]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make HTN constantly replanning optional (#33023)
authorosjarw <62134478+osjarw@users.noreply.github.com>
Fri, 18 Apr 2025 08:16:26 +0000 (11:16 +0300)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 08:16:26 +0000 (18:16 +1000)
Make constant replanning optional
And apply it to our most expensive NPCs

Content.Server/NPC/HTN/HTNComponent.cs
Content.Server/NPC/HTN/HTNSystem.cs
Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Resources/Prototypes/Entities/Mobs/NPCs/asteroid.yml
Resources/Prototypes/Entities/Mobs/NPCs/space.yml

index 788a3476382b71c9aaa2c88baa778fcc27b7a62a..43b8a70785a12c6fe346f93348f29f79394775a1 100644 (file)
@@ -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;
 
index ce4b248a0d267e5d147efad902a22ed69d712b6d..89b4ae778660c77c41195a35ffa9e1903253af66 100644 (file)
@@ -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;
 
index a7aca49505f15adcb87cbd5e1daf62a25958a5f5..22f818d56b8935a5c02fab8bde57ce83e0338c9b 100644 (file)
   - type: Item
     size: Tiny
   - type: HTN
+    constantlyReplan: false
     rootTask:
       task: MouseCompound
   - type: Physics
     factions:
       - Mouse
   - type: HTN
+    constantlyReplan: false
     rootTask:
       task: MouseCompound
   - type: Physics
index dcc8c4fbb8d93234aedb010c155770b07ed3dcb4..c7279801f01fe066fe593debd1a9a6fc9fed3155 100644 (file)
@@ -70,6 +70,7 @@
     factions:
     - SimpleHostile
   - type: HTN
+    constantlyReplan: false
     rootTask:
       task: GoliathCompound
     blackboard:
index 4ae6813963dd60350bc3a89d532e27706f146a51..9ed92709ea5b227dbf740a301c93be3dee20c8c5 100644 (file)
     factions:
       - Mouse
   - type: HTN
+    constantlyReplan: false
     rootTask:
       task: MouseCompound
   - type: Physics