AI/Animals/Actions/TranquilizedAction.cs
namespace HC3;

[Icon( "bedtime" )]
public sealed class TranquilizedAction : AgentAction
{
	private RealTimeSince _tranquilizedTime;

	public override float Score()
	{
		// Only activate when tranquilized
		if ( !Agent.Tags.Has( "tranquilized" ) )
			return 0f;

		// Very high priority to override other behaviors
		return 1000f;
	}

	public override void StartAction()
	{
		base.StartAction();

		// Clear any existing navigation
		Controller.ClearNavigation();

		// Track how long we've been tranquilized
		_tranquilizedTime = 0;

		// Make the animal sleep
		Agent.SetSequenceOverride( "Sleep", 0.5f );
	}

	public override Status TickAction()
	{
		// If no longer tranquilized, end the action
		if ( !Agent.Tags.Has( "tranquilized" ) )
			return Status.Success;

		// Make sure navigation is cleared
		if ( Controller.IsNavigating )
			Controller.ClearNavigation();

		// Continue sleeping
		return Status.Running;
	}

	public override void StopAction()
	{
		base.StopAction();

		// Clear sequence override when action ends
		Agent.SetSequenceOverride( null );
	}

	public override ActionDisplayInfo? GetDisplay()
	{
		return new ActionDisplayInfo(
			"bedtime",
			"Tranquilized",
			0
		);
	}
}