using System.Threading;
using Content.Server.NPC.Components;
namespace Content.Server.NPC.HTN;
[RegisterComponent]
public sealed partial class HTNComponent : NPCComponent
{
/// <summary>
/// The base task to use for planning
/// </summary>
[ViewVariables(VVAccess.ReadWrite),
DataField("rootTask", required: true)]
public HTNCompoundTask RootTask = default!;
/// Check any active services for our current plan. This is used to find new targets for example without changing our plan.
[DataField("checkServices")]
public bool CheckServices = true;
/// The NPC's current plan.
[ViewVariables]
public HTNPlan? Plan;
/// How long to wait after having planned to try planning again.
[ViewVariables(VVAccess.ReadWrite), DataField("planCooldown")]
public float PlanCooldown = 0.45f;
/// How much longer until we can try re-planning. This will happen even during update in case something changed.
[ViewVariables(VVAccess.ReadWrite)]
public float PlanAccumulator = 0f;
public HTNPlanJob? PlanningJob = null;
public CancellationTokenSource? PlanningToken = null;
/// Is this NPC currently planning?
[ViewVariables] public bool Planning => PlanningJob != null;
/// Determines whether plans should be made / updated for this entity
[DataField]
public bool Enabled = true;
}