using Godot;

namespace Newlon.Components;

public partial class TimeScalableTimer : Timer
{
	[Export] private Entity entity;

	private float internal_timescale;
	public override void _Ready()
	{
		internal_timescale = entity.LocalTimescale;
		entity.OnLocalTimescaleChanged += OnTimescaleChanged;
	}

	private void OnTimescaleChanged(float timescale)
	{
		WaitTime *= internal_timescale / timescale;
		internal_timescale = timescale;
	}
}
