class Interval {
	private time = 0;

	constructor(private interval: number) {}

	next(dt: number) {
		this.time += dt;
		if (this.time >= this.interval) {
			this.time %= this.interval;
			return true;
		}

		return false;
	}

	reset() {
		this.time = 0;
	}

	decrease(diff: number) {
		this.interval = Math.max(100, this.interval - diff);
	}
}

export default Interval;
