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

/// <summary>
/// A node that sets a tag on an agent.
/// </summary>
public class SetTagNode : Node
{
	private readonly Agent Agent;
	private readonly string Tag;
	private readonly bool Set;

	private bool _applied;

	public SetTagNode( Agent agent, string tag, bool set )
	{
		Agent = agent;
		Tag = tag;
		Set = set;
	}

	public override Status Tick()
	{
		if ( !_applied && Agent.IsValid() )
		{
			Agent.Tags.Set( Tag, Set );
			_applied = true;
		}
		return Status.Success;
	}
}