Npcs/Scientist/ScientistSearchSchedule.cs

A NPC schedule for a Scientist that makes the NPC move to a target position, look at it, and wait for one second. It cancels early if the NPC's senses detect a visible entity.

using Sandbox.Npcs.Tasks;

namespace Sandbox.Npcs.Schedules;

public sealed class ScientistSearchSchedule : ScheduleBase
{
	public Vector3 Target { get; set; }

	protected override void OnStart()
	{
		AddTask( new MoveTo( Target ) );
		AddTask( new LookAt( Target ) );
		AddTask( new Wait( 1f ) );
	}

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