using System.Threading;
using Content.Server.NPC.Components;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.NPC.HTN;
[RegisterComponent, ComponentReference(typeof(NPCComponent))]
public sealed class HTNComponent : NPCComponent
{
///
/// The base task to use for planning
///
[ViewVariables(VVAccess.ReadWrite),
DataField("rootTask", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))]
public string 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;
[ViewVariables]
public HTNPlanJob? PlanningJob = null;
[ViewVariables]
public CancellationTokenSource? PlanningToken = null;
///
/// Is this NPC currently planning?
///
[ViewVariables] public bool Planning => PlanningJob != null;
}