@nice2dev/game-engine 1.3.15 → 1.3.17

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.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1181 +1,1097 @@
1
- 'use strict';
2
-
3
- /**
4
- * @file BehaviorTree.ts
5
- * @description Behavior Tree System with Graphical Editor Support
6
- * PRO-1.4: Professional Editor Features
7
- *
8
- * Features:
9
- * - Full behavior tree implementation
10
- * - Composite nodes (Selector, Sequence, Parallel)
11
- * - Decorator nodes (Inverter, Repeater, Succeeder, etc.)
12
- * - Leaf nodes (Actions, Conditions)
13
- * - Real-time preview and debugging
14
- * - Blackboard system for shared data
15
- * - Subtree support
16
- * - Serialization support
17
- */
18
- /** Blackboard for sharing data between nodes */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
19
3
  class BTBlackboard {
20
- constructor() {
21
- this.data = new Map();
22
- this.types = new Map();
23
- this.listeners = new Map();
24
- }
25
- /** Set a value in the blackboard */
26
- set(key, value) {
27
- const name = typeof key === 'string' ? key : key.name;
28
- const oldValue = this.data.get(name);
29
- this.data.set(name, value);
30
- if (typeof key !== 'string') {
31
- this.types.set(name, key.type);
32
- }
33
- // Notify listeners
34
- if (oldValue !== value) {
35
- const callbacks = this.listeners.get(name);
36
- if (callbacks) {
37
- for (const cb of callbacks) {
38
- cb(value);
39
- }
40
- }
41
- }
42
- }
43
- /** Get a value from the blackboard */
44
- get(key) {
45
- const name = typeof key === 'string' ? key : key.name;
46
- const value = this.data.get(name);
47
- if (value === undefined && typeof key !== 'string' && key.defaultValue !== undefined) {
48
- return key.defaultValue;
49
- }
50
- return value;
51
- }
52
- /** Check if key exists */
53
- has(key) {
54
- const name = typeof key === 'string' ? key : key.name;
55
- return this.data.has(name);
56
- }
57
- /** Remove a key */
58
- delete(key) {
59
- const name = typeof key === 'string' ? key : key.name;
60
- this.data.delete(name);
61
- this.types.delete(name);
62
- }
63
- /** Clear all data */
64
- clear() {
65
- this.data.clear();
66
- }
67
- /** Subscribe to key changes */
68
- subscribe(key, callback) {
69
- const name = typeof key === 'string' ? key : key.name;
70
- let callbacks = this.listeners.get(name);
71
- if (!callbacks) {
72
- callbacks = [];
73
- this.listeners.set(name, callbacks);
74
- }
75
- callbacks.push(callback);
76
- // Return unsubscribe function
77
- return () => {
78
- const idx = callbacks.indexOf(callback);
79
- if (idx >= 0) {
80
- callbacks.splice(idx, 1);
81
- }
82
- };
83
- }
84
- /** Get all keys */
85
- keys() {
86
- return Array.from(this.data.keys());
87
- }
88
- /** Clone the blackboard */
89
- clone() {
90
- const bb = new BTBlackboard();
91
- for (const [key, value] of this.data) {
92
- bb.data.set(key, value);
4
+ constructor() {
5
+ this.data = /* @__PURE__ */ new Map();
6
+ this.types = /* @__PURE__ */ new Map();
7
+ this.listeners = /* @__PURE__ */ new Map();
8
+ }
9
+ /** Set a value in the blackboard */
10
+ set(key, value) {
11
+ const name = typeof key === "string" ? key : key.name;
12
+ const oldValue = this.data.get(name);
13
+ this.data.set(name, value);
14
+ if (typeof key !== "string") {
15
+ this.types.set(name, key.type);
16
+ }
17
+ if (oldValue !== value) {
18
+ const callbacks = this.listeners.get(name);
19
+ if (callbacks) {
20
+ for (const cb of callbacks) {
21
+ cb(value);
93
22
  }
94
- for (const [key, type] of this.types) {
95
- bb.types.set(key, type);
96
- }
97
- return bb;
98
- }
99
- /** Export to JSON */
100
- toJSON() {
101
- const result = {};
102
- for (const [key, value] of this.data) {
103
- result[key] = value;
104
- }
105
- return result;
106
- }
107
- /** Import from JSON */
108
- fromJSON(data) {
109
- for (const [key, value] of Object.entries(data)) {
110
- this.data.set(key, value);
111
- }
112
- }
23
+ }
24
+ }
25
+ }
26
+ /** Get a value from the blackboard */
27
+ get(key) {
28
+ const name = typeof key === "string" ? key : key.name;
29
+ const value = this.data.get(name);
30
+ if (value === void 0 && typeof key !== "string" && key.defaultValue !== void 0) {
31
+ return key.defaultValue;
32
+ }
33
+ return value;
34
+ }
35
+ /** Check if key exists */
36
+ has(key) {
37
+ const name = typeof key === "string" ? key : key.name;
38
+ return this.data.has(name);
39
+ }
40
+ /** Remove a key */
41
+ delete(key) {
42
+ const name = typeof key === "string" ? key : key.name;
43
+ this.data.delete(name);
44
+ this.types.delete(name);
45
+ }
46
+ /** Clear all data */
47
+ clear() {
48
+ this.data.clear();
49
+ }
50
+ /** Subscribe to key changes */
51
+ subscribe(key, callback) {
52
+ const name = typeof key === "string" ? key : key.name;
53
+ let callbacks = this.listeners.get(name);
54
+ if (!callbacks) {
55
+ callbacks = [];
56
+ this.listeners.set(name, callbacks);
57
+ }
58
+ callbacks.push(callback);
59
+ return () => {
60
+ const idx = callbacks.indexOf(callback);
61
+ if (idx >= 0) {
62
+ callbacks.splice(idx, 1);
63
+ }
64
+ };
65
+ }
66
+ /** Get all keys */
67
+ keys() {
68
+ return Array.from(this.data.keys());
69
+ }
70
+ /** Clone the blackboard */
71
+ clone() {
72
+ const bb = new BTBlackboard();
73
+ for (const [key, value] of this.data) {
74
+ bb.data.set(key, value);
75
+ }
76
+ for (const [key, type] of this.types) {
77
+ bb.types.set(key, type);
78
+ }
79
+ return bb;
80
+ }
81
+ /** Export to JSON */
82
+ toJSON() {
83
+ const result = {};
84
+ for (const [key, value] of this.data) {
85
+ result[key] = value;
86
+ }
87
+ return result;
88
+ }
89
+ /** Import from JSON */
90
+ fromJSON(data) {
91
+ for (const [key, value] of Object.entries(data)) {
92
+ this.data.set(key, value);
93
+ }
94
+ }
113
95
  }
114
- /** Base class for all behavior tree nodes */
115
96
  class BTNode {
116
- constructor(type, category, name) {
117
- /** Position in editor */
118
- this.position = { x: 0, y: 0 };
119
- /** Custom properties */
120
- this.properties = {};
121
- /** Current execution status (for debugging) */
122
- this.lastStatus = 'inactive';
123
- /** Last execution time (for profiling) */
124
- this.lastExecutionTime = 0;
125
- this.id = `bt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
126
- this.type = type;
127
- this.category = category;
128
- this.name = name;
129
- }
130
- /** Initialize the node */
131
- initialize(_context) { }
132
- /** Reset the node state */
133
- reset() {
134
- this.lastStatus = 'inactive';
135
- }
136
- /** Called when execution is aborted */
137
- abort() {
138
- this.lastStatus = 'aborted';
139
- }
140
- /** Serialize to JSON */
141
- toJSON() {
142
- return {
143
- id: this.id,
144
- type: this.type,
145
- category: this.category,
146
- name: this.name,
147
- position: this.position,
148
- properties: this.properties,
149
- comment: this.comment,
150
- };
151
- }
97
+ constructor(type, category, name) {
98
+ this.position = { x: 0, y: 0 };
99
+ this.properties = {};
100
+ this.lastStatus = "inactive";
101
+ this.lastExecutionTime = 0;
102
+ this.id = `bt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
103
+ this.type = type;
104
+ this.category = category;
105
+ this.name = name;
106
+ }
107
+ /** Initialize the node */
108
+ initialize(_context) {
109
+ }
110
+ /** Reset the node state */
111
+ reset() {
112
+ this.lastStatus = "inactive";
113
+ }
114
+ /** Called when execution is aborted */
115
+ abort() {
116
+ this.lastStatus = "aborted";
117
+ }
118
+ /** Serialize to JSON */
119
+ toJSON() {
120
+ return {
121
+ id: this.id,
122
+ type: this.type,
123
+ category: this.category,
124
+ name: this.name,
125
+ position: this.position,
126
+ properties: this.properties,
127
+ comment: this.comment
128
+ };
129
+ }
152
130
  }
153
- // ============================================================
154
- // Composite Nodes
155
- // ============================================================
156
- /** Base class for composite nodes (have children) */
157
131
  class BTComposite extends BTNode {
158
- constructor(type, name) {
159
- super(type, 'composite', name);
160
- this.children = [];
161
- this.currentChild = 0;
162
- }
163
- addChild(child) {
164
- this.children.push(child);
165
- }
166
- removeChild(child) {
167
- const idx = this.children.indexOf(child);
168
- if (idx >= 0) {
169
- this.children.splice(idx, 1);
170
- }
171
- }
172
- reset() {
173
- super.reset();
174
- this.currentChild = 0;
175
- for (const child of this.children) {
176
- child.reset();
177
- }
178
- }
179
- abort() {
180
- super.abort();
181
- // Abort currently running child
182
- if (this.currentChild < this.children.length) {
183
- this.children[this.currentChild].abort();
184
- }
185
- }
186
- toJSON() {
187
- return {
188
- ...super.toJSON(),
189
- children: this.children.map((c) => c.toJSON()),
190
- };
191
- }
132
+ constructor(type, name) {
133
+ super(type, "composite", name);
134
+ this.children = [];
135
+ this.currentChild = 0;
136
+ }
137
+ addChild(child) {
138
+ this.children.push(child);
139
+ }
140
+ removeChild(child) {
141
+ const idx = this.children.indexOf(child);
142
+ if (idx >= 0) {
143
+ this.children.splice(idx, 1);
144
+ }
145
+ }
146
+ reset() {
147
+ super.reset();
148
+ this.currentChild = 0;
149
+ for (const child of this.children) {
150
+ child.reset();
151
+ }
152
+ }
153
+ abort() {
154
+ super.abort();
155
+ if (this.currentChild < this.children.length) {
156
+ this.children[this.currentChild].abort();
157
+ }
158
+ }
159
+ toJSON() {
160
+ return {
161
+ ...super.toJSON(),
162
+ children: this.children.map((c) => c.toJSON())
163
+ };
164
+ }
192
165
  }
193
- /** Sequence: Runs children in order until one fails */
194
166
  class BTSequence extends BTComposite {
195
- constructor(name = 'Sequence') {
196
- super('sequence', name);
197
- }
198
- tick(context) {
199
- while (this.currentChild < this.children.length) {
200
- const child = this.children[this.currentChild];
201
- const status = child.tick(context);
202
- child.lastStatus = status;
203
- if (status === 'running') {
204
- this.lastStatus = 'running';
205
- return 'running';
206
- }
207
- if (status === 'failure') {
208
- this.currentChild = 0;
209
- this.lastStatus = 'failure';
210
- return 'failure';
211
- }
212
- this.currentChild++;
213
- }
167
+ constructor(name = "Sequence") {
168
+ super("sequence", name);
169
+ }
170
+ tick(context) {
171
+ while (this.currentChild < this.children.length) {
172
+ const child = this.children[this.currentChild];
173
+ const status = child.tick(context);
174
+ child.lastStatus = status;
175
+ if (status === "running") {
176
+ this.lastStatus = "running";
177
+ return "running";
178
+ }
179
+ if (status === "failure") {
214
180
  this.currentChild = 0;
215
- this.lastStatus = 'success';
216
- return 'success';
217
- }
218
- clone() {
219
- const node = new BTSequence(this.name);
220
- node.properties = { ...this.properties };
221
- node.position = { ...this.position };
222
- node.children = this.children.map((c) => c.clone());
223
- return node;
224
- }
181
+ this.lastStatus = "failure";
182
+ return "failure";
183
+ }
184
+ this.currentChild++;
185
+ }
186
+ this.currentChild = 0;
187
+ this.lastStatus = "success";
188
+ return "success";
189
+ }
190
+ clone() {
191
+ const node = new BTSequence(this.name);
192
+ node.properties = { ...this.properties };
193
+ node.position = { ...this.position };
194
+ node.children = this.children.map((c) => c.clone());
195
+ return node;
196
+ }
225
197
  }
226
- /** Selector: Runs children until one succeeds */
227
198
  class BTSelector extends BTComposite {
228
- constructor(name = 'Selector') {
229
- super('selector', name);
230
- }
231
- tick(context) {
232
- while (this.currentChild < this.children.length) {
233
- const child = this.children[this.currentChild];
234
- const status = child.tick(context);
235
- child.lastStatus = status;
236
- if (status === 'running') {
237
- this.lastStatus = 'running';
238
- return 'running';
239
- }
240
- if (status === 'success') {
241
- this.currentChild = 0;
242
- this.lastStatus = 'success';
243
- return 'success';
244
- }
245
- this.currentChild++;
246
- }
199
+ constructor(name = "Selector") {
200
+ super("selector", name);
201
+ }
202
+ tick(context) {
203
+ while (this.currentChild < this.children.length) {
204
+ const child = this.children[this.currentChild];
205
+ const status = child.tick(context);
206
+ child.lastStatus = status;
207
+ if (status === "running") {
208
+ this.lastStatus = "running";
209
+ return "running";
210
+ }
211
+ if (status === "success") {
247
212
  this.currentChild = 0;
248
- this.lastStatus = 'failure';
249
- return 'failure';
250
- }
251
- clone() {
252
- const node = new BTSelector(this.name);
253
- node.properties = { ...this.properties };
254
- node.position = { ...this.position };
255
- node.children = this.children.map((c) => c.clone());
256
- return node;
257
- }
213
+ this.lastStatus = "success";
214
+ return "success";
215
+ }
216
+ this.currentChild++;
217
+ }
218
+ this.currentChild = 0;
219
+ this.lastStatus = "failure";
220
+ return "failure";
221
+ }
222
+ clone() {
223
+ const node = new BTSelector(this.name);
224
+ node.properties = { ...this.properties };
225
+ node.position = { ...this.position };
226
+ node.children = this.children.map((c) => c.clone());
227
+ return node;
228
+ }
258
229
  }
259
- /** Parallel: Runs all children simultaneously */
260
230
  class BTParallel extends BTComposite {
261
- constructor(name = 'Parallel') {
262
- super('parallel', name);
263
- /** Policy for determining success */
264
- this.successPolicy = 'all';
265
- /** Policy for determining failure */
266
- this.failurePolicy = 'one';
267
- this.childStatuses = [];
268
- }
269
- initialize(_context) {
270
- this.childStatuses = new Array(this.children.length).fill('running');
271
- }
272
- tick(context) {
273
- let successCount = 0;
274
- let failureCount = 0;
275
- let runningCount = 0;
276
- for (let i = 0; i < this.children.length; i++) {
277
- // Skip already completed children
278
- if (this.childStatuses[i] !== 'running') {
279
- if (this.childStatuses[i] === 'success') {
280
- successCount++;
281
- }
282
- else if (this.childStatuses[i] === 'failure') {
283
- failureCount++;
284
- }
285
- continue;
286
- }
287
- const child = this.children[i];
288
- const status = child.tick(context);
289
- child.lastStatus = status;
290
- this.childStatuses[i] = status;
291
- if (status === 'success') {
292
- successCount++;
293
- }
294
- else if (status === 'failure') {
295
- failureCount++;
296
- }
297
- else {
298
- runningCount++;
299
- }
231
+ constructor(name = "Parallel") {
232
+ super("parallel", name);
233
+ this.successPolicy = "all";
234
+ this.failurePolicy = "one";
235
+ this.childStatuses = [];
236
+ }
237
+ initialize(_context) {
238
+ this.childStatuses = new Array(this.children.length).fill("running");
239
+ }
240
+ tick(context) {
241
+ let successCount = 0;
242
+ let failureCount = 0;
243
+ let runningCount = 0;
244
+ for (let i = 0; i < this.children.length; i++) {
245
+ if (this.childStatuses[i] !== "running") {
246
+ if (this.childStatuses[i] === "success") {
247
+ successCount++;
248
+ } else if (this.childStatuses[i] === "failure") {
249
+ failureCount++;
300
250
  }
301
- // Check failure policy
302
- if (this.failurePolicy === 'one' && failureCount > 0) {
303
- this.reset();
304
- this.lastStatus = 'failure';
305
- return 'failure';
306
- }
307
- if (this.failurePolicy === 'all' && failureCount === this.children.length) {
308
- this.reset();
309
- this.lastStatus = 'failure';
310
- return 'failure';
311
- }
312
- // Check success policy
313
- if (this.successPolicy === 'one' && successCount > 0) {
314
- this.reset();
315
- this.lastStatus = 'success';
316
- return 'success';
317
- }
318
- if (this.successPolicy === 'all' && successCount === this.children.length) {
319
- this.reset();
320
- this.lastStatus = 'success';
321
- return 'success';
322
- }
323
- // Still running
324
- if (runningCount > 0) {
325
- this.lastStatus = 'running';
326
- return 'running';
327
- }
328
- // Mixed results, depends on policy
329
- this.reset();
330
- this.lastStatus = 'failure';
331
- return 'failure';
332
- }
333
- reset() {
334
- super.reset();
335
- this.childStatuses = [];
336
- }
337
- clone() {
338
- const node = new BTParallel(this.name);
339
- node.properties = { ...this.properties };
340
- node.position = { ...this.position };
341
- node.successPolicy = this.successPolicy;
342
- node.failurePolicy = this.failurePolicy;
343
- node.children = this.children.map((c) => c.clone());
344
- return node;
345
- }
251
+ continue;
252
+ }
253
+ const child = this.children[i];
254
+ const status = child.tick(context);
255
+ child.lastStatus = status;
256
+ this.childStatuses[i] = status;
257
+ if (status === "success") {
258
+ successCount++;
259
+ } else if (status === "failure") {
260
+ failureCount++;
261
+ } else {
262
+ runningCount++;
263
+ }
264
+ }
265
+ if (this.failurePolicy === "one" && failureCount > 0) {
266
+ this.reset();
267
+ this.lastStatus = "failure";
268
+ return "failure";
269
+ }
270
+ if (this.failurePolicy === "all" && failureCount === this.children.length) {
271
+ this.reset();
272
+ this.lastStatus = "failure";
273
+ return "failure";
274
+ }
275
+ if (this.successPolicy === "one" && successCount > 0) {
276
+ this.reset();
277
+ this.lastStatus = "success";
278
+ return "success";
279
+ }
280
+ if (this.successPolicy === "all" && successCount === this.children.length) {
281
+ this.reset();
282
+ this.lastStatus = "success";
283
+ return "success";
284
+ }
285
+ if (runningCount > 0) {
286
+ this.lastStatus = "running";
287
+ return "running";
288
+ }
289
+ this.reset();
290
+ this.lastStatus = "failure";
291
+ return "failure";
292
+ }
293
+ reset() {
294
+ super.reset();
295
+ this.childStatuses = [];
296
+ }
297
+ clone() {
298
+ const node = new BTParallel(this.name);
299
+ node.properties = { ...this.properties };
300
+ node.position = { ...this.position };
301
+ node.successPolicy = this.successPolicy;
302
+ node.failurePolicy = this.failurePolicy;
303
+ node.children = this.children.map((c) => c.clone());
304
+ return node;
305
+ }
346
306
  }
347
- /** Random Selector: Selects children in random order */
348
307
  class BTRandomSelector extends BTComposite {
349
- constructor(name = 'Random Selector') {
350
- super('randomSelector', name);
351
- this.shuffledOrder = [];
352
- }
353
- initialize(_context) {
354
- this.shuffle();
355
- }
356
- shuffle() {
357
- this.shuffledOrder = this.children.map((_, i) => i);
358
- for (let i = this.shuffledOrder.length - 1; i > 0; i--) {
359
- const j = Math.floor(Math.random() * (i + 1));
360
- [this.shuffledOrder[i], this.shuffledOrder[j]] = [
361
- this.shuffledOrder[j],
362
- this.shuffledOrder[i],
363
- ];
364
- }
365
- }
366
- tick(context) {
367
- while (this.currentChild < this.shuffledOrder.length) {
368
- const childIdx = this.shuffledOrder[this.currentChild];
369
- const child = this.children[childIdx];
370
- const status = child.tick(context);
371
- child.lastStatus = status;
372
- if (status === 'running') {
373
- this.lastStatus = 'running';
374
- return 'running';
375
- }
376
- if (status === 'success') {
377
- this.currentChild = 0;
378
- this.shuffle();
379
- this.lastStatus = 'success';
380
- return 'success';
381
- }
382
- this.currentChild++;
383
- }
308
+ constructor(name = "Random Selector") {
309
+ super("randomSelector", name);
310
+ this.shuffledOrder = [];
311
+ }
312
+ initialize(_context) {
313
+ this.shuffle();
314
+ }
315
+ shuffle() {
316
+ this.shuffledOrder = this.children.map((_, i) => i);
317
+ for (let i = this.shuffledOrder.length - 1; i > 0; i--) {
318
+ const j = Math.floor(Math.random() * (i + 1));
319
+ [this.shuffledOrder[i], this.shuffledOrder[j]] = [
320
+ this.shuffledOrder[j],
321
+ this.shuffledOrder[i]
322
+ ];
323
+ }
324
+ }
325
+ tick(context) {
326
+ while (this.currentChild < this.shuffledOrder.length) {
327
+ const childIdx = this.shuffledOrder[this.currentChild];
328
+ const child = this.children[childIdx];
329
+ const status = child.tick(context);
330
+ child.lastStatus = status;
331
+ if (status === "running") {
332
+ this.lastStatus = "running";
333
+ return "running";
334
+ }
335
+ if (status === "success") {
384
336
  this.currentChild = 0;
385
337
  this.shuffle();
386
- this.lastStatus = 'failure';
387
- return 'failure';
388
- }
389
- clone() {
390
- const node = new BTRandomSelector(this.name);
391
- node.properties = { ...this.properties };
392
- node.position = { ...this.position };
393
- node.children = this.children.map((c) => c.clone());
394
- return node;
395
- }
338
+ this.lastStatus = "success";
339
+ return "success";
340
+ }
341
+ this.currentChild++;
342
+ }
343
+ this.currentChild = 0;
344
+ this.shuffle();
345
+ this.lastStatus = "failure";
346
+ return "failure";
347
+ }
348
+ clone() {
349
+ const node = new BTRandomSelector(this.name);
350
+ node.properties = { ...this.properties };
351
+ node.position = { ...this.position };
352
+ node.children = this.children.map((c) => c.clone());
353
+ return node;
354
+ }
396
355
  }
397
- /** Random Sequence: Runs children in random order */
398
356
  class BTRandomSequence extends BTComposite {
399
- constructor(name = 'Random Sequence') {
400
- super('randomSequence', name);
401
- this.shuffledOrder = [];
402
- }
403
- initialize(_context) {
404
- this.shuffle();
405
- }
406
- shuffle() {
407
- this.shuffledOrder = this.children.map((_, i) => i);
408
- for (let i = this.shuffledOrder.length - 1; i > 0; i--) {
409
- const j = Math.floor(Math.random() * (i + 1));
410
- [this.shuffledOrder[i], this.shuffledOrder[j]] = [
411
- this.shuffledOrder[j],
412
- this.shuffledOrder[i],
413
- ];
414
- }
415
- }
416
- tick(context) {
417
- while (this.currentChild < this.shuffledOrder.length) {
418
- const childIdx = this.shuffledOrder[this.currentChild];
419
- const child = this.children[childIdx];
420
- const status = child.tick(context);
421
- child.lastStatus = status;
422
- if (status === 'running') {
423
- this.lastStatus = 'running';
424
- return 'running';
425
- }
426
- if (status === 'failure') {
427
- this.currentChild = 0;
428
- this.shuffle();
429
- this.lastStatus = 'failure';
430
- return 'failure';
431
- }
432
- this.currentChild++;
433
- }
357
+ constructor(name = "Random Sequence") {
358
+ super("randomSequence", name);
359
+ this.shuffledOrder = [];
360
+ }
361
+ initialize(_context) {
362
+ this.shuffle();
363
+ }
364
+ shuffle() {
365
+ this.shuffledOrder = this.children.map((_, i) => i);
366
+ for (let i = this.shuffledOrder.length - 1; i > 0; i--) {
367
+ const j = Math.floor(Math.random() * (i + 1));
368
+ [this.shuffledOrder[i], this.shuffledOrder[j]] = [
369
+ this.shuffledOrder[j],
370
+ this.shuffledOrder[i]
371
+ ];
372
+ }
373
+ }
374
+ tick(context) {
375
+ while (this.currentChild < this.shuffledOrder.length) {
376
+ const childIdx = this.shuffledOrder[this.currentChild];
377
+ const child = this.children[childIdx];
378
+ const status = child.tick(context);
379
+ child.lastStatus = status;
380
+ if (status === "running") {
381
+ this.lastStatus = "running";
382
+ return "running";
383
+ }
384
+ if (status === "failure") {
434
385
  this.currentChild = 0;
435
386
  this.shuffle();
436
- this.lastStatus = 'success';
437
- return 'success';
438
- }
439
- clone() {
440
- const node = new BTRandomSequence(this.name);
441
- node.properties = { ...this.properties };
442
- node.position = { ...this.position };
443
- node.children = this.children.map((c) => c.clone());
444
- return node;
445
- }
387
+ this.lastStatus = "failure";
388
+ return "failure";
389
+ }
390
+ this.currentChild++;
391
+ }
392
+ this.currentChild = 0;
393
+ this.shuffle();
394
+ this.lastStatus = "success";
395
+ return "success";
396
+ }
397
+ clone() {
398
+ const node = new BTRandomSequence(this.name);
399
+ node.properties = { ...this.properties };
400
+ node.position = { ...this.position };
401
+ node.children = this.children.map((c) => c.clone());
402
+ return node;
403
+ }
446
404
  }
447
- // ============================================================
448
- // Decorator Nodes
449
- // ============================================================
450
- /** Base class for decorator nodes (single child) */
451
405
  class BTDecorator extends BTNode {
452
- constructor(type, name) {
453
- super(type, 'decorator', name);
454
- this.child = null;
455
- }
456
- setChild(child) {
457
- this.child = child;
458
- }
459
- reset() {
460
- super.reset();
461
- this.child?.reset();
462
- }
463
- abort() {
464
- super.abort();
465
- this.child?.abort();
466
- }
467
- toJSON() {
468
- return {
469
- ...super.toJSON(),
470
- children: this.child ? [this.child.toJSON()] : [],
471
- };
472
- }
406
+ constructor(type, name) {
407
+ super(type, "decorator", name);
408
+ this.child = null;
409
+ }
410
+ setChild(child) {
411
+ this.child = child;
412
+ }
413
+ reset() {
414
+ super.reset();
415
+ this.child?.reset();
416
+ }
417
+ abort() {
418
+ super.abort();
419
+ this.child?.abort();
420
+ }
421
+ toJSON() {
422
+ return {
423
+ ...super.toJSON(),
424
+ children: this.child ? [this.child.toJSON()] : []
425
+ };
426
+ }
473
427
  }
474
- /** Inverter: Inverts child's result */
475
428
  class BTInverter extends BTDecorator {
476
- constructor(name = 'Inverter') {
477
- super('inverter', name);
478
- }
479
- tick(context) {
480
- if (!this.child) {
481
- this.lastStatus = 'failure';
482
- return 'failure';
483
- }
484
- const status = this.child.tick(context);
485
- this.child.lastStatus = status;
486
- if (status === 'running') {
487
- this.lastStatus = 'running';
488
- return 'running';
489
- }
490
- const inverted = status === 'success' ? 'failure' : 'success';
491
- this.lastStatus = inverted;
492
- return inverted;
493
- }
494
- clone() {
495
- const node = new BTInverter(this.name);
496
- node.properties = { ...this.properties };
497
- node.position = { ...this.position };
498
- node.child = this.child?.clone() || null;
499
- return node;
500
- }
429
+ constructor(name = "Inverter") {
430
+ super("inverter", name);
431
+ }
432
+ tick(context) {
433
+ if (!this.child) {
434
+ this.lastStatus = "failure";
435
+ return "failure";
436
+ }
437
+ const status = this.child.tick(context);
438
+ this.child.lastStatus = status;
439
+ if (status === "running") {
440
+ this.lastStatus = "running";
441
+ return "running";
442
+ }
443
+ const inverted = status === "success" ? "failure" : "success";
444
+ this.lastStatus = inverted;
445
+ return inverted;
446
+ }
447
+ clone() {
448
+ const node = new BTInverter(this.name);
449
+ node.properties = { ...this.properties };
450
+ node.position = { ...this.position };
451
+ node.child = this.child?.clone() || null;
452
+ return node;
453
+ }
501
454
  }
502
- /** Succeeder: Always returns success */
503
455
  class BTSucceeder extends BTDecorator {
504
- constructor(name = 'Succeeder') {
505
- super('succeeder', name);
506
- }
507
- tick(context) {
508
- if (!this.child) {
509
- this.lastStatus = 'success';
510
- return 'success';
511
- }
512
- const status = this.child.tick(context);
513
- this.child.lastStatus = status;
514
- if (status === 'running') {
515
- this.lastStatus = 'running';
516
- return 'running';
517
- }
518
- this.lastStatus = 'success';
519
- return 'success';
520
- }
521
- clone() {
522
- const node = new BTSucceeder(this.name);
523
- node.properties = { ...this.properties };
524
- node.position = { ...this.position };
525
- node.child = this.child?.clone() || null;
526
- return node;
527
- }
456
+ constructor(name = "Succeeder") {
457
+ super("succeeder", name);
458
+ }
459
+ tick(context) {
460
+ if (!this.child) {
461
+ this.lastStatus = "success";
462
+ return "success";
463
+ }
464
+ const status = this.child.tick(context);
465
+ this.child.lastStatus = status;
466
+ if (status === "running") {
467
+ this.lastStatus = "running";
468
+ return "running";
469
+ }
470
+ this.lastStatus = "success";
471
+ return "success";
472
+ }
473
+ clone() {
474
+ const node = new BTSucceeder(this.name);
475
+ node.properties = { ...this.properties };
476
+ node.position = { ...this.position };
477
+ node.child = this.child?.clone() || null;
478
+ return node;
479
+ }
528
480
  }
529
- /** Failer: Always returns failure */
530
481
  class BTFailer extends BTDecorator {
531
- constructor(name = 'Failer') {
532
- super('failer', name);
533
- }
534
- tick(context) {
535
- if (!this.child) {
536
- this.lastStatus = 'failure';
537
- return 'failure';
538
- }
539
- const status = this.child.tick(context);
540
- this.child.lastStatus = status;
541
- if (status === 'running') {
542
- this.lastStatus = 'running';
543
- return 'running';
544
- }
545
- this.lastStatus = 'failure';
546
- return 'failure';
547
- }
548
- clone() {
549
- const node = new BTFailer(this.name);
550
- node.properties = { ...this.properties };
551
- node.position = { ...this.position };
552
- node.child = this.child?.clone() || null;
553
- return node;
554
- }
482
+ constructor(name = "Failer") {
483
+ super("failer", name);
484
+ }
485
+ tick(context) {
486
+ if (!this.child) {
487
+ this.lastStatus = "failure";
488
+ return "failure";
489
+ }
490
+ const status = this.child.tick(context);
491
+ this.child.lastStatus = status;
492
+ if (status === "running") {
493
+ this.lastStatus = "running";
494
+ return "running";
495
+ }
496
+ this.lastStatus = "failure";
497
+ return "failure";
498
+ }
499
+ clone() {
500
+ const node = new BTFailer(this.name);
501
+ node.properties = { ...this.properties };
502
+ node.position = { ...this.position };
503
+ node.child = this.child?.clone() || null;
504
+ return node;
505
+ }
555
506
  }
556
- /** Repeater: Repeats child N times */
557
507
  class BTRepeater extends BTDecorator {
558
- constructor(name = 'Repeater', times = -1) {
559
- super('repeater', name);
560
- this.times = -1; // -1 = infinite
561
- this.currentCount = 0;
562
- this.times = times;
563
- }
564
- tick(context) {
565
- if (!this.child) {
566
- this.lastStatus = 'failure';
567
- return 'failure';
568
- }
569
- while (this.times === -1 || this.currentCount < this.times) {
570
- const status = this.child.tick(context);
571
- this.child.lastStatus = status;
572
- if (status === 'running') {
573
- this.lastStatus = 'running';
574
- return 'running';
575
- }
576
- this.currentCount++;
577
- this.child.reset();
578
- }
579
- this.currentCount = 0;
580
- this.lastStatus = 'success';
581
- return 'success';
582
- }
583
- reset() {
584
- super.reset();
585
- this.currentCount = 0;
586
- }
587
- clone() {
588
- const node = new BTRepeater(this.name, this.times);
589
- node.properties = { ...this.properties };
590
- node.position = { ...this.position };
591
- node.child = this.child?.clone() || null;
592
- return node;
593
- }
508
+ constructor(name = "Repeater", times = -1) {
509
+ super("repeater", name);
510
+ this.times = -1;
511
+ this.currentCount = 0;
512
+ this.times = times;
513
+ }
514
+ tick(context) {
515
+ if (!this.child) {
516
+ this.lastStatus = "failure";
517
+ return "failure";
518
+ }
519
+ while (this.times === -1 || this.currentCount < this.times) {
520
+ const status = this.child.tick(context);
521
+ this.child.lastStatus = status;
522
+ if (status === "running") {
523
+ this.lastStatus = "running";
524
+ return "running";
525
+ }
526
+ this.currentCount++;
527
+ this.child.reset();
528
+ }
529
+ this.currentCount = 0;
530
+ this.lastStatus = "success";
531
+ return "success";
532
+ }
533
+ reset() {
534
+ super.reset();
535
+ this.currentCount = 0;
536
+ }
537
+ clone() {
538
+ const node = new BTRepeater(this.name, this.times);
539
+ node.properties = { ...this.properties };
540
+ node.position = { ...this.position };
541
+ node.child = this.child?.clone() || null;
542
+ return node;
543
+ }
594
544
  }
595
- /** RepeatUntilFail: Repeats until child fails */
596
545
  class BTRepeatUntilFail extends BTDecorator {
597
- constructor(name = 'Repeat Until Fail') {
598
- super('repeatUntilFail', name);
599
- }
600
- tick(context) {
601
- if (!this.child) {
602
- this.lastStatus = 'failure';
603
- return 'failure';
604
- }
605
- const status = this.child.tick(context);
606
- this.child.lastStatus = status;
607
- if (status === 'failure') {
608
- this.lastStatus = 'success';
609
- return 'success';
610
- }
611
- if (status === 'running') {
612
- this.lastStatus = 'running';
613
- return 'running';
614
- }
615
- // Success - reset and continue
616
- this.child.reset();
617
- this.lastStatus = 'running';
618
- return 'running';
619
- }
620
- clone() {
621
- const node = new BTRepeatUntilFail(this.name);
622
- node.properties = { ...this.properties };
623
- node.position = { ...this.position };
624
- node.child = this.child?.clone() || null;
625
- return node;
626
- }
546
+ constructor(name = "Repeat Until Fail") {
547
+ super("repeatUntilFail", name);
548
+ }
549
+ tick(context) {
550
+ if (!this.child) {
551
+ this.lastStatus = "failure";
552
+ return "failure";
553
+ }
554
+ const status = this.child.tick(context);
555
+ this.child.lastStatus = status;
556
+ if (status === "failure") {
557
+ this.lastStatus = "success";
558
+ return "success";
559
+ }
560
+ if (status === "running") {
561
+ this.lastStatus = "running";
562
+ return "running";
563
+ }
564
+ this.child.reset();
565
+ this.lastStatus = "running";
566
+ return "running";
567
+ }
568
+ clone() {
569
+ const node = new BTRepeatUntilFail(this.name);
570
+ node.properties = { ...this.properties };
571
+ node.position = { ...this.position };
572
+ node.child = this.child?.clone() || null;
573
+ return node;
574
+ }
627
575
  }
628
- /** RepeatUntilSuccess: Repeats until child succeeds */
629
576
  class BTRepeatUntilSuccess extends BTDecorator {
630
- constructor(name = 'Repeat Until Success') {
631
- super('repeatUntilSuccess', name);
632
- }
633
- tick(context) {
634
- if (!this.child) {
635
- this.lastStatus = 'failure';
636
- return 'failure';
637
- }
638
- const status = this.child.tick(context);
639
- this.child.lastStatus = status;
640
- if (status === 'success') {
641
- this.lastStatus = 'success';
642
- return 'success';
643
- }
644
- if (status === 'running') {
645
- this.lastStatus = 'running';
646
- return 'running';
647
- }
648
- // Failure - reset and continue
649
- this.child.reset();
650
- this.lastStatus = 'running';
651
- return 'running';
652
- }
653
- clone() {
654
- const node = new BTRepeatUntilSuccess(this.name);
655
- node.properties = { ...this.properties };
656
- node.position = { ...this.position };
657
- node.child = this.child?.clone() || null;
658
- return node;
659
- }
577
+ constructor(name = "Repeat Until Success") {
578
+ super("repeatUntilSuccess", name);
579
+ }
580
+ tick(context) {
581
+ if (!this.child) {
582
+ this.lastStatus = "failure";
583
+ return "failure";
584
+ }
585
+ const status = this.child.tick(context);
586
+ this.child.lastStatus = status;
587
+ if (status === "success") {
588
+ this.lastStatus = "success";
589
+ return "success";
590
+ }
591
+ if (status === "running") {
592
+ this.lastStatus = "running";
593
+ return "running";
594
+ }
595
+ this.child.reset();
596
+ this.lastStatus = "running";
597
+ return "running";
598
+ }
599
+ clone() {
600
+ const node = new BTRepeatUntilSuccess(this.name);
601
+ node.properties = { ...this.properties };
602
+ node.position = { ...this.position };
603
+ node.child = this.child?.clone() || null;
604
+ return node;
605
+ }
660
606
  }
661
- /** Timeout: Fails if child takes too long */
662
607
  class BTTimeout extends BTDecorator {
663
- constructor(name = 'Timeout', seconds = 5) {
664
- super('timeout', name);
665
- this.elapsed = 0;
666
- this.started = false;
667
- this.timeoutSeconds = seconds;
668
- }
669
- tick(context) {
670
- if (!this.child) {
671
- this.lastStatus = 'failure';
672
- return 'failure';
673
- }
674
- if (!this.started) {
675
- this.elapsed = 0;
676
- this.started = true;
677
- }
678
- this.elapsed += context.dt;
679
- if (this.elapsed >= this.timeoutSeconds) {
680
- this.child.abort();
681
- this.started = false;
682
- this.lastStatus = 'failure';
683
- return 'failure';
684
- }
685
- const status = this.child.tick(context);
686
- this.child.lastStatus = status;
687
- if (status !== 'running') {
688
- this.started = false;
689
- }
690
- this.lastStatus = status;
691
- return status;
692
- }
693
- reset() {
694
- super.reset();
695
- this.elapsed = 0;
696
- this.started = false;
697
- }
698
- clone() {
699
- const node = new BTTimeout(this.name, this.timeoutSeconds);
700
- node.properties = { ...this.properties };
701
- node.position = { ...this.position };
702
- node.child = this.child?.clone() || null;
703
- return node;
704
- }
608
+ constructor(name = "Timeout", seconds = 5) {
609
+ super("timeout", name);
610
+ this.elapsed = 0;
611
+ this.started = false;
612
+ this.timeoutSeconds = seconds;
613
+ }
614
+ tick(context) {
615
+ if (!this.child) {
616
+ this.lastStatus = "failure";
617
+ return "failure";
618
+ }
619
+ if (!this.started) {
620
+ this.elapsed = 0;
621
+ this.started = true;
622
+ }
623
+ this.elapsed += context.dt;
624
+ if (this.elapsed >= this.timeoutSeconds) {
625
+ this.child.abort();
626
+ this.started = false;
627
+ this.lastStatus = "failure";
628
+ return "failure";
629
+ }
630
+ const status = this.child.tick(context);
631
+ this.child.lastStatus = status;
632
+ if (status !== "running") {
633
+ this.started = false;
634
+ }
635
+ this.lastStatus = status;
636
+ return status;
637
+ }
638
+ reset() {
639
+ super.reset();
640
+ this.elapsed = 0;
641
+ this.started = false;
642
+ }
643
+ clone() {
644
+ const node = new BTTimeout(this.name, this.timeoutSeconds);
645
+ node.properties = { ...this.properties };
646
+ node.position = { ...this.position };
647
+ node.child = this.child?.clone() || null;
648
+ return node;
649
+ }
705
650
  }
706
- /** Cooldown: Rate limits child execution */
707
651
  class BTCooldown extends BTDecorator {
708
- constructor(name = 'Cooldown', seconds = 1) {
709
- super('cooldown', name);
710
- this.lastExecution = -Infinity;
711
- this.cooldownSeconds = seconds;
712
- }
713
- tick(context) {
714
- if (!this.child) {
715
- this.lastStatus = 'failure';
716
- return 'failure';
717
- }
718
- const elapsed = context.time - this.lastExecution;
719
- if (elapsed < this.cooldownSeconds) {
720
- this.lastStatus = 'failure';
721
- return 'failure';
722
- }
723
- const status = this.child.tick(context);
724
- this.child.lastStatus = status;
725
- if (status !== 'running') {
726
- this.lastExecution = context.time;
727
- }
728
- this.lastStatus = status;
729
- return status;
730
- }
731
- reset() {
732
- super.reset();
733
- // Don't reset lastExecution - cooldown should persist
734
- }
735
- clone() {
736
- const node = new BTCooldown(this.name, this.cooldownSeconds);
737
- node.properties = { ...this.properties };
738
- node.position = { ...this.position };
739
- node.child = this.child?.clone() || null;
740
- return node;
741
- }
652
+ constructor(name = "Cooldown", seconds = 1) {
653
+ super("cooldown", name);
654
+ this.lastExecution = -Infinity;
655
+ this.cooldownSeconds = seconds;
656
+ }
657
+ tick(context) {
658
+ if (!this.child) {
659
+ this.lastStatus = "failure";
660
+ return "failure";
661
+ }
662
+ const elapsed = context.time - this.lastExecution;
663
+ if (elapsed < this.cooldownSeconds) {
664
+ this.lastStatus = "failure";
665
+ return "failure";
666
+ }
667
+ const status = this.child.tick(context);
668
+ this.child.lastStatus = status;
669
+ if (status !== "running") {
670
+ this.lastExecution = context.time;
671
+ }
672
+ this.lastStatus = status;
673
+ return status;
674
+ }
675
+ reset() {
676
+ super.reset();
677
+ }
678
+ clone() {
679
+ const node = new BTCooldown(this.name, this.cooldownSeconds);
680
+ node.properties = { ...this.properties };
681
+ node.position = { ...this.position };
682
+ node.child = this.child?.clone() || null;
683
+ return node;
684
+ }
742
685
  }
743
- /** Condition Guard: Only runs child if condition is true */
744
686
  class BTConditionGuard extends BTDecorator {
745
- constructor(name = 'Guard', condition = () => true) {
746
- super('guard', name);
747
- this.condition = condition;
748
- }
749
- tick(context) {
750
- if (!this.child) {
751
- this.lastStatus = 'failure';
752
- return 'failure';
753
- }
754
- if (!this.condition(context)) {
755
- this.lastStatus = 'failure';
756
- return 'failure';
757
- }
758
- const status = this.child.tick(context);
759
- this.child.lastStatus = status;
760
- this.lastStatus = status;
761
- return status;
762
- }
763
- clone() {
764
- const node = new BTConditionGuard(this.name, this.condition);
765
- node.properties = { ...this.properties };
766
- node.position = { ...this.position };
767
- node.child = this.child?.clone() || null;
768
- return node;
769
- }
687
+ constructor(name = "Guard", condition = () => true) {
688
+ super("guard", name);
689
+ this.condition = condition;
690
+ }
691
+ tick(context) {
692
+ if (!this.child) {
693
+ this.lastStatus = "failure";
694
+ return "failure";
695
+ }
696
+ if (!this.condition(context)) {
697
+ this.lastStatus = "failure";
698
+ return "failure";
699
+ }
700
+ const status = this.child.tick(context);
701
+ this.child.lastStatus = status;
702
+ this.lastStatus = status;
703
+ return status;
704
+ }
705
+ clone() {
706
+ const node = new BTConditionGuard(this.name, this.condition);
707
+ node.properties = { ...this.properties };
708
+ node.position = { ...this.position };
709
+ node.child = this.child?.clone() || null;
710
+ return node;
711
+ }
770
712
  }
771
- /** Wait Action: Waits for a duration */
772
713
  class BTWait extends BTNode {
773
- constructor(name = 'Wait', seconds = 1) {
774
- super('wait', 'action', name);
775
- this.elapsed = 0;
776
- this.started = false;
777
- this.seconds = seconds;
778
- }
779
- tick(context) {
780
- if (!this.started) {
781
- this.elapsed = 0;
782
- this.started = true;
783
- }
784
- this.elapsed += context.dt;
785
- if (this.elapsed >= this.seconds) {
786
- this.started = false;
787
- this.lastStatus = 'success';
788
- return 'success';
789
- }
790
- this.lastStatus = 'running';
791
- return 'running';
792
- }
793
- reset() {
794
- super.reset();
795
- this.elapsed = 0;
796
- this.started = false;
797
- }
798
- clone() {
799
- const node = new BTWait(this.name, this.seconds);
800
- node.properties = { ...this.properties };
801
- node.position = { ...this.position };
802
- return node;
803
- }
714
+ constructor(name = "Wait", seconds = 1) {
715
+ super("wait", "action", name);
716
+ this.elapsed = 0;
717
+ this.started = false;
718
+ this.seconds = seconds;
719
+ }
720
+ tick(context) {
721
+ if (!this.started) {
722
+ this.elapsed = 0;
723
+ this.started = true;
724
+ }
725
+ this.elapsed += context.dt;
726
+ if (this.elapsed >= this.seconds) {
727
+ this.started = false;
728
+ this.lastStatus = "success";
729
+ return "success";
730
+ }
731
+ this.lastStatus = "running";
732
+ return "running";
733
+ }
734
+ reset() {
735
+ super.reset();
736
+ this.elapsed = 0;
737
+ this.started = false;
738
+ }
739
+ clone() {
740
+ const node = new BTWait(this.name, this.seconds);
741
+ node.properties = { ...this.properties };
742
+ node.position = { ...this.position };
743
+ return node;
744
+ }
804
745
  }
805
- /** Log Action: Logs a message */
806
746
  class BTLog extends BTNode {
807
- constructor(name = 'Log', message = '', level = 'info') {
808
- super('log', 'action', name);
809
- this.message = message;
810
- this.level = level;
811
- }
812
- tick(_context) {
813
- console.log(`[BT ${this.level}] ${this.message}`);
814
- this.lastStatus = 'success';
815
- return 'success';
816
- }
817
- clone() {
818
- const node = new BTLog(this.name, this.message, this.level);
819
- node.properties = { ...this.properties };
820
- node.position = { ...this.position };
821
- return node;
822
- }
747
+ constructor(name = "Log", message = "", level = "info") {
748
+ super("log", "action", name);
749
+ this.message = message;
750
+ this.level = level;
751
+ }
752
+ tick(_context) {
753
+ console.log(`[BT ${this.level}] ${this.message}`);
754
+ this.lastStatus = "success";
755
+ return "success";
756
+ }
757
+ clone() {
758
+ const node = new BTLog(this.name, this.message, this.level);
759
+ node.properties = { ...this.properties };
760
+ node.position = { ...this.position };
761
+ return node;
762
+ }
823
763
  }
824
- // ============================================================
825
- // Subtree Node
826
- // ============================================================
827
764
  class BTSubtree extends BTNode {
828
- constructor(name, subtreeId) {
829
- super('subtree', 'subtree', name);
830
- this.subtree = null;
831
- this.subtreeId = subtreeId;
832
- }
833
- setSubtree(tree) {
834
- this.subtree = tree;
835
- }
836
- tick(context) {
837
- if (!this.subtree) {
838
- this.lastStatus = 'failure';
839
- return 'failure';
840
- }
841
- const status = this.subtree.tick(context);
842
- this.lastStatus = status;
843
- return status;
844
- }
845
- reset() {
846
- super.reset();
847
- this.subtree?.reset();
848
- }
849
- clone() {
850
- const node = new BTSubtree(this.name, this.subtreeId);
851
- node.properties = { ...this.properties };
852
- node.position = { ...this.position };
853
- node.subtree = this.subtree?.clone() || null;
854
- return node;
855
- }
765
+ constructor(name, subtreeId) {
766
+ super("subtree", "subtree", name);
767
+ this.subtree = null;
768
+ this.subtreeId = subtreeId;
769
+ }
770
+ setSubtree(tree) {
771
+ this.subtree = tree;
772
+ }
773
+ tick(context) {
774
+ if (!this.subtree) {
775
+ this.lastStatus = "failure";
776
+ return "failure";
777
+ }
778
+ const status = this.subtree.tick(context);
779
+ this.lastStatus = status;
780
+ return status;
781
+ }
782
+ reset() {
783
+ super.reset();
784
+ this.subtree?.reset();
785
+ }
786
+ clone() {
787
+ const node = new BTSubtree(this.name, this.subtreeId);
788
+ node.properties = { ...this.properties };
789
+ node.position = { ...this.position };
790
+ node.subtree = this.subtree?.clone() || null;
791
+ return node;
792
+ }
856
793
  }
857
- // ============================================================
858
- // Root Node
859
- // ============================================================
860
794
  class BTRoot extends BTNode {
861
- constructor(name = 'Root') {
862
- super('root', 'root', name);
863
- this.child = null;
864
- }
865
- setChild(child) {
866
- this.child = child;
867
- }
868
- tick(context) {
869
- if (!this.child) {
870
- this.lastStatus = 'success';
871
- return 'success';
872
- }
873
- const status = this.child.tick(context);
874
- this.child.lastStatus = status;
875
- this.lastStatus = status;
876
- return status;
877
- }
878
- reset() {
879
- super.reset();
880
- this.child?.reset();
881
- }
882
- toJSON() {
883
- return {
884
- ...super.toJSON(),
885
- children: this.child ? [this.child.toJSON()] : [],
886
- };
887
- }
888
- clone() {
889
- const node = new BTRoot(this.name);
890
- node.properties = { ...this.properties };
891
- node.position = { ...this.position };
892
- node.child = this.child?.clone() || null;
893
- return node;
894
- }
795
+ constructor(name = "Root") {
796
+ super("root", "root", name);
797
+ this.child = null;
798
+ }
799
+ setChild(child) {
800
+ this.child = child;
801
+ }
802
+ tick(context) {
803
+ if (!this.child) {
804
+ this.lastStatus = "success";
805
+ return "success";
806
+ }
807
+ const status = this.child.tick(context);
808
+ this.child.lastStatus = status;
809
+ this.lastStatus = status;
810
+ return status;
811
+ }
812
+ reset() {
813
+ super.reset();
814
+ this.child?.reset();
815
+ }
816
+ toJSON() {
817
+ return {
818
+ ...super.toJSON(),
819
+ children: this.child ? [this.child.toJSON()] : []
820
+ };
821
+ }
822
+ clone() {
823
+ const node = new BTRoot(this.name);
824
+ node.properties = { ...this.properties };
825
+ node.position = { ...this.position };
826
+ node.child = this.child?.clone() || null;
827
+ return node;
828
+ }
895
829
  }
896
- // ============================================================
897
- // Behavior Tree
898
- // ============================================================
899
830
  class BehaviorTree {
900
- constructor(name = 'Behavior Tree') {
901
- /** Execution statistics */
902
- this.stats = {
903
- tickCount: 0,
904
- lastTickTime: 0,
905
- averageTickTime: 0,
906
- };
907
- /** Debugging */
908
- this.debugMode = false;
909
- this.breakpoints = new Set();
910
- this.isPaused = false;
911
- this.id = `tree_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
912
- this.name = name;
913
- this.root = new BTRoot();
914
- this.blackboard = new BTBlackboard();
915
- }
916
- /** Tick the tree */
917
- tick(context) {
918
- if (this.isPaused) {
919
- return 'running';
920
- }
921
- // Merge blackboards
922
- const mergedContext = {
923
- ...context,
924
- blackboard: this.blackboard,
925
- };
926
- const startTime = performance.now();
927
- const status = this.root.tick(mergedContext);
928
- const endTime = performance.now();
929
- // Update stats
930
- this.stats.tickCount++;
931
- this.stats.lastTickTime = endTime - startTime;
932
- this.stats.averageTickTime =
933
- (this.stats.averageTickTime * (this.stats.tickCount - 1) + this.stats.lastTickTime) /
934
- this.stats.tickCount;
935
- return status;
936
- }
937
- /** Reset the tree */
938
- reset() {
939
- this.root.reset();
940
- }
941
- /** Pause execution */
942
- pause() {
943
- this.isPaused = true;
944
- }
945
- /** Resume execution */
946
- resume() {
947
- this.isPaused = false;
948
- }
949
- /** Add breakpoint */
950
- addBreakpoint(nodeId) {
951
- this.breakpoints.add(nodeId);
952
- }
953
- /** Remove breakpoint */
954
- removeBreakpoint(nodeId) {
955
- this.breakpoints.delete(nodeId);
956
- }
957
- /** Toggle breakpoint */
958
- toggleBreakpoint(nodeId) {
959
- if (this.breakpoints.has(nodeId)) {
960
- this.breakpoints.delete(nodeId);
961
- }
962
- else {
963
- this.breakpoints.add(nodeId);
964
- }
965
- }
966
- /** Find node by ID */
967
- findNode(nodeId) {
968
- return this.findNodeRecursive(this.root, nodeId);
969
- }
970
- findNodeRecursive(node, nodeId) {
971
- if (node.id === nodeId) {
972
- return node;
973
- }
974
- if (node instanceof BTComposite) {
975
- for (const child of node.children) {
976
- const found = this.findNodeRecursive(child, nodeId);
977
- if (found) {
978
- return found;
979
- }
980
- }
981
- }
982
- else if (node instanceof BTDecorator && node.child) {
983
- return this.findNodeRecursive(node.child, nodeId);
984
- }
985
- else if (node instanceof BTRoot && node.child) {
986
- return this.findNodeRecursive(node.child, nodeId);
987
- }
988
- return null;
989
- }
990
- /** Get all nodes */
991
- getAllNodes() {
992
- const nodes = [];
993
- this.collectNodes(this.root, nodes);
994
- return nodes;
995
- }
996
- collectNodes(node, nodes) {
997
- nodes.push(node);
998
- if (node instanceof BTComposite) {
999
- for (const child of node.children) {
1000
- this.collectNodes(child, nodes);
1001
- }
1002
- }
1003
- else if (node instanceof BTDecorator && node.child) {
1004
- this.collectNodes(node.child, nodes);
1005
- }
1006
- else if (node instanceof BTRoot && node.child) {
1007
- this.collectNodes(node.child, nodes);
831
+ constructor(name = "Behavior Tree") {
832
+ this.stats = {
833
+ tickCount: 0,
834
+ lastTickTime: 0,
835
+ averageTickTime: 0
836
+ };
837
+ this.debugMode = false;
838
+ this.breakpoints = /* @__PURE__ */ new Set();
839
+ this.isPaused = false;
840
+ this.id = `tree_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
841
+ this.name = name;
842
+ this.root = new BTRoot();
843
+ this.blackboard = new BTBlackboard();
844
+ }
845
+ /** Tick the tree */
846
+ tick(context) {
847
+ if (this.isPaused) {
848
+ return "running";
849
+ }
850
+ const mergedContext = {
851
+ ...context,
852
+ blackboard: this.blackboard
853
+ };
854
+ const startTime = performance.now();
855
+ const status = this.root.tick(mergedContext);
856
+ const endTime = performance.now();
857
+ this.stats.tickCount++;
858
+ this.stats.lastTickTime = endTime - startTime;
859
+ this.stats.averageTickTime = (this.stats.averageTickTime * (this.stats.tickCount - 1) + this.stats.lastTickTime) / this.stats.tickCount;
860
+ return status;
861
+ }
862
+ /** Reset the tree */
863
+ reset() {
864
+ this.root.reset();
865
+ }
866
+ /** Pause execution */
867
+ pause() {
868
+ this.isPaused = true;
869
+ }
870
+ /** Resume execution */
871
+ resume() {
872
+ this.isPaused = false;
873
+ }
874
+ /** Add breakpoint */
875
+ addBreakpoint(nodeId) {
876
+ this.breakpoints.add(nodeId);
877
+ }
878
+ /** Remove breakpoint */
879
+ removeBreakpoint(nodeId) {
880
+ this.breakpoints.delete(nodeId);
881
+ }
882
+ /** Toggle breakpoint */
883
+ toggleBreakpoint(nodeId) {
884
+ if (this.breakpoints.has(nodeId)) {
885
+ this.breakpoints.delete(nodeId);
886
+ } else {
887
+ this.breakpoints.add(nodeId);
888
+ }
889
+ }
890
+ /** Find node by ID */
891
+ findNode(nodeId) {
892
+ return this.findNodeRecursive(this.root, nodeId);
893
+ }
894
+ findNodeRecursive(node, nodeId) {
895
+ if (node.id === nodeId) {
896
+ return node;
897
+ }
898
+ if (node instanceof BTComposite) {
899
+ for (const child of node.children) {
900
+ const found = this.findNodeRecursive(child, nodeId);
901
+ if (found) {
902
+ return found;
1008
903
  }
1009
- }
1010
- /** Clone the tree */
1011
- clone() {
1012
- const tree = new BehaviorTree(this.name);
1013
- tree.root = this.root.clone();
1014
- tree.blackboard = this.blackboard.clone();
1015
- return tree;
1016
- }
1017
- /** Serialize to JSON */
1018
- toJSON() {
1019
- return {
1020
- id: this.id,
1021
- name: this.name,
1022
- root: this.root.toJSON(),
1023
- blackboard: this.blackboard.toJSON(),
1024
- };
1025
- }
904
+ }
905
+ } else if (node instanceof BTDecorator && node.child) {
906
+ return this.findNodeRecursive(node.child, nodeId);
907
+ } else if (node instanceof BTRoot && node.child) {
908
+ return this.findNodeRecursive(node.child, nodeId);
909
+ }
910
+ return null;
911
+ }
912
+ /** Get all nodes */
913
+ getAllNodes() {
914
+ const nodes = [];
915
+ this.collectNodes(this.root, nodes);
916
+ return nodes;
917
+ }
918
+ collectNodes(node, nodes) {
919
+ nodes.push(node);
920
+ if (node instanceof BTComposite) {
921
+ for (const child of node.children) {
922
+ this.collectNodes(child, nodes);
923
+ }
924
+ } else if (node instanceof BTDecorator && node.child) {
925
+ this.collectNodes(node.child, nodes);
926
+ } else if (node instanceof BTRoot && node.child) {
927
+ this.collectNodes(node.child, nodes);
928
+ }
929
+ }
930
+ /** Clone the tree */
931
+ clone() {
932
+ const tree = new BehaviorTree(this.name);
933
+ tree.root = this.root.clone();
934
+ tree.blackboard = this.blackboard.clone();
935
+ return tree;
936
+ }
937
+ /** Serialize to JSON */
938
+ toJSON() {
939
+ return {
940
+ id: this.id,
941
+ name: this.name,
942
+ root: this.root.toJSON(),
943
+ blackboard: this.blackboard.toJSON()
944
+ };
945
+ }
1026
946
  }
1027
- // ============================================================
1028
- // Node Registry
1029
- // ============================================================
1030
947
  class BTNodeRegistry {
1031
- constructor() {
1032
- this.definitions = new Map();
1033
- }
1034
- register(definition) {
1035
- this.definitions.set(definition.type, definition);
1036
- }
1037
- get(type) {
1038
- return this.definitions.get(type);
1039
- }
1040
- getAll() {
1041
- return Array.from(this.definitions.values());
1042
- }
1043
- getByCategory(category) {
1044
- return this.getAll().filter((d) => d.category === category);
1045
- }
1046
- createNode(type, properties) {
1047
- const def = this.definitions.get(type);
1048
- if (!def) {
1049
- return null;
1050
- }
1051
- return def.create(properties);
1052
- }
948
+ constructor() {
949
+ this.definitions = /* @__PURE__ */ new Map();
950
+ }
951
+ register(definition) {
952
+ this.definitions.set(definition.type, definition);
953
+ }
954
+ get(type) {
955
+ return this.definitions.get(type);
956
+ }
957
+ getAll() {
958
+ return Array.from(this.definitions.values());
959
+ }
960
+ getByCategory(category) {
961
+ return this.getAll().filter((d) => d.category === category);
962
+ }
963
+ createNode(type, properties) {
964
+ const def = this.definitions.get(type);
965
+ if (!def) {
966
+ return null;
967
+ }
968
+ return def.create(properties);
969
+ }
1053
970
  }
1054
- // ============================================================
1055
- // Factory Functions
1056
- // ============================================================
1057
971
  function createBehaviorTree(name) {
1058
- return new BehaviorTree(name);
972
+ return new BehaviorTree(name);
1059
973
  }
1060
974
  function createBlackboard() {
1061
- return new BTBlackboard();
975
+ return new BTBlackboard();
1062
976
  }
1063
977
  function createNodeRegistry() {
1064
- const registry = new BTNodeRegistry();
1065
- // Register built-in nodes
1066
- registry.register({
1067
- type: 'sequence',
1068
- category: 'composite',
1069
- name: 'Sequence',
1070
- description: 'Executes children in order until one fails',
1071
- icon: 'arrow-right',
1072
- color: '#3b82f6',
1073
- create: () => new BTSequence(),
1074
- });
1075
- registry.register({
1076
- type: 'selector',
1077
- category: 'composite',
1078
- name: 'Selector',
1079
- description: 'Executes children until one succeeds',
1080
- icon: 'git-branch',
1081
- color: '#22c55e',
1082
- create: () => new BTSelector(),
1083
- });
1084
- registry.register({
1085
- type: 'parallel',
1086
- category: 'composite',
1087
- name: 'Parallel',
1088
- description: 'Executes all children simultaneously',
1089
- icon: 'layers',
1090
- color: '#8b5cf6',
1091
- properties: [
1092
- { name: 'successPolicy', type: 'enum', enumValues: ['all', 'one'], default: 'all' },
1093
- { name: 'failurePolicy', type: 'enum', enumValues: ['all', 'one'], default: 'one' },
1094
- ],
1095
- create: (props) => {
1096
- const node = new BTParallel();
1097
- if (props?.successPolicy) {
1098
- node.successPolicy = props.successPolicy;
1099
- }
1100
- if (props?.failurePolicy) {
1101
- node.failurePolicy = props.failurePolicy;
1102
- }
1103
- return node;
1104
- },
1105
- });
1106
- registry.register({
1107
- type: 'inverter',
1108
- category: 'decorator',
1109
- name: 'Inverter',
1110
- description: 'Inverts the result of its child',
1111
- icon: 'refresh-cw',
1112
- color: '#f97316',
1113
- create: () => new BTInverter(),
1114
- });
1115
- registry.register({
1116
- type: 'repeater',
1117
- category: 'decorator',
1118
- name: 'Repeater',
1119
- description: 'Repeats child N times (-1 = infinite)',
1120
- icon: 'repeat',
1121
- color: '#f97316',
1122
- properties: [{ name: 'times', type: 'number', default: -1, min: -1 }],
1123
- create: (props) => new BTRepeater('Repeater', props?.times ?? -1),
1124
- });
1125
- registry.register({
1126
- type: 'timeout',
1127
- category: 'decorator',
1128
- name: 'Timeout',
1129
- description: 'Fails if child takes too long',
1130
- icon: 'clock',
1131
- color: '#f97316',
1132
- properties: [{ name: 'seconds', type: 'number', default: 5, min: 0 }],
1133
- create: (props) => new BTTimeout('Timeout', props?.seconds ?? 5),
1134
- });
1135
- registry.register({
1136
- type: 'wait',
1137
- category: 'action',
1138
- name: 'Wait',
1139
- description: 'Waits for a duration',
1140
- icon: 'pause',
1141
- color: '#6b7280',
1142
- properties: [{ name: 'seconds', type: 'number', default: 1, min: 0 }],
1143
- create: (props) => new BTWait('Wait', props?.seconds ?? 1),
1144
- });
1145
- registry.register({
1146
- type: 'log',
1147
- category: 'action',
1148
- name: 'Log',
1149
- description: 'Logs a message',
1150
- icon: 'message-square',
1151
- color: '#6b7280',
1152
- properties: [
1153
- { name: 'message', type: 'string', default: '' },
1154
- { name: 'level', type: 'enum', enumValues: ['info', 'warn', 'error'], default: 'info' },
1155
- ],
1156
- create: (props) => new BTLog('Log', props?.message ?? '', props?.level ?? 'info'),
1157
- });
1158
- return registry;
978
+ const registry = new BTNodeRegistry();
979
+ registry.register({
980
+ type: "sequence",
981
+ category: "composite",
982
+ name: "Sequence",
983
+ description: "Executes children in order until one fails",
984
+ icon: "arrow-right",
985
+ color: "#3b82f6",
986
+ create: () => new BTSequence()
987
+ });
988
+ registry.register({
989
+ type: "selector",
990
+ category: "composite",
991
+ name: "Selector",
992
+ description: "Executes children until one succeeds",
993
+ icon: "git-branch",
994
+ color: "#22c55e",
995
+ create: () => new BTSelector()
996
+ });
997
+ registry.register({
998
+ type: "parallel",
999
+ category: "composite",
1000
+ name: "Parallel",
1001
+ description: "Executes all children simultaneously",
1002
+ icon: "layers",
1003
+ color: "#8b5cf6",
1004
+ properties: [
1005
+ { name: "successPolicy", type: "enum", enumValues: ["all", "one"], default: "all" },
1006
+ { name: "failurePolicy", type: "enum", enumValues: ["all", "one"], default: "one" }
1007
+ ],
1008
+ create: (props) => {
1009
+ const node = new BTParallel();
1010
+ if (props?.successPolicy) {
1011
+ node.successPolicy = props.successPolicy;
1012
+ }
1013
+ if (props?.failurePolicy) {
1014
+ node.failurePolicy = props.failurePolicy;
1015
+ }
1016
+ return node;
1017
+ }
1018
+ });
1019
+ registry.register({
1020
+ type: "inverter",
1021
+ category: "decorator",
1022
+ name: "Inverter",
1023
+ description: "Inverts the result of its child",
1024
+ icon: "refresh-cw",
1025
+ color: "#f97316",
1026
+ create: () => new BTInverter()
1027
+ });
1028
+ registry.register({
1029
+ type: "repeater",
1030
+ category: "decorator",
1031
+ name: "Repeater",
1032
+ description: "Repeats child N times (-1 = infinite)",
1033
+ icon: "repeat",
1034
+ color: "#f97316",
1035
+ properties: [{ name: "times", type: "number", default: -1, min: -1 }],
1036
+ create: (props) => new BTRepeater("Repeater", props?.times ?? -1)
1037
+ });
1038
+ registry.register({
1039
+ type: "timeout",
1040
+ category: "decorator",
1041
+ name: "Timeout",
1042
+ description: "Fails if child takes too long",
1043
+ icon: "clock",
1044
+ color: "#f97316",
1045
+ properties: [{ name: "seconds", type: "number", default: 5, min: 0 }],
1046
+ create: (props) => new BTTimeout("Timeout", props?.seconds ?? 5)
1047
+ });
1048
+ registry.register({
1049
+ type: "wait",
1050
+ category: "action",
1051
+ name: "Wait",
1052
+ description: "Waits for a duration",
1053
+ icon: "pause",
1054
+ color: "#6b7280",
1055
+ properties: [{ name: "seconds", type: "number", default: 1, min: 0 }],
1056
+ create: (props) => new BTWait("Wait", props?.seconds ?? 1)
1057
+ });
1058
+ registry.register({
1059
+ type: "log",
1060
+ category: "action",
1061
+ name: "Log",
1062
+ description: "Logs a message",
1063
+ icon: "message-square",
1064
+ color: "#6b7280",
1065
+ properties: [
1066
+ { name: "message", type: "string", default: "" },
1067
+ { name: "level", type: "enum", enumValues: ["info", "warn", "error"], default: "info" }
1068
+ ],
1069
+ create: (props) => new BTLog(
1070
+ "Log",
1071
+ props?.message ?? "",
1072
+ props?.level ?? "info"
1073
+ )
1074
+ });
1075
+ return registry;
1159
1076
  }
1160
- /** Create execution context */
1161
1077
  function createBTContext(params) {
1162
- let isAborted = false;
1163
- return {
1164
- entityId: params.entityId,
1165
- blackboard: params.blackboard || new BTBlackboard(),
1166
- dt: params.dt,
1167
- time: params.time,
1168
- world: params.world,
1169
- emit: () => { },
1170
- abort: () => {
1171
- isAborted = true;
1172
- },
1173
- get isAborted() {
1174
- return isAborted;
1175
- },
1176
- };
1078
+ let isAborted = false;
1079
+ return {
1080
+ entityId: params.entityId,
1081
+ blackboard: params.blackboard || new BTBlackboard(),
1082
+ dt: params.dt,
1083
+ time: params.time,
1084
+ world: params.world,
1085
+ emit: () => {
1086
+ },
1087
+ abort: () => {
1088
+ isAborted = true;
1089
+ },
1090
+ get isAborted() {
1091
+ return isAborted;
1092
+ }
1093
+ };
1177
1094
  }
1178
-
1179
1095
  exports.BTBlackboard = BTBlackboard;
1180
1096
  exports.BTComposite = BTComposite;
1181
1097
  exports.BTConditionGuard = BTConditionGuard;