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

/// <summary>
/// A node that handles repairing a ride.
/// </summary>
public class RepairRideNode : Node
{
	private readonly BasicRide Ride;
	private readonly Staff Staff;

	private TimeUntil timer;

	public RepairRideNode( Staff staff, BasicRide ride )
	{
		Ride = ride;
		Staff = staff;
	}

	protected override void OnStart()
	{
		Staff.SetSequenceOverride( "Action_Repair" );
		timer = 5;
	}

	public override Status Tick()
	{
		if ( !timer )
			return Status.Running;

		Staff.IncreaseStat( StaffStats.RidesRepaired );
		Staff.SetSequenceOverride( null );

		Ride.Repair();

		return Status.Success;
	}

	public override ActionDisplayInfo? GetDisplay()
	{
		return new ActionDisplayInfo(
			"plumbing",
			$"Repairing {Ride.Title}",
			timer.Fraction
		);
	}
}