import EventEmitter from 'eventemitter3';

import type { Service } from '../types';
import type { ClockEvents } from './Clock';

/** Passive clock placeholder used when no active clock is registered. */
export default class NullClock extends EventEmitter<ClockEvents> implements Service
{
    public name = 'NullClock';
    public readonly serviceType = 'clock';

    public elapsedTime = 0;
    public deltaMS = 0;
    public fps = 0;
    public paused = false;
    public timeScale = 1;

    public run(): void
    {
        // No-op for the null service.
    }

    public pause(): void
    {
        this.paused = true;
    }

    public resume(): void
    {
        this.paused = false;
    }

    public setTimeScale(_scale: number): void
    {
        // No-op.
    }

    public dispose(): void
    {
        this.removeAllListeners();
    }
}
