private static Path FindNearestToCapture(Context cx, int from) { if (Cache.TryGetValue(from, out var path) && ShouldCapture(cx, cx.Nodes[path.Last()])) { return(path); } path = Astar.FindNearest(cx.Nodes, from, n => ShouldCapture(cx, n)); Cache[from] = path; return(path); }