@nice2dev/game-engine 1.3.14 → 1.3.16

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