zymex22 / Project-RimFactory-Revived

Project RimFactory Revived
MIT License
46 stars 34 forks source link

(Bug report) CanReach patch (While Path is blocked) sometimes causes Pathing Issues #691

Closed Sn1p3rr3c0n closed 1 year ago

Sn1p3rr3c0n commented 1 year ago

The Issue occurs if a User wants to use the Advanced IO Ports while having the access to the DSU Blocked (No path to the DSU). To allow Pathing they need to activate the CanReach Patch. Then in some cases the Pathing will fail.

There are currently two Scenarios in which I can reproduce that issue.

General Requirements

  1. The Path to the DSU is blocked
  2. The DSU Contains Items that the Pawn Wants
  3. There are not alternatives outside the DSU
  4. The CanReach Patch is active

Standing Drafted

seems to not occur for Food

  1. Have a Drafted Pawn near the Advanced IO Port
  2. It shall be closer to the Advanced IO Port then the DSU
  3. It shall not be directly next to the Advanced IO Port
  4. Undraft the pawn while it is standing Still

What Happens If the Pawn is standing still when it is undrafted the Pathing will fail. If the pawn is moving when it is undrafted the Pathing will work in most cases

Distance Case

  1. Have a Pawn Drafted or not
  2. It shall be closer to the DSU then the Advanced IO Port

What Happens The Pathing to Items contained in the DSU will constantly fail. Note a standalone Pawn that is closer to a Advanced IO Port then the DSU will not have any issues except the Standing Drafted Senario

Related Warning:

Erisen pathing from (268, 0, 160) to Thing_MealSurvivalPack27401 ran out of cells to process.
Job:Ingest (Job_20867) A=Thing_MealSurvivalPack27401
Faction: PlayerColony
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Warning (string)
Verse.AI.PathFinder:FindPath (Verse.IntVec3,Verse.LocalTargetInfo,Verse.TraverseParms,Verse.AI.PathEndMode,Verse.AI.PathFinderCostTuning)
Verse.AI.PathFinder:FindPath (Verse.IntVec3,Verse.LocalTargetInfo,Verse.Pawn,Verse.AI.PathEndMode,Verse.AI.PathFinderCostTuning)
Verse.AI.Pawn_PathFollower:GenerateNewPath ()
Verse.AI.Pawn_PathFollower:TrySetNewPath ()
Verse.AI.Pawn_PathFollower:TryEnterNextPathCell ()
Verse.AI.Pawn_PathFollower:PatherTick ()
Verse.Pawn:Tick ()
Verse.TickList:Tick ()
Verse.TickManager:DoSingleTick ()
Verse.TickManager:TickManagerUpdate ()
Verse.Game:UpdatePlay ()
Verse.Root_Play:Update ()
Sn1p3rr3c0n commented 1 year ago

For the Distance Case The issue here is that the CanReach Patch Tells the Pawn that i can Reach the Item in question. (so far so good) But then the Patches that actually make use of the Advanced IO Pot choose not to use them (ups..) --> We need to detect if the Path to the DSU Is Blocked and then force pawns to use the Advanced IO Ports instead of selecting the shorter path

Sn1p3rr3c0n commented 1 year ago

All issues described in this Ticket should have been resolved. One thing to note is that the Current Implementation of the CanReach Patch does not support the JobDriver_HaulToTransporter This is Caused as the CanReach Check is Performed Differently for this case- Here the Check is if the Position of the Item can reach the Transporter

Sn1p3rr3c0n commented 1 year ago

One Interesting side effect of those changes is that the Performance of the CanReach Patch has been significantly improved.

Before

CanReachBaseline Note: The pink line indicates ~0.5ms Regardless of if it was needed or not, CanReach takes a significant amount of time to run

After

image Note: The purple line indicates ~0.06ms The pink line indicates ~0.5ms

You can clearly see at what point the patch was no longer required and the associated load falling off dramatically. Additionally the spikes are much lower now