Make HTN constantly replanning optional (#33023)
Make constant replanning optional And apply it to our most expensive NPCs
This commit is contained in:
@@ -37,6 +37,9 @@ public sealed partial class HTNComponent : NPCComponent
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float PlanAccumulator = 0f;
|
public float PlanAccumulator = 0f;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool ConstantlyReplan = true;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public HTNPlanJob? PlanningJob = null;
|
public HTNPlanJob? PlanningJob = null;
|
||||||
|
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ public sealed class HTNSystem : EntitySystem
|
|||||||
component.PlanAccumulator -= frameTime;
|
component.PlanAccumulator -= frameTime;
|
||||||
|
|
||||||
// We'll still try re-planning occasionally even when we're updating in case new data comes in.
|
// We'll still try re-planning occasionally even when we're updating in case new data comes in.
|
||||||
if (component.PlanAccumulator <= 0f)
|
if ((component.ConstantlyReplan || component.Plan is null) && component.PlanAccumulator <= 0f)
|
||||||
{
|
{
|
||||||
RequestPlan(component);
|
RequestPlan(component);
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ public sealed class HTNSystem : EntitySystem
|
|||||||
if (component.PlanningJob != null)
|
if (component.PlanningJob != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.PlanAccumulator += component.PlanCooldown;
|
component.PlanAccumulator = component.PlanCooldown;
|
||||||
var cancelToken = new CancellationTokenSource();
|
var cancelToken = new CancellationTokenSource();
|
||||||
var branchTraversal = component.Plan?.BranchTraversalRecord;
|
var branchTraversal = component.Plan?.BranchTraversalRecord;
|
||||||
|
|
||||||
|
|||||||
@@ -332,6 +332,7 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
size: Tiny
|
size: Tiny
|
||||||
- type: HTN
|
- type: HTN
|
||||||
|
constantlyReplan: false
|
||||||
rootTask:
|
rootTask:
|
||||||
task: MouseCompound
|
task: MouseCompound
|
||||||
- type: Physics
|
- type: Physics
|
||||||
@@ -1681,6 +1682,7 @@
|
|||||||
factions:
|
factions:
|
||||||
- Mouse
|
- Mouse
|
||||||
- type: HTN
|
- type: HTN
|
||||||
|
constantlyReplan: false
|
||||||
rootTask:
|
rootTask:
|
||||||
task: MouseCompound
|
task: MouseCompound
|
||||||
- type: Physics
|
- type: Physics
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
factions:
|
factions:
|
||||||
- SimpleHostile
|
- SimpleHostile
|
||||||
- type: HTN
|
- type: HTN
|
||||||
|
constantlyReplan: false
|
||||||
rootTask:
|
rootTask:
|
||||||
task: GoliathCompound
|
task: GoliathCompound
|
||||||
blackboard:
|
blackboard:
|
||||||
|
|||||||
@@ -405,6 +405,7 @@
|
|||||||
factions:
|
factions:
|
||||||
- Mouse
|
- Mouse
|
||||||
- type: HTN
|
- type: HTN
|
||||||
|
constantlyReplan: false
|
||||||
rootTask:
|
rootTask:
|
||||||
task: MouseCompound
|
task: MouseCompound
|
||||||
- type: Physics
|
- type: Physics
|
||||||
|
|||||||
Reference in New Issue
Block a user