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

/// <summary>
/// A node that makes an agent look at a point
/// </summary>
public class LookAtNode : Node
{
	private readonly Agent Agent;
	private readonly Vector3 Target;

	public LookAtNode( Agent agent, Vector3 target )
	{
		Agent = agent;
		Target = target;
	}

	public override Status Tick()
	{
		var delta = Target - Agent.WorldPosition;
		Agent.WorldRotation = Rotation.LookAt( delta.Normal, Agent.WorldRotation.Up );

		return Status.Success;
	}
}