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)]
|
||||
public float PlanAccumulator = 0f;
|
||||
|
||||
[DataField]
|
||||
public bool ConstantlyReplan = true;
|
||||
|
||||
[ViewVariables]
|
||||
public HTNPlanJob? PlanningJob = null;
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ public sealed class HTNSystem : EntitySystem
|
||||
component.PlanAccumulator -= frameTime;
|
||||
|
||||
// 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);
|
||||
}
|
||||
@@ -462,7 +462,7 @@ public sealed class HTNSystem : EntitySystem
|
||||
if (component.PlanningJob != null)
|
||||
return;
|
||||
|
||||
component.PlanAccumulator += component.PlanCooldown;
|
||||
component.PlanAccumulator = component.PlanCooldown;
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var branchTraversal = component.Plan?.BranchTraversalRecord;
|
||||
|
||||
|
||||
@@ -332,6 +332,7 @@
|
||||
- type: Item
|
||||
size: Tiny
|
||||
- type: HTN
|
||||
constantlyReplan: false
|
||||
rootTask:
|
||||
task: MouseCompound
|
||||
- type: Physics
|
||||
@@ -1681,6 +1682,7 @@
|
||||
factions:
|
||||
- Mouse
|
||||
- type: HTN
|
||||
constantlyReplan: false
|
||||
rootTask:
|
||||
task: MouseCompound
|
||||
- type: Physics
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
factions:
|
||||
- SimpleHostile
|
||||
- type: HTN
|
||||
constantlyReplan: false
|
||||
rootTask:
|
||||
task: GoliathCompound
|
||||
blackboard:
|
||||
|
||||
@@ -405,6 +405,7 @@
|
||||
factions:
|
||||
- Mouse
|
||||
- type: HTN
|
||||
constantlyReplan: false
|
||||
rootTask:
|
||||
task: MouseCompound
|
||||
- type: Physics
|
||||
|
||||
Reference in New Issue
Block a user