@esengine/pathfinding 12.0.0 → 12.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/nodes.js ADDED
@@ -0,0 +1,1174 @@
1
+ import {
2
+ PathfindingState,
3
+ __name
4
+ } from "./chunk-GTFFYRZM.js";
5
+
6
+ // src/nodes/PathfindingNodes.ts
7
+ var FindPathTemplate = {
8
+ type: "FindPath",
9
+ title: "Find Path",
10
+ category: "custom",
11
+ description: "Find path from start to end / \u4ECE\u8D77\u70B9\u5230\u7EC8\u70B9\u5BFB\u8DEF",
12
+ keywords: [
13
+ "path",
14
+ "pathfinding",
15
+ "astar",
16
+ "navigate",
17
+ "route"
18
+ ],
19
+ menuPath: [
20
+ "Pathfinding",
21
+ "Find Path"
22
+ ],
23
+ inputs: [
24
+ {
25
+ name: "exec",
26
+ displayName: "",
27
+ type: "exec"
28
+ },
29
+ {
30
+ name: "startX",
31
+ displayName: "Start X",
32
+ type: "float"
33
+ },
34
+ {
35
+ name: "startY",
36
+ displayName: "Start Y",
37
+ type: "float"
38
+ },
39
+ {
40
+ name: "endX",
41
+ displayName: "End X",
42
+ type: "float"
43
+ },
44
+ {
45
+ name: "endY",
46
+ displayName: "End Y",
47
+ type: "float"
48
+ }
49
+ ],
50
+ outputs: [
51
+ {
52
+ name: "exec",
53
+ displayName: "",
54
+ type: "exec"
55
+ },
56
+ {
57
+ name: "found",
58
+ displayName: "Found",
59
+ type: "bool"
60
+ },
61
+ {
62
+ name: "path",
63
+ displayName: "Path",
64
+ type: "array"
65
+ },
66
+ {
67
+ name: "cost",
68
+ displayName: "Cost",
69
+ type: "float"
70
+ }
71
+ ],
72
+ color: "#4caf50"
73
+ };
74
+ var _FindPathExecutor = class _FindPathExecutor {
75
+ execute(node, context) {
76
+ const ctx = context;
77
+ const startX = ctx.evaluateInput(node.id, "startX", 0);
78
+ const startY = ctx.evaluateInput(node.id, "startY", 0);
79
+ const endX = ctx.evaluateInput(node.id, "endX", 0);
80
+ const endY = ctx.evaluateInput(node.id, "endY", 0);
81
+ const result = ctx.findPath(startX, startY, endX, endY);
82
+ return {
83
+ outputs: {
84
+ found: result.found,
85
+ path: result.path,
86
+ cost: result.cost
87
+ },
88
+ nextExec: "exec"
89
+ };
90
+ }
91
+ };
92
+ __name(_FindPathExecutor, "FindPathExecutor");
93
+ var FindPathExecutor = _FindPathExecutor;
94
+ var FindPathSmoothTemplate = {
95
+ type: "FindPathSmooth",
96
+ title: "Find Path (Smooth)",
97
+ category: "custom",
98
+ description: "Find path with smoothing / \u5BFB\u8DEF\u5E76\u5E73\u6ED1\u8DEF\u5F84",
99
+ keywords: [
100
+ "path",
101
+ "pathfinding",
102
+ "smooth",
103
+ "navigate"
104
+ ],
105
+ menuPath: [
106
+ "Pathfinding",
107
+ "Find Path (Smooth)"
108
+ ],
109
+ inputs: [
110
+ {
111
+ name: "exec",
112
+ displayName: "",
113
+ type: "exec"
114
+ },
115
+ {
116
+ name: "startX",
117
+ displayName: "Start X",
118
+ type: "float"
119
+ },
120
+ {
121
+ name: "startY",
122
+ displayName: "Start Y",
123
+ type: "float"
124
+ },
125
+ {
126
+ name: "endX",
127
+ displayName: "End X",
128
+ type: "float"
129
+ },
130
+ {
131
+ name: "endY",
132
+ displayName: "End Y",
133
+ type: "float"
134
+ }
135
+ ],
136
+ outputs: [
137
+ {
138
+ name: "exec",
139
+ displayName: "",
140
+ type: "exec"
141
+ },
142
+ {
143
+ name: "found",
144
+ displayName: "Found",
145
+ type: "bool"
146
+ },
147
+ {
148
+ name: "path",
149
+ displayName: "Path",
150
+ type: "array"
151
+ },
152
+ {
153
+ name: "cost",
154
+ displayName: "Cost",
155
+ type: "float"
156
+ }
157
+ ],
158
+ color: "#4caf50"
159
+ };
160
+ var _FindPathSmoothExecutor = class _FindPathSmoothExecutor {
161
+ execute(node, context) {
162
+ const ctx = context;
163
+ const startX = ctx.evaluateInput(node.id, "startX", 0);
164
+ const startY = ctx.evaluateInput(node.id, "startY", 0);
165
+ const endX = ctx.evaluateInput(node.id, "endX", 0);
166
+ const endY = ctx.evaluateInput(node.id, "endY", 0);
167
+ const result = ctx.findPathSmooth(startX, startY, endX, endY);
168
+ return {
169
+ outputs: {
170
+ found: result.found,
171
+ path: result.path,
172
+ cost: result.cost
173
+ },
174
+ nextExec: "exec"
175
+ };
176
+ }
177
+ };
178
+ __name(_FindPathSmoothExecutor, "FindPathSmoothExecutor");
179
+ var FindPathSmoothExecutor = _FindPathSmoothExecutor;
180
+ var IsWalkableTemplate = {
181
+ type: "IsWalkable",
182
+ title: "Is Walkable",
183
+ category: "custom",
184
+ description: "Check if position is walkable / \u68C0\u67E5\u4F4D\u7F6E\u662F\u5426\u53EF\u901A\u884C",
185
+ keywords: [
186
+ "walkable",
187
+ "obstacle",
188
+ "blocked",
189
+ "terrain"
190
+ ],
191
+ menuPath: [
192
+ "Pathfinding",
193
+ "Is Walkable"
194
+ ],
195
+ isPure: true,
196
+ inputs: [
197
+ {
198
+ name: "x",
199
+ displayName: "X",
200
+ type: "float"
201
+ },
202
+ {
203
+ name: "y",
204
+ displayName: "Y",
205
+ type: "float"
206
+ }
207
+ ],
208
+ outputs: [
209
+ {
210
+ name: "walkable",
211
+ displayName: "Walkable",
212
+ type: "bool"
213
+ }
214
+ ],
215
+ color: "#4caf50"
216
+ };
217
+ var _IsWalkableExecutor = class _IsWalkableExecutor {
218
+ execute(node, context) {
219
+ const ctx = context;
220
+ const x = ctx.evaluateInput(node.id, "x", 0);
221
+ const y = ctx.evaluateInput(node.id, "y", 0);
222
+ const walkable = ctx.isWalkable(x, y);
223
+ return {
224
+ outputs: {
225
+ walkable
226
+ }
227
+ };
228
+ }
229
+ };
230
+ __name(_IsWalkableExecutor, "IsWalkableExecutor");
231
+ var IsWalkableExecutor = _IsWalkableExecutor;
232
+ var GetPathLengthTemplate = {
233
+ type: "GetPathLength",
234
+ title: "Get Path Length",
235
+ category: "custom",
236
+ description: "Get the number of points in path / \u83B7\u53D6\u8DEF\u5F84\u70B9\u6570\u91CF",
237
+ keywords: [
238
+ "path",
239
+ "length",
240
+ "count",
241
+ "waypoints"
242
+ ],
243
+ menuPath: [
244
+ "Pathfinding",
245
+ "Get Path Length"
246
+ ],
247
+ isPure: true,
248
+ inputs: [
249
+ {
250
+ name: "path",
251
+ displayName: "Path",
252
+ type: "array"
253
+ }
254
+ ],
255
+ outputs: [
256
+ {
257
+ name: "length",
258
+ displayName: "Length",
259
+ type: "int"
260
+ }
261
+ ],
262
+ color: "#4caf50"
263
+ };
264
+ var _GetPathLengthExecutor = class _GetPathLengthExecutor {
265
+ execute(node, context) {
266
+ const ctx = context;
267
+ const path = ctx.evaluateInput(node.id, "path", []);
268
+ return {
269
+ outputs: {
270
+ length: path.length
271
+ }
272
+ };
273
+ }
274
+ };
275
+ __name(_GetPathLengthExecutor, "GetPathLengthExecutor");
276
+ var GetPathLengthExecutor = _GetPathLengthExecutor;
277
+ var GetPathDistanceTemplate = {
278
+ type: "GetPathDistance",
279
+ title: "Get Path Distance",
280
+ category: "custom",
281
+ description: "Get total path distance / \u83B7\u53D6\u8DEF\u5F84\u603B\u8DDD\u79BB",
282
+ keywords: [
283
+ "path",
284
+ "distance",
285
+ "length",
286
+ "travel"
287
+ ],
288
+ menuPath: [
289
+ "Pathfinding",
290
+ "Get Path Distance"
291
+ ],
292
+ isPure: true,
293
+ inputs: [
294
+ {
295
+ name: "path",
296
+ displayName: "Path",
297
+ type: "array"
298
+ }
299
+ ],
300
+ outputs: [
301
+ {
302
+ name: "distance",
303
+ displayName: "Distance",
304
+ type: "float"
305
+ }
306
+ ],
307
+ color: "#4caf50"
308
+ };
309
+ var _GetPathDistanceExecutor = class _GetPathDistanceExecutor {
310
+ execute(node, context) {
311
+ const ctx = context;
312
+ const path = ctx.evaluateInput(node.id, "path", []);
313
+ const distance = ctx.getPathDistance(path);
314
+ return {
315
+ outputs: {
316
+ distance
317
+ }
318
+ };
319
+ }
320
+ };
321
+ __name(_GetPathDistanceExecutor, "GetPathDistanceExecutor");
322
+ var GetPathDistanceExecutor = _GetPathDistanceExecutor;
323
+ var GetPathPointTemplate = {
324
+ type: "GetPathPoint",
325
+ title: "Get Path Point",
326
+ category: "custom",
327
+ description: "Get point at index in path / \u83B7\u53D6\u8DEF\u5F84\u4E2D\u6307\u5B9A\u7D22\u5F15\u7684\u70B9",
328
+ keywords: [
329
+ "path",
330
+ "point",
331
+ "waypoint",
332
+ "index"
333
+ ],
334
+ menuPath: [
335
+ "Pathfinding",
336
+ "Get Path Point"
337
+ ],
338
+ isPure: true,
339
+ inputs: [
340
+ {
341
+ name: "path",
342
+ displayName: "Path",
343
+ type: "array"
344
+ },
345
+ {
346
+ name: "index",
347
+ displayName: "Index",
348
+ type: "int"
349
+ }
350
+ ],
351
+ outputs: [
352
+ {
353
+ name: "x",
354
+ displayName: "X",
355
+ type: "float"
356
+ },
357
+ {
358
+ name: "y",
359
+ displayName: "Y",
360
+ type: "float"
361
+ },
362
+ {
363
+ name: "valid",
364
+ displayName: "Valid",
365
+ type: "bool"
366
+ }
367
+ ],
368
+ color: "#4caf50"
369
+ };
370
+ var _GetPathPointExecutor = class _GetPathPointExecutor {
371
+ execute(node, context) {
372
+ const ctx = context;
373
+ const path = ctx.evaluateInput(node.id, "path", []);
374
+ const index = ctx.evaluateInput(node.id, "index", 0);
375
+ if (index >= 0 && index < path.length) {
376
+ return {
377
+ outputs: {
378
+ x: path[index].x,
379
+ y: path[index].y,
380
+ valid: true
381
+ }
382
+ };
383
+ }
384
+ return {
385
+ outputs: {
386
+ x: 0,
387
+ y: 0,
388
+ valid: false
389
+ }
390
+ };
391
+ }
392
+ };
393
+ __name(_GetPathPointExecutor, "GetPathPointExecutor");
394
+ var GetPathPointExecutor = _GetPathPointExecutor;
395
+ var MoveAlongPathTemplate = {
396
+ type: "MoveAlongPath",
397
+ title: "Move Along Path",
398
+ category: "custom",
399
+ description: "Get position along path at progress / \u83B7\u53D6\u8DEF\u5F84\u4E0A\u6307\u5B9A\u8FDB\u5EA6\u7684\u4F4D\u7F6E",
400
+ keywords: [
401
+ "path",
402
+ "move",
403
+ "lerp",
404
+ "progress",
405
+ "interpolate"
406
+ ],
407
+ menuPath: [
408
+ "Pathfinding",
409
+ "Move Along Path"
410
+ ],
411
+ isPure: true,
412
+ inputs: [
413
+ {
414
+ name: "path",
415
+ displayName: "Path",
416
+ type: "array"
417
+ },
418
+ {
419
+ name: "progress",
420
+ displayName: "Progress (0-1)",
421
+ type: "float"
422
+ }
423
+ ],
424
+ outputs: [
425
+ {
426
+ name: "x",
427
+ displayName: "X",
428
+ type: "float"
429
+ },
430
+ {
431
+ name: "y",
432
+ displayName: "Y",
433
+ type: "float"
434
+ }
435
+ ],
436
+ color: "#4caf50"
437
+ };
438
+ var _MoveAlongPathExecutor = class _MoveAlongPathExecutor {
439
+ execute(node, context) {
440
+ const ctx = context;
441
+ const path = ctx.evaluateInput(node.id, "path", []);
442
+ let progress = ctx.evaluateInput(node.id, "progress", 0);
443
+ if (path.length === 0) {
444
+ return {
445
+ outputs: {
446
+ x: 0,
447
+ y: 0
448
+ }
449
+ };
450
+ }
451
+ if (path.length === 1) {
452
+ return {
453
+ outputs: {
454
+ x: path[0].x,
455
+ y: path[0].y
456
+ }
457
+ };
458
+ }
459
+ progress = Math.max(0, Math.min(1, progress));
460
+ let totalDistance = 0;
461
+ const segmentDistances = [];
462
+ for (let i = 1; i < path.length; i++) {
463
+ const dx = path[i].x - path[i - 1].x;
464
+ const dy = path[i].y - path[i - 1].y;
465
+ const dist = Math.sqrt(dx * dx + dy * dy);
466
+ segmentDistances.push(dist);
467
+ totalDistance += dist;
468
+ }
469
+ if (totalDistance === 0) {
470
+ return {
471
+ outputs: {
472
+ x: path[0].x,
473
+ y: path[0].y
474
+ }
475
+ };
476
+ }
477
+ const targetDistance = progress * totalDistance;
478
+ let accumulatedDistance = 0;
479
+ for (let i = 0; i < segmentDistances.length; i++) {
480
+ const segmentDist = segmentDistances[i];
481
+ if (accumulatedDistance + segmentDist >= targetDistance) {
482
+ const segmentProgress = (targetDistance - accumulatedDistance) / segmentDist;
483
+ const x = path[i].x + (path[i + 1].x - path[i].x) * segmentProgress;
484
+ const y = path[i].y + (path[i + 1].y - path[i].y) * segmentProgress;
485
+ return {
486
+ outputs: {
487
+ x,
488
+ y
489
+ }
490
+ };
491
+ }
492
+ accumulatedDistance += segmentDist;
493
+ }
494
+ const last = path[path.length - 1];
495
+ return {
496
+ outputs: {
497
+ x: last.x,
498
+ y: last.y
499
+ }
500
+ };
501
+ }
502
+ };
503
+ __name(_MoveAlongPathExecutor, "MoveAlongPathExecutor");
504
+ var MoveAlongPathExecutor = _MoveAlongPathExecutor;
505
+ var HasLineOfSightTemplate = {
506
+ type: "HasLineOfSight",
507
+ title: "Has Line of Sight",
508
+ category: "custom",
509
+ description: "Check if there is a clear line between two points / \u68C0\u67E5\u4E24\u70B9\u4E4B\u95F4\u662F\u5426\u6709\u6E05\u6670\u7684\u89C6\u7EBF",
510
+ keywords: [
511
+ "line",
512
+ "sight",
513
+ "los",
514
+ "visibility",
515
+ "raycast"
516
+ ],
517
+ menuPath: [
518
+ "Pathfinding",
519
+ "Has Line of Sight"
520
+ ],
521
+ isPure: true,
522
+ inputs: [
523
+ {
524
+ name: "startX",
525
+ displayName: "Start X",
526
+ type: "float"
527
+ },
528
+ {
529
+ name: "startY",
530
+ displayName: "Start Y",
531
+ type: "float"
532
+ },
533
+ {
534
+ name: "endX",
535
+ displayName: "End X",
536
+ type: "float"
537
+ },
538
+ {
539
+ name: "endY",
540
+ displayName: "End Y",
541
+ type: "float"
542
+ }
543
+ ],
544
+ outputs: [
545
+ {
546
+ name: "hasLOS",
547
+ displayName: "Has LOS",
548
+ type: "bool"
549
+ }
550
+ ],
551
+ color: "#4caf50"
552
+ };
553
+ var _HasLineOfSightExecutor = class _HasLineOfSightExecutor {
554
+ execute(node, context) {
555
+ const ctx = context;
556
+ const startX = ctx.evaluateInput(node.id, "startX", 0);
557
+ const startY = ctx.evaluateInput(node.id, "startY", 0);
558
+ const endX = ctx.evaluateInput(node.id, "endX", 0);
559
+ const endY = ctx.evaluateInput(node.id, "endY", 0);
560
+ const hasLOS = ctx.hasLineOfSight?.(startX, startY, endX, endY) ?? true;
561
+ return {
562
+ outputs: {
563
+ hasLOS
564
+ }
565
+ };
566
+ }
567
+ };
568
+ __name(_HasLineOfSightExecutor, "HasLineOfSightExecutor");
569
+ var HasLineOfSightExecutor = _HasLineOfSightExecutor;
570
+ var PathfindingNodeDefinitions = {
571
+ templates: [
572
+ FindPathTemplate,
573
+ FindPathSmoothTemplate,
574
+ IsWalkableTemplate,
575
+ GetPathLengthTemplate,
576
+ GetPathDistanceTemplate,
577
+ GetPathPointTemplate,
578
+ MoveAlongPathTemplate,
579
+ HasLineOfSightTemplate
580
+ ],
581
+ executors: /* @__PURE__ */ new Map([
582
+ [
583
+ "FindPath",
584
+ new FindPathExecutor()
585
+ ],
586
+ [
587
+ "FindPathSmooth",
588
+ new FindPathSmoothExecutor()
589
+ ],
590
+ [
591
+ "IsWalkable",
592
+ new IsWalkableExecutor()
593
+ ],
594
+ [
595
+ "GetPathLength",
596
+ new GetPathLengthExecutor()
597
+ ],
598
+ [
599
+ "GetPathDistance",
600
+ new GetPathDistanceExecutor()
601
+ ],
602
+ [
603
+ "GetPathPoint",
604
+ new GetPathPointExecutor()
605
+ ],
606
+ [
607
+ "MoveAlongPath",
608
+ new MoveAlongPathExecutor()
609
+ ],
610
+ [
611
+ "HasLineOfSight",
612
+ new HasLineOfSightExecutor()
613
+ ]
614
+ ])
615
+ };
616
+
617
+ // src/nodes/IncrementalPathfindingNodes.ts
618
+ var RequestPathAsyncTemplate = {
619
+ type: "RequestPathAsync",
620
+ title: "Request Path (Async)",
621
+ category: "custom",
622
+ description: "Request incremental pathfinding / \u8BF7\u6C42\u589E\u91CF\u5BFB\u8DEF",
623
+ keywords: [
624
+ "path",
625
+ "pathfinding",
626
+ "async",
627
+ "incremental",
628
+ "request"
629
+ ],
630
+ menuPath: [
631
+ "Pathfinding",
632
+ "Incremental",
633
+ "Request Path (Async)"
634
+ ],
635
+ inputs: [
636
+ {
637
+ name: "exec",
638
+ displayName: "",
639
+ type: "exec"
640
+ },
641
+ {
642
+ name: "startX",
643
+ displayName: "Start X",
644
+ type: "float"
645
+ },
646
+ {
647
+ name: "startY",
648
+ displayName: "Start Y",
649
+ type: "float"
650
+ },
651
+ {
652
+ name: "endX",
653
+ displayName: "End X",
654
+ type: "float"
655
+ },
656
+ {
657
+ name: "endY",
658
+ displayName: "End Y",
659
+ type: "float"
660
+ },
661
+ {
662
+ name: "priority",
663
+ displayName: "Priority",
664
+ type: "int"
665
+ }
666
+ ],
667
+ outputs: [
668
+ {
669
+ name: "exec",
670
+ displayName: "",
671
+ type: "exec"
672
+ },
673
+ {
674
+ name: "requestId",
675
+ displayName: "Request ID",
676
+ type: "int"
677
+ }
678
+ ],
679
+ color: "#4caf50"
680
+ };
681
+ var _RequestPathAsyncExecutor = class _RequestPathAsyncExecutor {
682
+ execute(node, context) {
683
+ const ctx = context;
684
+ const startX = ctx.evaluateInput(node.id, "startX", 0);
685
+ const startY = ctx.evaluateInput(node.id, "startY", 0);
686
+ const endX = ctx.evaluateInput(node.id, "endX", 0);
687
+ const endY = ctx.evaluateInput(node.id, "endY", 0);
688
+ const priority = ctx.evaluateInput(node.id, "priority", 50);
689
+ const requestId = ctx.requestPath(startX, startY, endX, endY, priority);
690
+ return {
691
+ outputs: {
692
+ requestId
693
+ },
694
+ nextExec: "exec"
695
+ };
696
+ }
697
+ };
698
+ __name(_RequestPathAsyncExecutor, "RequestPathAsyncExecutor");
699
+ var RequestPathAsyncExecutor = _RequestPathAsyncExecutor;
700
+ var StepPathTemplate = {
701
+ type: "StepPath",
702
+ title: "Step Path",
703
+ category: "custom",
704
+ description: "Execute one step of pathfinding / \u6267\u884C\u4E00\u6B65\u5BFB\u8DEF",
705
+ keywords: [
706
+ "path",
707
+ "pathfinding",
708
+ "step",
709
+ "iterate",
710
+ "incremental"
711
+ ],
712
+ menuPath: [
713
+ "Pathfinding",
714
+ "Incremental",
715
+ "Step Path"
716
+ ],
717
+ inputs: [
718
+ {
719
+ name: "exec",
720
+ displayName: "",
721
+ type: "exec"
722
+ },
723
+ {
724
+ name: "requestId",
725
+ displayName: "Request ID",
726
+ type: "int"
727
+ },
728
+ {
729
+ name: "maxIterations",
730
+ displayName: "Max Iterations",
731
+ type: "int"
732
+ }
733
+ ],
734
+ outputs: [
735
+ {
736
+ name: "exec",
737
+ displayName: "",
738
+ type: "exec"
739
+ },
740
+ {
741
+ name: "state",
742
+ displayName: "State",
743
+ type: "string"
744
+ },
745
+ {
746
+ name: "progress",
747
+ displayName: "Progress",
748
+ type: "float"
749
+ },
750
+ {
751
+ name: "nodesSearched",
752
+ displayName: "Nodes Searched",
753
+ type: "int"
754
+ }
755
+ ],
756
+ color: "#4caf50"
757
+ };
758
+ var _StepPathExecutor = class _StepPathExecutor {
759
+ execute(node, context) {
760
+ const ctx = context;
761
+ const requestId = ctx.evaluateInput(node.id, "requestId", -1);
762
+ const maxIterations = ctx.evaluateInput(node.id, "maxIterations", 100);
763
+ const progress = ctx.stepPath(requestId, maxIterations);
764
+ return {
765
+ outputs: {
766
+ state: progress.state,
767
+ progress: progress.estimatedProgress,
768
+ nodesSearched: progress.nodesSearched
769
+ },
770
+ nextExec: "exec"
771
+ };
772
+ }
773
+ };
774
+ __name(_StepPathExecutor, "StepPathExecutor");
775
+ var StepPathExecutor = _StepPathExecutor;
776
+ var GetPathProgressTemplate = {
777
+ type: "GetPathProgress",
778
+ title: "Get Path Progress",
779
+ category: "custom",
780
+ description: "Get incremental pathfinding progress / \u83B7\u53D6\u589E\u91CF\u5BFB\u8DEF\u8FDB\u5EA6",
781
+ keywords: [
782
+ "path",
783
+ "progress",
784
+ "status",
785
+ "state"
786
+ ],
787
+ menuPath: [
788
+ "Pathfinding",
789
+ "Incremental",
790
+ "Get Path Progress"
791
+ ],
792
+ isPure: true,
793
+ inputs: [
794
+ {
795
+ name: "requestId",
796
+ displayName: "Request ID",
797
+ type: "int"
798
+ }
799
+ ],
800
+ outputs: [
801
+ {
802
+ name: "state",
803
+ displayName: "State",
804
+ type: "string"
805
+ },
806
+ {
807
+ name: "progress",
808
+ displayName: "Progress (0-1)",
809
+ type: "float"
810
+ },
811
+ {
812
+ name: "nodesSearched",
813
+ displayName: "Nodes Searched",
814
+ type: "int"
815
+ },
816
+ {
817
+ name: "isComplete",
818
+ displayName: "Is Complete",
819
+ type: "bool"
820
+ },
821
+ {
822
+ name: "isInProgress",
823
+ displayName: "Is In Progress",
824
+ type: "bool"
825
+ }
826
+ ],
827
+ color: "#4caf50"
828
+ };
829
+ var _GetPathProgressExecutor = class _GetPathProgressExecutor {
830
+ execute(node, context) {
831
+ const ctx = context;
832
+ const requestId = ctx.evaluateInput(node.id, "requestId", -1);
833
+ const progress = ctx.getPathProgress(requestId);
834
+ if (!progress) {
835
+ return {
836
+ outputs: {
837
+ state: PathfindingState.Idle,
838
+ progress: 0,
839
+ nodesSearched: 0,
840
+ isComplete: false,
841
+ isInProgress: false
842
+ }
843
+ };
844
+ }
845
+ return {
846
+ outputs: {
847
+ state: progress.state,
848
+ progress: progress.estimatedProgress,
849
+ nodesSearched: progress.nodesSearched,
850
+ isComplete: progress.state === PathfindingState.Completed,
851
+ isInProgress: progress.state === PathfindingState.InProgress
852
+ }
853
+ };
854
+ }
855
+ };
856
+ __name(_GetPathProgressExecutor, "GetPathProgressExecutor");
857
+ var GetPathProgressExecutor = _GetPathProgressExecutor;
858
+ var GetPathResultTemplate = {
859
+ type: "GetPathResult",
860
+ title: "Get Path Result",
861
+ category: "custom",
862
+ description: "Get completed path result / \u83B7\u53D6\u5DF2\u5B8C\u6210\u7684\u5BFB\u8DEF\u7ED3\u679C",
863
+ keywords: [
864
+ "path",
865
+ "result",
866
+ "get",
867
+ "output"
868
+ ],
869
+ menuPath: [
870
+ "Pathfinding",
871
+ "Incremental",
872
+ "Get Path Result"
873
+ ],
874
+ isPure: true,
875
+ inputs: [
876
+ {
877
+ name: "requestId",
878
+ displayName: "Request ID",
879
+ type: "int"
880
+ }
881
+ ],
882
+ outputs: [
883
+ {
884
+ name: "found",
885
+ displayName: "Found",
886
+ type: "bool"
887
+ },
888
+ {
889
+ name: "path",
890
+ displayName: "Path",
891
+ type: "array"
892
+ },
893
+ {
894
+ name: "cost",
895
+ displayName: "Cost",
896
+ type: "float"
897
+ },
898
+ {
899
+ name: "framesUsed",
900
+ displayName: "Frames Used",
901
+ type: "int"
902
+ }
903
+ ],
904
+ color: "#4caf50"
905
+ };
906
+ var _GetPathResultExecutor = class _GetPathResultExecutor {
907
+ execute(node, context) {
908
+ const ctx = context;
909
+ const requestId = ctx.evaluateInput(node.id, "requestId", -1);
910
+ const result = ctx.getPathResult(requestId);
911
+ if (!result) {
912
+ return {
913
+ outputs: {
914
+ found: false,
915
+ path: [],
916
+ cost: 0,
917
+ framesUsed: 0
918
+ }
919
+ };
920
+ }
921
+ return {
922
+ outputs: {
923
+ found: result.found,
924
+ path: result.path,
925
+ cost: result.cost,
926
+ framesUsed: result.framesUsed
927
+ }
928
+ };
929
+ }
930
+ };
931
+ __name(_GetPathResultExecutor, "GetPathResultExecutor");
932
+ var GetPathResultExecutor = _GetPathResultExecutor;
933
+ var CancelPathTemplate = {
934
+ type: "CancelPath",
935
+ title: "Cancel Path",
936
+ category: "custom",
937
+ description: "Cancel ongoing pathfinding / \u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u5BFB\u8DEF",
938
+ keywords: [
939
+ "path",
940
+ "cancel",
941
+ "stop",
942
+ "abort"
943
+ ],
944
+ menuPath: [
945
+ "Pathfinding",
946
+ "Incremental",
947
+ "Cancel Path"
948
+ ],
949
+ inputs: [
950
+ {
951
+ name: "exec",
952
+ displayName: "",
953
+ type: "exec"
954
+ },
955
+ {
956
+ name: "requestId",
957
+ displayName: "Request ID",
958
+ type: "int"
959
+ }
960
+ ],
961
+ outputs: [
962
+ {
963
+ name: "exec",
964
+ displayName: "",
965
+ type: "exec"
966
+ }
967
+ ],
968
+ color: "#f44336"
969
+ };
970
+ var _CancelPathExecutor = class _CancelPathExecutor {
971
+ execute(node, context) {
972
+ const ctx = context;
973
+ const requestId = ctx.evaluateInput(node.id, "requestId", -1);
974
+ ctx.cancelPath(requestId);
975
+ return {
976
+ nextExec: "exec"
977
+ };
978
+ }
979
+ };
980
+ __name(_CancelPathExecutor, "CancelPathExecutor");
981
+ var CancelPathExecutor = _CancelPathExecutor;
982
+ var SetObstacleTemplate = {
983
+ type: "SetObstacle",
984
+ title: "Set Obstacle",
985
+ category: "custom",
986
+ description: "Set or remove obstacle / \u8BBE\u7F6E\u6216\u79FB\u9664\u969C\u788D\u7269",
987
+ keywords: [
988
+ "obstacle",
989
+ "block",
990
+ "walkable",
991
+ "terrain"
992
+ ],
993
+ menuPath: [
994
+ "Pathfinding",
995
+ "Incremental",
996
+ "Set Obstacle"
997
+ ],
998
+ inputs: [
999
+ {
1000
+ name: "exec",
1001
+ displayName: "",
1002
+ type: "exec"
1003
+ },
1004
+ {
1005
+ name: "x",
1006
+ displayName: "X",
1007
+ type: "int"
1008
+ },
1009
+ {
1010
+ name: "y",
1011
+ displayName: "Y",
1012
+ type: "int"
1013
+ },
1014
+ {
1015
+ name: "blocked",
1016
+ displayName: "Blocked",
1017
+ type: "bool"
1018
+ }
1019
+ ],
1020
+ outputs: [
1021
+ {
1022
+ name: "exec",
1023
+ displayName: "",
1024
+ type: "exec"
1025
+ }
1026
+ ],
1027
+ color: "#ff9800"
1028
+ };
1029
+ var _SetObstacleExecutor = class _SetObstacleExecutor {
1030
+ execute(node, context) {
1031
+ const ctx = context;
1032
+ const x = ctx.evaluateInput(node.id, "x", 0);
1033
+ const y = ctx.evaluateInput(node.id, "y", 0);
1034
+ const blocked = ctx.evaluateInput(node.id, "blocked", true);
1035
+ ctx.setObstacle(x, y, blocked);
1036
+ return {
1037
+ nextExec: "exec"
1038
+ };
1039
+ }
1040
+ };
1041
+ __name(_SetObstacleExecutor, "SetObstacleExecutor");
1042
+ var SetObstacleExecutor = _SetObstacleExecutor;
1043
+ var IsPathCompleteTemplate = {
1044
+ type: "IsPathComplete",
1045
+ title: "Is Path Complete",
1046
+ category: "custom",
1047
+ description: "Check if pathfinding is complete / \u68C0\u67E5\u5BFB\u8DEF\u662F\u5426\u5B8C\u6210",
1048
+ keywords: [
1049
+ "path",
1050
+ "complete",
1051
+ "done",
1052
+ "finished"
1053
+ ],
1054
+ menuPath: [
1055
+ "Pathfinding",
1056
+ "Incremental",
1057
+ "Is Path Complete"
1058
+ ],
1059
+ isPure: true,
1060
+ inputs: [
1061
+ {
1062
+ name: "requestId",
1063
+ displayName: "Request ID",
1064
+ type: "int"
1065
+ }
1066
+ ],
1067
+ outputs: [
1068
+ {
1069
+ name: "isComplete",
1070
+ displayName: "Is Complete",
1071
+ type: "bool"
1072
+ },
1073
+ {
1074
+ name: "found",
1075
+ displayName: "Found",
1076
+ type: "bool"
1077
+ }
1078
+ ],
1079
+ color: "#4caf50"
1080
+ };
1081
+ var _IsPathCompleteExecutor = class _IsPathCompleteExecutor {
1082
+ execute(node, context) {
1083
+ const ctx = context;
1084
+ const requestId = ctx.evaluateInput(node.id, "requestId", -1);
1085
+ const progress = ctx.getPathProgress(requestId);
1086
+ const isComplete = progress?.state === PathfindingState.Completed || progress?.state === PathfindingState.Failed;
1087
+ const result = ctx.getPathResult(requestId);
1088
+ const found = result?.found ?? false;
1089
+ return {
1090
+ outputs: {
1091
+ isComplete,
1092
+ found
1093
+ }
1094
+ };
1095
+ }
1096
+ };
1097
+ __name(_IsPathCompleteExecutor, "IsPathCompleteExecutor");
1098
+ var IsPathCompleteExecutor = _IsPathCompleteExecutor;
1099
+ var IncrementalPathfindingNodeDefinitions = {
1100
+ templates: [
1101
+ RequestPathAsyncTemplate,
1102
+ StepPathTemplate,
1103
+ GetPathProgressTemplate,
1104
+ GetPathResultTemplate,
1105
+ CancelPathTemplate,
1106
+ SetObstacleTemplate,
1107
+ IsPathCompleteTemplate
1108
+ ],
1109
+ executors: /* @__PURE__ */ new Map([
1110
+ [
1111
+ "RequestPathAsync",
1112
+ new RequestPathAsyncExecutor()
1113
+ ],
1114
+ [
1115
+ "StepPath",
1116
+ new StepPathExecutor()
1117
+ ],
1118
+ [
1119
+ "GetPathProgress",
1120
+ new GetPathProgressExecutor()
1121
+ ],
1122
+ [
1123
+ "GetPathResult",
1124
+ new GetPathResultExecutor()
1125
+ ],
1126
+ [
1127
+ "CancelPath",
1128
+ new CancelPathExecutor()
1129
+ ],
1130
+ [
1131
+ "SetObstacle",
1132
+ new SetObstacleExecutor()
1133
+ ],
1134
+ [
1135
+ "IsPathComplete",
1136
+ new IsPathCompleteExecutor()
1137
+ ]
1138
+ ])
1139
+ };
1140
+ export {
1141
+ CancelPathExecutor,
1142
+ CancelPathTemplate,
1143
+ FindPathExecutor,
1144
+ FindPathSmoothExecutor,
1145
+ FindPathSmoothTemplate,
1146
+ FindPathTemplate,
1147
+ GetPathDistanceExecutor,
1148
+ GetPathDistanceTemplate,
1149
+ GetPathLengthExecutor,
1150
+ GetPathLengthTemplate,
1151
+ GetPathPointExecutor,
1152
+ GetPathPointTemplate,
1153
+ GetPathProgressExecutor,
1154
+ GetPathProgressTemplate,
1155
+ GetPathResultExecutor,
1156
+ GetPathResultTemplate,
1157
+ HasLineOfSightExecutor,
1158
+ HasLineOfSightTemplate,
1159
+ IncrementalPathfindingNodeDefinitions,
1160
+ IsPathCompleteExecutor,
1161
+ IsPathCompleteTemplate,
1162
+ IsWalkableExecutor,
1163
+ IsWalkableTemplate,
1164
+ MoveAlongPathExecutor,
1165
+ MoveAlongPathTemplate,
1166
+ PathfindingNodeDefinitions,
1167
+ RequestPathAsyncExecutor,
1168
+ RequestPathAsyncTemplate,
1169
+ SetObstacleExecutor,
1170
+ SetObstacleTemplate,
1171
+ StepPathExecutor,
1172
+ StepPathTemplate
1173
+ };
1174
+ //# sourceMappingURL=nodes.js.map