mwg API
    Preparing search index...

    Class EnvironmentClock

    A continuous world clock that maps elapsed time to day phase and weather.

    import { EnvironmentClock } from '@datamoc/mw_games/world';

    const clock = new EnvironmentClock({ dayLength: 600 }); // a 10-minute day
    clock.setWeather('rain');

    // in the game loop:
    const snapshot = clock.update(1 / 60);
    console.log(snapshot.phase, snapshot.weather);
    Index
    changed: Signal<EnvironmentSnapshot> = ...
    dayLength: number
    • Advances the clock by dt real seconds.

      update(dt) rather than advance(), because this is the one clock here measured in real time rather than turns: everything named advance in this framework takes whole turns or rounds (TurnClock, Charges, Field, Barrier, AbilityCycle), and everything named update takes dt seconds, as it already did throughout render, ui and audio.

      Parameters

      • dt: number

      Returns EnvironmentSnapshot