mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Make HTN constantly replanning optional (#33023)
Make constant replanning optional And apply it to our most expensive NPCs
This commit is contained in:
parent
90359e407c
commit
cca5a88be4
5 changed files with 9 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue