import Hook from './Hook';

/**
 * @class DelayHook
 * @extends Hook
 * @description Hook that implements a delay, completing after the specified duration has passed.
 */
class DelayHook extends Hook
{
    private delayDuration: number;
    private elapsedTime: number;

    /**
     * @class
     * @param {number} delayDuration - Duration of the delay in milliseconds.
     */
    constructor(delayDuration: number)
    {
        super();
        this.delayDuration = delayDuration;
        this.elapsedTime = 0;
    }

    /**
     * Updates the elapsed time and checks if the delay duration has been reached.
     * @param {number} dt - Delta time since the last update in milliseconds.
     */
    update(dt: number): void
    {
        this.elapsedTime += dt * 0.001;
    }

    /**
     * Checks if the delay has completed.
     * @returns {boolean} - Returns `true` if the delay has reached its duration, otherwise `false`.
     */
    isComplete(): boolean
    {
        return this.elapsedTime >= this.delayDuration;
    }
}

export default DelayHook;
