Add parallel NPC steering back in (#13159)

This commit is contained in:
metalgearsloth
2022-12-24 12:37:58 +11:00
committed by GitHub
parent e884be64fa
commit b78ca238c6
2 changed files with 24 additions and 3 deletions

View File

@@ -61,6 +61,20 @@ public sealed class HTNSystem : EntitySystem
private void OnLoad()
{
// Clear all NPCs in case they're hanging onto stale tasks
foreach (var comp in EntityQuery<HTNComponent>(true))
{
comp.PlanningToken?.Cancel();
comp.PlanningToken = null;
if (comp.Plan != null)
{
var currentOperator = comp.Plan.CurrentOperator;
currentOperator.Shutdown(comp.Blackboard, HTNOperatorStatus.Failed);
comp.Plan = null;
}
}
// Add dependencies for all operators.
// We put code on operators as I couldn't think of a clean way to put it on systems.
foreach (var compound in _prototypeManager.EnumeratePrototypes<HTNCompoundTask>())