Npcs/Rollermine/RollermineIdleSchedule.cs

An NPC schedule for a Rollermine that makes it idle when it has no visible target. On start it adds a Wait task of a random duration between 1 and 2.5 seconds, and it cancels early if a visible target appears.

using Sandbox.Npcs.Tasks;

namespace Sandbox.Npcs.Rollermine.Schedules;

/// <summary>
/// Rollermine idles when no target is visible — waits briefly then re-evaluates.
/// </summary>
public class RollermineIdleSchedule : ScheduleBase
{
	protected override void OnStart()
	{
		AddTask( new Wait( Game.Random.Float( 1f, 2.5f ) ) );
	}

	protected override bool ShouldCancel()
	{
		return Npc.Senses.GetNearestVisible().IsValid();
	}
}