using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; namespace Content.Server.NPC.HTN.PrimitiveTasks; /// /// Concrete code that gets run for an NPC task. /// [ImplicitDataDefinitionForInheritors, MeansImplicitUse] public abstract partial class HTNOperator { /// /// Called once whenever prototypes reload. Typically used to inject dependencies. /// public virtual void Initialize(IEntitySystemManager sysManager) { IoCManager.InjectDependencies(this); } /// /// Called during planning. /// /// The blackboard for the NPC. /// /// Whether the plan is still valid and the effects to apply to the blackboard. /// These get re-applied during execution and are up to the operator to use or discard. public virtual async Task<(bool Valid, Dictionary? Effects)> Plan(NPCBlackboard blackboard, CancellationToken cancelToken) { return (true, null); } /// /// Called during the NPC's regular updates. If the logic requires coordination between NPCs (e.g. steering or combat) /// this may be better off using a component and letting an external system handling it. /// public virtual HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime) { return HTNOperatorStatus.Finished; } /// /// Called when the plan has finished running. /// public virtual void PlanShutdown(NPCBlackboard blackboard) { } /// /// Called the first time an operator runs. /// public virtual void Startup(NPCBlackboard blackboard) {} /// /// Called whenever the operator stops running. /// public virtual void TaskShutdown(NPCBlackboard blackboard, HTNOperatorStatus status) {} }