NPC refactor (#10122)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
45
Content.Server/NPC/HTN/HTNComponent.cs
Normal file
45
Content.Server/NPC/HTN/HTNComponent.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// The base task to use for planning
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite),
|
||||
DataField("rootTask", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<HTNCompoundTask>))]
|
||||
public string RootTask = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The NPC's current plan.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public HTNPlan? Plan;
|
||||
|
||||
/// <summary>
|
||||
/// How long to wait after having planned to try planning again.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("planCooldown")]
|
||||
public float PlanCooldown = 0.45f;
|
||||
|
||||
/// <summary>
|
||||
/// How much longer until we can try re-planning. This will happen even during update in case something changed.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PlanAccumulator = 0f;
|
||||
|
||||
[ViewVariables]
|
||||
public HTNPlanJob? PlanningJob = null;
|
||||
|
||||
[ViewVariables]
|
||||
public CancellationTokenSource? PlanningToken = null;
|
||||
|
||||
/// <summary>
|
||||
/// Is this NPC currently planning?
|
||||
/// </summary>
|
||||
[ViewVariables] public bool Planning => PlanningJob != null;
|
||||
}
|
||||
Reference in New Issue
Block a user