AI/ActionSystem/BehaviorTree/Nodes/DelayNode.cs
namespace HC3;

/// <summary>
/// A node that delays execution for a specified duration.
/// </summary>
public class DelayNode : Node
{
	float _duration { get; init; }
	TimeUntil _timeUntil;
	string _reason;

	public DelayNode( float duration, string reason = null )
	{
		_duration = duration;
		_reason = reason;
	}

	protected override void OnStart()
	{
		_timeUntil = _duration;
	}

	public override Status Tick()
	{
		if ( _timeUntil )
		{
			return Status.Success;
		}

		return Status.Running;
	}

	public override ActionDisplayInfo? GetDisplay()
	{
		if ( _reason is null ) return null;

		return new ActionDisplayInfo(
			"pending",
			_reason,
			_timeUntil / _duration
		);
	}
}