Npcs/Roller/RollerIdleSchedule.cs

An NPC schedule for the Roller NPC that makes it idle when it has no visible target. On start it adds a Wait task for a random 1.0–2.5 seconds. It cancels the schedule if a visible target appears.

using Sandbox.Npcs.Tasks;

namespace Sandbox.Npcs.Roller.Schedules;

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

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