@nice2dev/game-engine 1.3.15 → 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 +9 -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,957 +1,1008 @@
1
- import { NiceIcon } from '@nice2dev/ui';
2
- import React from 'react';
3
- import { EventBus } from '../core/EventBus.js';
4
-
5
- /* ────────────────────────────────────────────────────────────────
6
- Quest & Mission System
7
-
8
- A comprehensive quest system with:
9
- - Multiple quest types (main, side, daily, achievement)
10
- - Objectives with progress tracking
11
- - Rewards and prerequisites
12
- - Quest chains and dependencies
13
- - State persistence
14
- ──────────────────────────────────────────────────────────────── */
15
- /* ═══════════════════════════════════════════════════════════════
16
- QUEST MANAGER
17
- ══════════════════════════════════════════════════════════════════ */
1
+ import { NiceIcon } from "@nice2dev/ui";
2
+ import React from "react";
3
+ import { EventBus } from "../core/EventBus.js";
18
4
  class QuestManager {
19
- constructor(events) {
20
- this.quests = new Map();
21
- this.journal = {
22
- activeQuests: [],
23
- completedQuests: [],
24
- failedQuests: [],
25
- };
26
- this.playerLevel = 1;
27
- this.playerItems = new Set();
28
- this.playerSkills = new Set();
29
- this.reputation = new Map();
30
- this.customConditions = new Map();
31
- this.events = events ?? new EventBus();
32
- }
33
- /* ── Quest Registration ───────────────────────────────────────── */
34
- registerQuest(quest) {
35
- this.quests.set(quest.id, quest);
36
- }
37
- registerQuests(quests) {
38
- for (const quest of quests) {
39
- this.registerQuest(quest);
40
- }
41
- }
42
- unregisterQuest(questId) {
43
- this.quests.delete(questId);
44
- }
45
- getQuest(questId) {
46
- return this.quests.get(questId);
47
- }
48
- getAllQuests() {
49
- return Array.from(this.quests.values());
50
- }
51
- /* ── Player State ─────────────────────────────────────────────── */
52
- setPlayerLevel(level) {
53
- this.playerLevel = level;
54
- this.checkQuestUnlocks();
55
- }
56
- addPlayerItem(itemId) {
57
- this.playerItems.add(itemId);
58
- this.checkQuestUnlocks();
59
- }
60
- removePlayerItem(itemId) {
61
- this.playerItems.delete(itemId);
62
- }
63
- addPlayerSkill(skillId) {
64
- this.playerSkills.add(skillId);
65
- this.checkQuestUnlocks();
66
- }
67
- setReputation(factionId, amount) {
68
- this.reputation.set(factionId, amount);
69
- this.checkQuestUnlocks();
70
- }
71
- addReputation(factionId, amount) {
72
- const current = this.reputation.get(factionId) ?? 0;
73
- this.reputation.set(factionId, current + amount);
74
- this.checkQuestUnlocks();
75
- }
76
- registerCustomCondition(key, condition) {
77
- this.customConditions.set(key, condition);
78
- }
79
- /* ── Quest State ──────────────────────────────────────────────── */
80
- getQuestState(questId) {
81
- return (this.journal.activeQuests.find((q) => q.questId === questId) ??
82
- this.journal.completedQuests.find((q) => q.questId === questId) ??
83
- this.journal.failedQuests.find((q) => q.questId === questId));
84
- }
85
- getQuestStatus(questId) {
86
- const state = this.getQuestState(questId);
87
- if (state) {
88
- return state.status;
89
- }
90
- const quest = this.quests.get(questId);
91
- if (!quest) {
92
- return 'locked';
93
- }
94
- return this.canUnlockQuest(questId) ? 'available' : 'locked';
95
- }
96
- getActiveQuests() {
97
- return [...this.journal.activeQuests];
98
- }
99
- getCompletedQuests() {
100
- return [...this.journal.completedQuests];
101
- }
102
- getAvailableQuests() {
103
- return this.getAllQuests().filter((q) => {
104
- const status = this.getQuestStatus(q.id);
105
- return status === 'available';
106
- });
107
- }
108
- getJournal() {
109
- return { ...this.journal };
110
- }
111
- /* ── Quest Flow ───────────────────────────────────────────────── */
112
- canUnlockQuest(questId) {
113
- const quest = this.quests.get(questId);
114
- if (!quest) {
115
- return false;
116
- }
117
- // Already active or completed
118
- const existingState = this.getQuestState(questId);
119
- if (existingState &&
120
- (existingState.status === 'active' || existingState.status === 'completed')) {
121
- // Check if repeatable
122
- if (!quest.repeatable) {
123
- return false;
124
- }
125
- if (existingState.lastCompletedAt && quest.repeatCooldown) {
126
- if (Date.now() - existingState.lastCompletedAt < quest.repeatCooldown) {
127
- return false;
128
- }
129
- }
130
- }
131
- // Check prerequisites
132
- return quest.prerequisites.every((prereq) => this.checkPrerequisite(prereq));
133
- }
134
- checkPrerequisite(prereq) {
135
- switch (prereq.type) {
136
- case 'quest': {
137
- if (!prereq.questId) {
138
- return true;
139
- }
140
- const state = this.getQuestState(prereq.questId);
141
- return state?.status === 'completed';
142
- }
143
- case 'level':
144
- return this.playerLevel >= (prereq.level ?? 0);
145
- case 'item':
146
- return prereq.itemId ? this.playerItems.has(prereq.itemId) : true;
147
- case 'reputation': {
148
- if (!prereq.reputation) {
149
- return true;
150
- }
151
- const rep = this.reputation.get(prereq.reputation.factionId) ?? 0;
152
- return rep >= prereq.reputation.amount;
153
- }
154
- case 'skill':
155
- return prereq.skillId ? this.playerSkills.has(prereq.skillId) : true;
156
- case 'time': {
157
- if (!prereq.timeWindow) {
158
- return true;
159
- }
160
- const now = Date.now();
161
- return now >= prereq.timeWindow.start && now <= prereq.timeWindow.end;
162
- }
163
- case 'custom': {
164
- if (!prereq.customKey) {
165
- return true;
166
- }
167
- const condition = this.customConditions.get(prereq.customKey);
168
- return condition ? condition() : false;
169
- }
170
- default:
171
- return true;
172
- }
173
- }
174
- acceptQuest(questId) {
175
- if (!this.canUnlockQuest(questId)) {
176
- return false;
177
- }
178
- const quest = this.quests.get(questId);
179
- if (!quest) {
180
- return false;
181
- }
182
- // Remove from failed if re-accepting
183
- this.journal.failedQuests = this.journal.failedQuests.filter((q) => q.questId !== questId);
184
- // Create fresh objectives with 0 progress
185
- const objectives = quest.objectives.map((obj) => ({
186
- ...obj,
187
- current: 0,
188
- completed: false,
189
- }));
190
- const state = {
191
- questId,
192
- status: 'active',
193
- objectives,
194
- startedAt: Date.now(),
195
- completionCount: this.getQuestState(questId)?.completionCount ?? 0,
196
- };
197
- if (quest.timeLimit) {
198
- state.timeRemaining = quest.timeLimit * 1000;
199
- }
200
- this.journal.activeQuests.push(state);
201
- this.emitEvent('quest:accepted', questId, {});
202
- return true;
203
- }
204
- abandonQuest(questId) {
205
- const quest = this.quests.get(questId);
206
- if (!quest?.canAbandon) {
207
- return false;
208
- }
209
- const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
210
- if (stateIndex === -1) {
211
- return false;
212
- }
213
- const state = this.journal.activeQuests[stateIndex];
214
- state.status = 'failed';
215
- state.endedAt = Date.now();
216
- this.journal.activeQuests.splice(stateIndex, 1);
217
- this.journal.failedQuests.push(state);
218
- this.emitEvent('quest:abandoned', questId, {});
219
- return true;
220
- }
221
- /* ── Objective Progress ───────────────────────────────────────── */
222
- updateObjectiveProgress(questId, objectiveId, amount) {
223
- const state = this.journal.activeQuests.find((q) => q.questId === questId);
224
- if (!state || state.status !== 'active') {
225
- return false;
226
- }
227
- const objective = state.objectives.find((o) => o.id === objectiveId);
228
- if (!objective || objective.completed) {
229
- return false;
230
- }
231
- const previousValue = objective.current;
232
- objective.current = Math.min(objective.current + amount, objective.target);
233
- this.emitEvent('quest:objective-progress', questId, {
234
- objectiveId,
235
- previous: previousValue,
236
- current: objective.current,
237
- target: objective.target,
238
- });
239
- // Check if objective completed
240
- if (objective.current >= objective.target) {
241
- objective.completed = true;
242
- this.emitEvent('quest:objective-completed', questId, { objectiveId });
243
- this.checkQuestCompletion(questId);
244
- }
245
- return true;
246
- }
247
- setObjectiveProgress(questId, objectiveId, value) {
248
- const state = this.journal.activeQuests.find((q) => q.questId === questId);
249
- if (!state || state.status !== 'active') {
250
- return false;
251
- }
252
- const objective = state.objectives.find((o) => o.id === objectiveId);
253
- if (!objective || objective.completed) {
254
- return false;
255
- }
256
- const previousValue = objective.current;
257
- objective.current = Math.min(value, objective.target);
258
- if (objective.current !== previousValue) {
259
- this.emitEvent('quest:objective-progress', questId, {
260
- objectiveId,
261
- previous: previousValue,
262
- current: objective.current,
263
- target: objective.target,
264
- });
265
- }
266
- if (objective.current >= objective.target) {
267
- objective.completed = true;
268
- this.emitEvent('quest:objective-completed', questId, { objectiveId });
269
- this.checkQuestCompletion(questId);
270
- }
271
- return true;
272
- }
273
- completeObjective(questId, objectiveId) {
274
- const state = this.journal.activeQuests.find((q) => q.questId === questId);
275
- if (!state || state.status !== 'active') {
276
- return false;
277
- }
278
- const objective = state.objectives.find((o) => o.id === objectiveId);
279
- if (!objective || objective.completed) {
280
- return false;
281
- }
282
- objective.current = objective.target;
283
- objective.completed = true;
284
- this.emitEvent('quest:objective-completed', questId, { objectiveId });
285
- this.checkQuestCompletion(questId);
286
- return true;
287
- }
288
- /* ── Quest Completion ─────────────────────────────────────────── */
289
- checkQuestCompletion(questId) {
290
- const state = this.journal.activeQuests.find((q) => q.questId === questId);
291
- if (!state) {
292
- return;
293
- }
294
- // Check if all required objectives are complete
295
- const requiredComplete = state.objectives.filter((o) => !o.optional).every((o) => o.completed);
296
- if (requiredComplete) {
297
- this.completeQuest(questId);
298
- }
299
- }
300
- completeQuest(questId) {
301
- const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
302
- if (stateIndex === -1) {
303
- return false;
304
- }
305
- const state = this.journal.activeQuests[stateIndex];
306
- state.status = 'completed';
307
- state.endedAt = Date.now();
308
- state.completionCount++;
309
- state.lastCompletedAt = Date.now();
310
- this.journal.activeQuests.splice(stateIndex, 1);
311
- this.journal.completedQuests.push(state);
312
- this.emitEvent('quest:completed', questId, { state: { ...state } });
313
- this.checkQuestUnlocks();
314
- this.checkFollowUpQuests(questId);
315
- return true;
316
- }
317
- failQuest(questId) {
318
- const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
319
- if (stateIndex === -1) {
320
- return false;
321
- }
322
- const state = this.journal.activeQuests[stateIndex];
323
- state.status = 'failed';
324
- state.endedAt = Date.now();
325
- this.journal.activeQuests.splice(stateIndex, 1);
326
- this.journal.failedQuests.push(state);
327
- this.emitEvent('quest:failed', questId, {});
5
+ constructor(events) {
6
+ this.quests = /* @__PURE__ */ new Map();
7
+ this.journal = {
8
+ activeQuests: [],
9
+ completedQuests: [],
10
+ failedQuests: []
11
+ };
12
+ this.playerLevel = 1;
13
+ this.playerItems = /* @__PURE__ */ new Set();
14
+ this.playerSkills = /* @__PURE__ */ new Set();
15
+ this.reputation = /* @__PURE__ */ new Map();
16
+ this.customConditions = /* @__PURE__ */ new Map();
17
+ this.events = events ?? new EventBus();
18
+ }
19
+ /* ── Quest Registration ───────────────────────────────────────── */
20
+ registerQuest(quest) {
21
+ this.quests.set(quest.id, quest);
22
+ }
23
+ registerQuests(quests) {
24
+ for (const quest of quests) {
25
+ this.registerQuest(quest);
26
+ }
27
+ }
28
+ unregisterQuest(questId) {
29
+ this.quests.delete(questId);
30
+ }
31
+ getQuest(questId) {
32
+ return this.quests.get(questId);
33
+ }
34
+ getAllQuests() {
35
+ return Array.from(this.quests.values());
36
+ }
37
+ /* ── Player State ─────────────────────────────────────────────── */
38
+ setPlayerLevel(level) {
39
+ this.playerLevel = level;
40
+ this.checkQuestUnlocks();
41
+ }
42
+ addPlayerItem(itemId) {
43
+ this.playerItems.add(itemId);
44
+ this.checkQuestUnlocks();
45
+ }
46
+ removePlayerItem(itemId) {
47
+ this.playerItems.delete(itemId);
48
+ }
49
+ addPlayerSkill(skillId) {
50
+ this.playerSkills.add(skillId);
51
+ this.checkQuestUnlocks();
52
+ }
53
+ setReputation(factionId, amount) {
54
+ this.reputation.set(factionId, amount);
55
+ this.checkQuestUnlocks();
56
+ }
57
+ addReputation(factionId, amount) {
58
+ const current = this.reputation.get(factionId) ?? 0;
59
+ this.reputation.set(factionId, current + amount);
60
+ this.checkQuestUnlocks();
61
+ }
62
+ registerCustomCondition(key, condition) {
63
+ this.customConditions.set(key, condition);
64
+ }
65
+ /* ── Quest State ──────────────────────────────────────────────── */
66
+ getQuestState(questId) {
67
+ return this.journal.activeQuests.find((q) => q.questId === questId) ?? this.journal.completedQuests.find((q) => q.questId === questId) ?? this.journal.failedQuests.find((q) => q.questId === questId);
68
+ }
69
+ getQuestStatus(questId) {
70
+ const state = this.getQuestState(questId);
71
+ if (state) {
72
+ return state.status;
73
+ }
74
+ const quest = this.quests.get(questId);
75
+ if (!quest) {
76
+ return "locked";
77
+ }
78
+ return this.canUnlockQuest(questId) ? "available" : "locked";
79
+ }
80
+ getActiveQuests() {
81
+ return [...this.journal.activeQuests];
82
+ }
83
+ getCompletedQuests() {
84
+ return [...this.journal.completedQuests];
85
+ }
86
+ getAvailableQuests() {
87
+ return this.getAllQuests().filter((q) => {
88
+ const status = this.getQuestStatus(q.id);
89
+ return status === "available";
90
+ });
91
+ }
92
+ getJournal() {
93
+ return { ...this.journal };
94
+ }
95
+ /* ── Quest Flow ───────────────────────────────────────────────── */
96
+ canUnlockQuest(questId) {
97
+ const quest = this.quests.get(questId);
98
+ if (!quest) {
99
+ return false;
100
+ }
101
+ const existingState = this.getQuestState(questId);
102
+ if (existingState && (existingState.status === "active" || existingState.status === "completed")) {
103
+ if (!quest.repeatable) {
104
+ return false;
105
+ }
106
+ if (existingState.lastCompletedAt && quest.repeatCooldown) {
107
+ if (Date.now() - existingState.lastCompletedAt < quest.repeatCooldown) {
108
+ return false;
109
+ }
110
+ }
111
+ }
112
+ return quest.prerequisites.every((prereq) => this.checkPrerequisite(prereq));
113
+ }
114
+ checkPrerequisite(prereq) {
115
+ switch (prereq.type) {
116
+ case "quest": {
117
+ if (!prereq.questId) {
118
+ return true;
119
+ }
120
+ const state = this.getQuestState(prereq.questId);
121
+ return state?.status === "completed";
122
+ }
123
+ case "level":
124
+ return this.playerLevel >= (prereq.level ?? 0);
125
+ case "item":
126
+ return prereq.itemId ? this.playerItems.has(prereq.itemId) : true;
127
+ case "reputation": {
128
+ if (!prereq.reputation) {
129
+ return true;
130
+ }
131
+ const rep = this.reputation.get(prereq.reputation.factionId) ?? 0;
132
+ return rep >= prereq.reputation.amount;
133
+ }
134
+ case "skill":
135
+ return prereq.skillId ? this.playerSkills.has(prereq.skillId) : true;
136
+ case "time": {
137
+ if (!prereq.timeWindow) {
138
+ return true;
139
+ }
140
+ const now = Date.now();
141
+ return now >= prereq.timeWindow.start && now <= prereq.timeWindow.end;
142
+ }
143
+ case "custom": {
144
+ if (!prereq.customKey) {
145
+ return true;
146
+ }
147
+ const condition = this.customConditions.get(prereq.customKey);
148
+ return condition ? condition() : false;
149
+ }
150
+ default:
328
151
  return true;
329
152
  }
330
- checkQuestUnlocks() {
331
- for (const quest of this.quests.values()) {
332
- const status = this.getQuestStatus(quest.id);
333
- if (status === 'locked' && this.canUnlockQuest(quest.id)) {
334
- this.emitEvent('quest:unlocked', quest.id, {});
335
- }
336
- }
153
+ }
154
+ acceptQuest(questId) {
155
+ if (!this.canUnlockQuest(questId)) {
156
+ return false;
337
157
  }
338
- checkFollowUpQuests(completedQuestId) {
339
- const quest = this.quests.get(completedQuestId);
340
- if (!quest?.followUpQuests) {
341
- return;
342
- }
343
- for (const followUpId of quest.followUpQuests) {
344
- if (this.canUnlockQuest(followUpId)) {
345
- this.emitEvent('quest:unlocked', followUpId, {});
346
- }
347
- }
348
- }
349
- /* ── Rewards ──────────────────────────────────────────────────── */
350
- getQuestRewards(questId) {
351
- const quest = this.quests.get(questId);
352
- const state = this.getQuestState(questId);
353
- if (!quest || state?.status !== 'completed') {
354
- return null;
355
- }
356
- const main = [...quest.rewards];
357
- const bonus = [];
358
- // Add bonus rewards if optional objectives completed
359
- if (quest.bonusRewards && state) {
360
- const optionalComplete = state.objectives.filter((o) => o.optional).every((o) => o.completed);
361
- if (optionalComplete) {
362
- bonus.push(...quest.bonusRewards);
363
- }
364
- }
365
- return { main, bonus };
366
- }
367
- claimRewards(questId) {
368
- const rewards = this.getQuestRewards(questId);
369
- if (!rewards) {
370
- return null;
371
- }
372
- const allRewards = [...rewards.main, ...rewards.bonus];
373
- this.emitEvent('quest:reward-claimed', questId, { rewards: allRewards });
374
- return allRewards;
375
- }
376
- /* ── Quest Tracking ───────────────────────────────────────────── */
377
- trackQuest(questId) {
378
- const state = this.journal.activeQuests.find((q) => q.questId === questId);
379
- if (!state) {
380
- return;
381
- }
382
- this.journal.trackedQuestId = questId;
383
- this.emitEvent('quest:tracked', questId, {});
384
- }
385
- untrackQuest() {
386
- this.journal.trackedQuestId = undefined;
387
- }
388
- getTrackedQuest() {
389
- if (!this.journal.trackedQuestId) {
390
- return undefined;
391
- }
392
- return this.journal.activeQuests.find((q) => q.questId === this.journal.trackedQuestId);
393
- }
394
- /* ── Timer Update ─────────────────────────────────────────────── */
395
- update(deltaMs) {
396
- for (const state of this.journal.activeQuests) {
397
- if (state.timeRemaining !== undefined && state.timeRemaining > 0) {
398
- state.timeRemaining -= deltaMs;
399
- if (state.timeRemaining <= 0) {
400
- state.timeRemaining = 0;
401
- this.failQuest(state.questId);
402
- }
403
- }
404
- }
405
- }
406
- /* ── Persistence ──────────────────────────────────────────────── */
407
- saveState() {
408
- return JSON.parse(JSON.stringify(this.journal));
409
- }
410
- loadState(journal) {
411
- this.journal = JSON.parse(JSON.stringify(journal));
412
- }
413
- /* ── Events ───────────────────────────────────────────────────── */
414
- emitEvent(type, questId, data) {
415
- this.events.emit(type, {
416
- type,
417
- questId,
418
- data,
419
- timestamp: Date.now(),
420
- });
421
- }
422
- subscribe(eventType, handler) {
423
- return this.events.on(eventType, handler);
158
+ const quest = this.quests.get(questId);
159
+ if (!quest) {
160
+ return false;
424
161
  }
162
+ this.journal.failedQuests = this.journal.failedQuests.filter((q) => q.questId !== questId);
163
+ const objectives = quest.objectives.map((obj) => ({
164
+ ...obj,
165
+ current: 0,
166
+ completed: false
167
+ }));
168
+ const state = {
169
+ questId,
170
+ status: "active",
171
+ objectives,
172
+ startedAt: Date.now(),
173
+ completionCount: this.getQuestState(questId)?.completionCount ?? 0
174
+ };
175
+ if (quest.timeLimit) {
176
+ state.timeRemaining = quest.timeLimit * 1e3;
177
+ }
178
+ this.journal.activeQuests.push(state);
179
+ this.emitEvent("quest:accepted", questId, {});
180
+ return true;
181
+ }
182
+ abandonQuest(questId) {
183
+ const quest = this.quests.get(questId);
184
+ if (!quest?.canAbandon) {
185
+ return false;
186
+ }
187
+ const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
188
+ if (stateIndex === -1) {
189
+ return false;
190
+ }
191
+ const state = this.journal.activeQuests[stateIndex];
192
+ state.status = "failed";
193
+ state.endedAt = Date.now();
194
+ this.journal.activeQuests.splice(stateIndex, 1);
195
+ this.journal.failedQuests.push(state);
196
+ this.emitEvent("quest:abandoned", questId, {});
197
+ return true;
198
+ }
199
+ /* ── Objective Progress ───────────────────────────────────────── */
200
+ updateObjectiveProgress(questId, objectiveId, amount) {
201
+ const state = this.journal.activeQuests.find((q) => q.questId === questId);
202
+ if (!state || state.status !== "active") {
203
+ return false;
204
+ }
205
+ const objective = state.objectives.find((o) => o.id === objectiveId);
206
+ if (!objective || objective.completed) {
207
+ return false;
208
+ }
209
+ const previousValue = objective.current;
210
+ objective.current = Math.min(objective.current + amount, objective.target);
211
+ this.emitEvent("quest:objective-progress", questId, {
212
+ objectiveId,
213
+ previous: previousValue,
214
+ current: objective.current,
215
+ target: objective.target
216
+ });
217
+ if (objective.current >= objective.target) {
218
+ objective.completed = true;
219
+ this.emitEvent("quest:objective-completed", questId, { objectiveId });
220
+ this.checkQuestCompletion(questId);
221
+ }
222
+ return true;
223
+ }
224
+ setObjectiveProgress(questId, objectiveId, value) {
225
+ const state = this.journal.activeQuests.find((q) => q.questId === questId);
226
+ if (!state || state.status !== "active") {
227
+ return false;
228
+ }
229
+ const objective = state.objectives.find((o) => o.id === objectiveId);
230
+ if (!objective || objective.completed) {
231
+ return false;
232
+ }
233
+ const previousValue = objective.current;
234
+ objective.current = Math.min(value, objective.target);
235
+ if (objective.current !== previousValue) {
236
+ this.emitEvent("quest:objective-progress", questId, {
237
+ objectiveId,
238
+ previous: previousValue,
239
+ current: objective.current,
240
+ target: objective.target
241
+ });
242
+ }
243
+ if (objective.current >= objective.target) {
244
+ objective.completed = true;
245
+ this.emitEvent("quest:objective-completed", questId, { objectiveId });
246
+ this.checkQuestCompletion(questId);
247
+ }
248
+ return true;
249
+ }
250
+ completeObjective(questId, objectiveId) {
251
+ const state = this.journal.activeQuests.find((q) => q.questId === questId);
252
+ if (!state || state.status !== "active") {
253
+ return false;
254
+ }
255
+ const objective = state.objectives.find((o) => o.id === objectiveId);
256
+ if (!objective || objective.completed) {
257
+ return false;
258
+ }
259
+ objective.current = objective.target;
260
+ objective.completed = true;
261
+ this.emitEvent("quest:objective-completed", questId, { objectiveId });
262
+ this.checkQuestCompletion(questId);
263
+ return true;
264
+ }
265
+ /* ── Quest Completion ─────────────────────────────────────────── */
266
+ checkQuestCompletion(questId) {
267
+ const state = this.journal.activeQuests.find((q) => q.questId === questId);
268
+ if (!state) {
269
+ return;
270
+ }
271
+ const requiredComplete = state.objectives.filter((o) => !o.optional).every((o) => o.completed);
272
+ if (requiredComplete) {
273
+ this.completeQuest(questId);
274
+ }
275
+ }
276
+ completeQuest(questId) {
277
+ const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
278
+ if (stateIndex === -1) {
279
+ return false;
280
+ }
281
+ const state = this.journal.activeQuests[stateIndex];
282
+ state.status = "completed";
283
+ state.endedAt = Date.now();
284
+ state.completionCount++;
285
+ state.lastCompletedAt = Date.now();
286
+ this.journal.activeQuests.splice(stateIndex, 1);
287
+ this.journal.completedQuests.push(state);
288
+ this.emitEvent("quest:completed", questId, { state: { ...state } });
289
+ this.checkQuestUnlocks();
290
+ this.checkFollowUpQuests(questId);
291
+ return true;
292
+ }
293
+ failQuest(questId) {
294
+ const stateIndex = this.journal.activeQuests.findIndex((q) => q.questId === questId);
295
+ if (stateIndex === -1) {
296
+ return false;
297
+ }
298
+ const state = this.journal.activeQuests[stateIndex];
299
+ state.status = "failed";
300
+ state.endedAt = Date.now();
301
+ this.journal.activeQuests.splice(stateIndex, 1);
302
+ this.journal.failedQuests.push(state);
303
+ this.emitEvent("quest:failed", questId, {});
304
+ return true;
305
+ }
306
+ checkQuestUnlocks() {
307
+ for (const quest of this.quests.values()) {
308
+ const status = this.getQuestStatus(quest.id);
309
+ if (status === "locked" && this.canUnlockQuest(quest.id)) {
310
+ this.emitEvent("quest:unlocked", quest.id, {});
311
+ }
312
+ }
313
+ }
314
+ checkFollowUpQuests(completedQuestId) {
315
+ const quest = this.quests.get(completedQuestId);
316
+ if (!quest?.followUpQuests) {
317
+ return;
318
+ }
319
+ for (const followUpId of quest.followUpQuests) {
320
+ if (this.canUnlockQuest(followUpId)) {
321
+ this.emitEvent("quest:unlocked", followUpId, {});
322
+ }
323
+ }
324
+ }
325
+ /* ── Rewards ──────────────────────────────────────────────────── */
326
+ getQuestRewards(questId) {
327
+ const quest = this.quests.get(questId);
328
+ const state = this.getQuestState(questId);
329
+ if (!quest || state?.status !== "completed") {
330
+ return null;
331
+ }
332
+ const main = [...quest.rewards];
333
+ const bonus = [];
334
+ if (quest.bonusRewards && state) {
335
+ const optionalComplete = state.objectives.filter((o) => o.optional).every((o) => o.completed);
336
+ if (optionalComplete) {
337
+ bonus.push(...quest.bonusRewards);
338
+ }
339
+ }
340
+ return { main, bonus };
341
+ }
342
+ claimRewards(questId) {
343
+ const rewards = this.getQuestRewards(questId);
344
+ if (!rewards) {
345
+ return null;
346
+ }
347
+ const allRewards = [...rewards.main, ...rewards.bonus];
348
+ this.emitEvent("quest:reward-claimed", questId, { rewards: allRewards });
349
+ return allRewards;
350
+ }
351
+ /* ── Quest Tracking ───────────────────────────────────────────── */
352
+ trackQuest(questId) {
353
+ const state = this.journal.activeQuests.find((q) => q.questId === questId);
354
+ if (!state) {
355
+ return;
356
+ }
357
+ this.journal.trackedQuestId = questId;
358
+ this.emitEvent("quest:tracked", questId, {});
359
+ }
360
+ untrackQuest() {
361
+ this.journal.trackedQuestId = void 0;
362
+ }
363
+ getTrackedQuest() {
364
+ if (!this.journal.trackedQuestId) {
365
+ return void 0;
366
+ }
367
+ return this.journal.activeQuests.find((q) => q.questId === this.journal.trackedQuestId);
368
+ }
369
+ /* ── Timer Update ─────────────────────────────────────────────── */
370
+ update(deltaMs) {
371
+ for (const state of this.journal.activeQuests) {
372
+ if (state.timeRemaining !== void 0 && state.timeRemaining > 0) {
373
+ state.timeRemaining -= deltaMs;
374
+ if (state.timeRemaining <= 0) {
375
+ state.timeRemaining = 0;
376
+ this.failQuest(state.questId);
377
+ }
378
+ }
379
+ }
380
+ }
381
+ /* ── Persistence ──────────────────────────────────────────────── */
382
+ saveState() {
383
+ return JSON.parse(JSON.stringify(this.journal));
384
+ }
385
+ loadState(journal) {
386
+ this.journal = JSON.parse(JSON.stringify(journal));
387
+ }
388
+ /* ── Events ───────────────────────────────────────────────────── */
389
+ emitEvent(type, questId, data) {
390
+ this.events.emit(type, {
391
+ type,
392
+ questId,
393
+ data,
394
+ timestamp: Date.now()
395
+ });
396
+ }
397
+ subscribe(eventType, handler) {
398
+ return this.events.on(eventType, handler);
399
+ }
425
400
  }
426
- /* ═══════════════════════════════════════════════════════════════
427
- QUEST BUILDER (Fluent API)
428
- ══════════════════════════════════════════════════════════════════ */
429
401
  class QuestBuilder {
430
- constructor(id, name) {
431
- this.objectiveCounter = 0;
432
- this.rewardCounter = 0;
433
- this.quest = {
434
- id,
435
- name,
436
- summary: '',
437
- description: '',
438
- type: 'side',
439
- difficulty: 'normal',
440
- objectives: [],
441
- rewards: [],
442
- prerequisites: [],
443
- canAbandon: true,
444
- repeatable: false,
445
- };
446
- }
447
- summary(summary) {
448
- this.quest.summary = summary;
449
- return this;
450
- }
451
- description(description) {
452
- this.quest.description = description;
453
- return this;
454
- }
455
- type(type) {
456
- this.quest.type = type;
457
- return this;
458
- }
459
- difficulty(difficulty) {
460
- this.quest.difficulty = difficulty;
461
- return this;
462
- }
463
- icon(icon) {
464
- this.quest.icon = icon;
465
- return this;
466
- }
467
- giver(npcId) {
468
- this.quest.giverNpcId = npcId;
469
- return this;
470
- }
471
- turnIn(npcId) {
472
- this.quest.turnInNpcId = npcId;
473
- return this;
474
- }
475
- location(hint) {
476
- this.quest.locationHint = hint;
477
- return this;
478
- }
479
- level(level) {
480
- this.quest.recommendedLevel = level;
481
- return this;
482
- }
483
- timeLimit(seconds) {
484
- this.quest.timeLimit = seconds;
485
- return this;
486
- }
487
- cannotAbandon() {
488
- this.quest.canAbandon = false;
489
- return this;
490
- }
491
- repeatable(cooldownMs = 0) {
492
- this.quest.repeatable = true;
493
- this.quest.repeatCooldown = cooldownMs;
494
- return this;
495
- }
496
- tags(tags) {
497
- this.quest.tags = tags;
498
- return this;
499
- }
500
- followUp(questIds) {
501
- this.quest.followUpQuests = questIds;
502
- return this;
503
- }
504
- /* ── Prerequisites ────────────────────────────────────────────── */
505
- requireQuest(questId) {
506
- this.quest.prerequisites.push({ type: 'quest', questId });
507
- return this;
508
- }
509
- requireLevel(level) {
510
- this.quest.prerequisites.push({ type: 'level', level });
511
- return this;
512
- }
513
- requireItem(itemId) {
514
- this.quest.prerequisites.push({ type: 'item', itemId });
515
- return this;
516
- }
517
- requireReputation(factionId, amount) {
518
- this.quest.prerequisites.push({ type: 'reputation', reputation: { factionId, amount } });
519
- return this;
520
- }
521
- requireSkill(skillId) {
522
- this.quest.prerequisites.push({ type: 'skill', skillId });
523
- return this;
524
- }
525
- requireCustom(customKey) {
526
- this.quest.prerequisites.push({ type: 'custom', customKey });
527
- return this;
528
- }
529
- /* ── Objectives ───────────────────────────────────────────────── */
530
- addObjective(objective) {
531
- const id = `obj_${++this.objectiveCounter}`;
532
- this.quest.objectives.push({
533
- ...objective,
534
- id,
535
- current: 0,
536
- completed: false,
537
- });
538
- return this;
539
- }
540
- collect(itemId, amount, description, optional = false) {
541
- return this.addObjective({
542
- type: 'collect',
543
- description,
544
- target: amount,
545
- optional,
546
- trackingData: { itemId },
547
- });
548
- }
549
- kill(enemyType, amount, description, optional = false) {
550
- return this.addObjective({
551
- type: 'kill',
552
- description,
553
- target: amount,
554
- optional,
555
- trackingData: { enemyType },
556
- });
557
- }
558
- interact(entityId, description, optional = false) {
559
- return this.addObjective({
560
- type: 'interact',
561
- description,
562
- target: 1,
563
- optional,
564
- trackingData: { entityId },
565
- });
566
- }
567
- reach(locationId, description, optional = false) {
568
- return this.addObjective({
569
- type: 'reach',
570
- description,
571
- target: 1,
572
- optional,
573
- trackingData: { locationId },
574
- });
575
- }
576
- escort(npcId, locationId, description, optional = false) {
577
- return this.addObjective({
578
- type: 'escort',
579
- description,
580
- target: 1,
581
- optional,
582
- trackingData: { npcId, locationId },
583
- });
584
- }
585
- defend(seconds, description, optional = false) {
586
- return this.addObjective({
587
- type: 'defend',
588
- description,
589
- target: seconds,
590
- optional,
591
- });
592
- }
593
- survive(seconds, description, optional = false) {
594
- return this.addObjective({
595
- type: 'survive',
596
- description,
597
- target: seconds,
598
- optional,
599
- });
600
- }
601
- craft(itemId, amount, description, optional = false) {
602
- return this.addObjective({
603
- type: 'craft',
604
- description,
605
- target: amount,
606
- optional,
607
- trackingData: { itemId },
608
- });
609
- }
610
- talk(npcId, description, optional = false) {
611
- return this.addObjective({
612
- type: 'talk',
613
- description,
614
- target: 1,
615
- optional,
616
- trackingData: { npcId },
617
- });
618
- }
619
- discover(locationId, description, optional = false) {
620
- return this.addObjective({
621
- type: 'discover',
622
- description,
623
- target: 1,
624
- optional,
625
- trackingData: { locationId },
626
- });
627
- }
628
- score(threshold, description, optional = false) {
629
- return this.addObjective({
630
- type: 'score',
631
- description,
632
- target: threshold,
633
- optional,
634
- });
635
- }
636
- customObjective(type, target, description, data, optional = false) {
637
- return this.addObjective({
638
- type: 'custom',
639
- description,
640
- target,
641
- optional,
642
- trackingData: data,
643
- });
644
- }
645
- /* ── Rewards ──────────────────────────────────────────────────── */
646
- generateRewardId() {
647
- return `reward_${++this.rewardCounter}`;
648
- }
649
- rewardXP(amount, name = 'Experience') {
650
- this.quest.rewards.push({
651
- id: this.generateRewardId(),
652
- type: 'experience',
653
- name,
654
- amount,
655
- });
656
- return this;
657
- }
658
- rewardCurrency(amount, currencyName = 'Gold') {
659
- this.quest.rewards.push({
660
- id: this.generateRewardId(),
661
- type: 'currency',
662
- name: currencyName,
663
- amount,
664
- });
665
- return this;
666
- }
667
- rewardItem(itemId, name, quantity = 1, icon) {
668
- this.quest.rewards.push({
669
- id: this.generateRewardId(),
670
- type: 'item',
671
- name,
672
- itemId,
673
- quantity,
674
- icon,
675
- });
676
- return this;
677
- }
678
- rewardSkill(skillId, name, icon) {
679
- this.quest.rewards.push({
680
- id: this.generateRewardId(),
681
- type: 'skill',
682
- name,
683
- skillId,
684
- icon,
685
- });
686
- return this;
687
- }
688
- rewardReputation(factionId, amount, factionName) {
689
- this.quest.rewards.push({
690
- id: this.generateRewardId(),
691
- type: 'reputation',
692
- name: `${factionName} Reputation`,
693
- reputation: { factionId, amount },
694
- });
695
- return this;
696
- }
697
- rewardUnlock(unlockId, name, icon) {
698
- this.quest.rewards.push({
699
- id: this.generateRewardId(),
700
- type: 'unlock',
701
- name,
702
- unlockId,
703
- icon,
704
- });
705
- return this;
706
- }
707
- rewardAchievement(achievementId, name, icon) {
708
- this.quest.rewards.push({
709
- id: this.generateRewardId(),
710
- type: 'achievement',
711
- name,
712
- unlockId: achievementId,
713
- icon,
714
- });
715
- return this;
716
- }
717
- bonusXP(amount, name = 'Bonus Experience') {
718
- if (!this.quest.bonusRewards) {
719
- this.quest.bonusRewards = [];
720
- }
721
- this.quest.bonusRewards.push({
722
- id: this.generateRewardId(),
723
- type: 'experience',
724
- name,
725
- amount,
726
- });
727
- return this;
728
- }
729
- bonusItem(itemId, name, quantity = 1, icon) {
730
- if (!this.quest.bonusRewards) {
731
- this.quest.bonusRewards = [];
732
- }
733
- this.quest.bonusRewards.push({
734
- id: this.generateRewardId(),
735
- type: 'item',
736
- name,
737
- itemId,
738
- quantity,
739
- icon,
740
- });
741
- return this;
742
- }
743
- build() {
744
- return { ...this.quest };
745
- }
402
+ constructor(id, name) {
403
+ this.objectiveCounter = 0;
404
+ this.rewardCounter = 0;
405
+ this.quest = {
406
+ id,
407
+ name,
408
+ summary: "",
409
+ description: "",
410
+ type: "side",
411
+ difficulty: "normal",
412
+ objectives: [],
413
+ rewards: [],
414
+ prerequisites: [],
415
+ canAbandon: true,
416
+ repeatable: false
417
+ };
418
+ }
419
+ summary(summary) {
420
+ this.quest.summary = summary;
421
+ return this;
422
+ }
423
+ description(description) {
424
+ this.quest.description = description;
425
+ return this;
426
+ }
427
+ type(type) {
428
+ this.quest.type = type;
429
+ return this;
430
+ }
431
+ difficulty(difficulty) {
432
+ this.quest.difficulty = difficulty;
433
+ return this;
434
+ }
435
+ icon(icon) {
436
+ this.quest.icon = icon;
437
+ return this;
438
+ }
439
+ giver(npcId) {
440
+ this.quest.giverNpcId = npcId;
441
+ return this;
442
+ }
443
+ turnIn(npcId) {
444
+ this.quest.turnInNpcId = npcId;
445
+ return this;
446
+ }
447
+ location(hint) {
448
+ this.quest.locationHint = hint;
449
+ return this;
450
+ }
451
+ level(level) {
452
+ this.quest.recommendedLevel = level;
453
+ return this;
454
+ }
455
+ timeLimit(seconds) {
456
+ this.quest.timeLimit = seconds;
457
+ return this;
458
+ }
459
+ cannotAbandon() {
460
+ this.quest.canAbandon = false;
461
+ return this;
462
+ }
463
+ repeatable(cooldownMs = 0) {
464
+ this.quest.repeatable = true;
465
+ this.quest.repeatCooldown = cooldownMs;
466
+ return this;
467
+ }
468
+ tags(tags) {
469
+ this.quest.tags = tags;
470
+ return this;
471
+ }
472
+ followUp(questIds) {
473
+ this.quest.followUpQuests = questIds;
474
+ return this;
475
+ }
476
+ /* ── Prerequisites ────────────────────────────────────────────── */
477
+ requireQuest(questId) {
478
+ this.quest.prerequisites.push({ type: "quest", questId });
479
+ return this;
480
+ }
481
+ requireLevel(level) {
482
+ this.quest.prerequisites.push({ type: "level", level });
483
+ return this;
484
+ }
485
+ requireItem(itemId) {
486
+ this.quest.prerequisites.push({ type: "item", itemId });
487
+ return this;
488
+ }
489
+ requireReputation(factionId, amount) {
490
+ this.quest.prerequisites.push({ type: "reputation", reputation: { factionId, amount } });
491
+ return this;
492
+ }
493
+ requireSkill(skillId) {
494
+ this.quest.prerequisites.push({ type: "skill", skillId });
495
+ return this;
496
+ }
497
+ requireCustom(customKey) {
498
+ this.quest.prerequisites.push({ type: "custom", customKey });
499
+ return this;
500
+ }
501
+ /* ── Objectives ───────────────────────────────────────────────── */
502
+ addObjective(objective) {
503
+ const id = `obj_${++this.objectiveCounter}`;
504
+ this.quest.objectives.push({
505
+ ...objective,
506
+ id,
507
+ current: 0,
508
+ completed: false
509
+ });
510
+ return this;
511
+ }
512
+ collect(itemId, amount, description, optional = false) {
513
+ return this.addObjective({
514
+ type: "collect",
515
+ description,
516
+ target: amount,
517
+ optional,
518
+ trackingData: { itemId }
519
+ });
520
+ }
521
+ kill(enemyType, amount, description, optional = false) {
522
+ return this.addObjective({
523
+ type: "kill",
524
+ description,
525
+ target: amount,
526
+ optional,
527
+ trackingData: { enemyType }
528
+ });
529
+ }
530
+ interact(entityId, description, optional = false) {
531
+ return this.addObjective({
532
+ type: "interact",
533
+ description,
534
+ target: 1,
535
+ optional,
536
+ trackingData: { entityId }
537
+ });
538
+ }
539
+ reach(locationId, description, optional = false) {
540
+ return this.addObjective({
541
+ type: "reach",
542
+ description,
543
+ target: 1,
544
+ optional,
545
+ trackingData: { locationId }
546
+ });
547
+ }
548
+ escort(npcId, locationId, description, optional = false) {
549
+ return this.addObjective({
550
+ type: "escort",
551
+ description,
552
+ target: 1,
553
+ optional,
554
+ trackingData: { npcId, locationId }
555
+ });
556
+ }
557
+ defend(seconds, description, optional = false) {
558
+ return this.addObjective({
559
+ type: "defend",
560
+ description,
561
+ target: seconds,
562
+ optional
563
+ });
564
+ }
565
+ survive(seconds, description, optional = false) {
566
+ return this.addObjective({
567
+ type: "survive",
568
+ description,
569
+ target: seconds,
570
+ optional
571
+ });
572
+ }
573
+ craft(itemId, amount, description, optional = false) {
574
+ return this.addObjective({
575
+ type: "craft",
576
+ description,
577
+ target: amount,
578
+ optional,
579
+ trackingData: { itemId }
580
+ });
581
+ }
582
+ talk(npcId, description, optional = false) {
583
+ return this.addObjective({
584
+ type: "talk",
585
+ description,
586
+ target: 1,
587
+ optional,
588
+ trackingData: { npcId }
589
+ });
590
+ }
591
+ discover(locationId, description, optional = false) {
592
+ return this.addObjective({
593
+ type: "discover",
594
+ description,
595
+ target: 1,
596
+ optional,
597
+ trackingData: { locationId }
598
+ });
599
+ }
600
+ score(threshold, description, optional = false) {
601
+ return this.addObjective({
602
+ type: "score",
603
+ description,
604
+ target: threshold,
605
+ optional
606
+ });
607
+ }
608
+ customObjective(type, target, description, data, optional = false) {
609
+ return this.addObjective({
610
+ type: "custom",
611
+ description,
612
+ target,
613
+ optional,
614
+ trackingData: data
615
+ });
616
+ }
617
+ /* ── Rewards ──────────────────────────────────────────────────── */
618
+ generateRewardId() {
619
+ return `reward_${++this.rewardCounter}`;
620
+ }
621
+ rewardXP(amount, name = "Experience") {
622
+ this.quest.rewards.push({
623
+ id: this.generateRewardId(),
624
+ type: "experience",
625
+ name,
626
+ amount
627
+ });
628
+ return this;
629
+ }
630
+ rewardCurrency(amount, currencyName = "Gold") {
631
+ this.quest.rewards.push({
632
+ id: this.generateRewardId(),
633
+ type: "currency",
634
+ name: currencyName,
635
+ amount
636
+ });
637
+ return this;
638
+ }
639
+ rewardItem(itemId, name, quantity = 1, icon) {
640
+ this.quest.rewards.push({
641
+ id: this.generateRewardId(),
642
+ type: "item",
643
+ name,
644
+ itemId,
645
+ quantity,
646
+ icon
647
+ });
648
+ return this;
649
+ }
650
+ rewardSkill(skillId, name, icon) {
651
+ this.quest.rewards.push({
652
+ id: this.generateRewardId(),
653
+ type: "skill",
654
+ name,
655
+ skillId,
656
+ icon
657
+ });
658
+ return this;
659
+ }
660
+ rewardReputation(factionId, amount, factionName) {
661
+ this.quest.rewards.push({
662
+ id: this.generateRewardId(),
663
+ type: "reputation",
664
+ name: `${factionName} Reputation`,
665
+ reputation: { factionId, amount }
666
+ });
667
+ return this;
668
+ }
669
+ rewardUnlock(unlockId, name, icon) {
670
+ this.quest.rewards.push({
671
+ id: this.generateRewardId(),
672
+ type: "unlock",
673
+ name,
674
+ unlockId,
675
+ icon
676
+ });
677
+ return this;
678
+ }
679
+ rewardAchievement(achievementId, name, icon) {
680
+ this.quest.rewards.push({
681
+ id: this.generateRewardId(),
682
+ type: "achievement",
683
+ name,
684
+ unlockId: achievementId,
685
+ icon
686
+ });
687
+ return this;
688
+ }
689
+ bonusXP(amount, name = "Bonus Experience") {
690
+ if (!this.quest.bonusRewards) {
691
+ this.quest.bonusRewards = [];
692
+ }
693
+ this.quest.bonusRewards.push({
694
+ id: this.generateRewardId(),
695
+ type: "experience",
696
+ name,
697
+ amount
698
+ });
699
+ return this;
700
+ }
701
+ bonusItem(itemId, name, quantity = 1, icon) {
702
+ if (!this.quest.bonusRewards) {
703
+ this.quest.bonusRewards = [];
704
+ }
705
+ this.quest.bonusRewards.push({
706
+ id: this.generateRewardId(),
707
+ type: "item",
708
+ name,
709
+ itemId,
710
+ quantity,
711
+ icon
712
+ });
713
+ return this;
714
+ }
715
+ build() {
716
+ return { ...this.quest };
717
+ }
746
718
  }
747
- const QuestList = ({ quests, questDefinitions, trackedId, onSelect, onTrack, filter, className = '', style, }) => {
748
- const filteredQuests = filter
749
- ? quests.filter((q) => {
750
- const def = questDefinitions.get(q.questId);
751
- return def && filter.includes(def.type);
752
- })
753
- : quests;
754
- return React.createElement('div', {
755
- className: `nice-quest-list ${className}`,
756
- style: {
757
- display: 'flex',
758
- flexDirection: 'column',
759
- gap: '8px',
760
- ...style,
719
+ const QuestList = ({
720
+ quests,
721
+ questDefinitions,
722
+ trackedId,
723
+ onSelect,
724
+ onTrack,
725
+ filter,
726
+ className = "",
727
+ style
728
+ }) => {
729
+ const filteredQuests = filter ? quests.filter((q) => {
730
+ const def = questDefinitions.get(q.questId);
731
+ return def && filter.includes(def.type);
732
+ }) : quests;
733
+ return React.createElement(
734
+ "div",
735
+ {
736
+ className: `nice-quest-list ${className}`,
737
+ style: {
738
+ display: "flex",
739
+ flexDirection: "column",
740
+ gap: "8px",
741
+ ...style
742
+ }
743
+ },
744
+ filteredQuests.map((state) => {
745
+ const quest = questDefinitions.get(state.questId);
746
+ if (!quest) {
747
+ return null;
748
+ }
749
+ const progress = state.objectives.filter((o) => !o.optional);
750
+ const completed = progress.filter((o) => o.completed).length;
751
+ const total = progress.length;
752
+ const isTracked = trackedId === state.questId;
753
+ return React.createElement(
754
+ "div",
755
+ {
756
+ key: state.questId,
757
+ className: `nice-quest-item ${isTracked ? "tracked" : ""}`,
758
+ onClick: () => onSelect?.(state.questId),
759
+ style: {
760
+ padding: "12px",
761
+ backgroundColor: isTracked ? "rgba(100, 181, 246, 0.2)" : "rgba(255, 255, 255, 0.05)",
762
+ border: isTracked ? "2px solid #64b5f6" : "2px solid transparent",
763
+ borderRadius: "8px",
764
+ cursor: "pointer"
765
+ }
761
766
  },
762
- }, filteredQuests.map((state) => {
763
- const quest = questDefinitions.get(state.questId);
764
- if (!quest) {
765
- return null;
766
- }
767
- const progress = state.objectives.filter((o) => !o.optional);
768
- const completed = progress.filter((o) => o.completed).length;
769
- const total = progress.length;
770
- const isTracked = trackedId === state.questId;
771
- return React.createElement('div', {
772
- key: state.questId,
773
- className: `nice-quest-item ${isTracked ? 'tracked' : ''}`,
774
- onClick: () => onSelect?.(state.questId),
775
- style: {
776
- padding: '12px',
777
- backgroundColor: isTracked ? 'rgba(100, 181, 246, 0.2)' : 'rgba(255, 255, 255, 0.05)',
778
- border: isTracked ? '2px solid #64b5f6' : '2px solid transparent',
779
- borderRadius: '8px',
780
- cursor: 'pointer',
767
+ [
768
+ React.createElement(
769
+ "div",
770
+ {
771
+ key: "header",
772
+ style: { display: "flex", justifyContent: "space-between", marginBottom: "4px" }
781
773
  },
782
- }, [
783
- React.createElement('div', {
784
- key: 'header',
785
- style: { display: 'flex', justifyContent: 'space-between', marginBottom: '4px' },
786
- }, [
787
- React.createElement('span', {
788
- key: 'name',
789
- style: { fontWeight: 'bold' },
790
- }, quest.name),
791
- React.createElement('span', {
792
- key: 'type',
793
- style: {
794
- fontSize: '12px',
795
- padding: '2px 6px',
796
- backgroundColor: getTypeColor(quest.type),
797
- borderRadius: '4px',
798
- },
799
- }, quest.type.toUpperCase()),
800
- ]),
801
- React.createElement('div', {
802
- key: 'progress',
803
- style: { display: 'flex', alignItems: 'center', gap: '8px', marginTop: '8px' },
804
- }, [
805
- React.createElement('div', {
806
- key: 'bar',
807
- style: {
808
- flex: 1,
809
- height: '4px',
810
- backgroundColor: 'rgba(255, 255, 255, 0.2)',
811
- borderRadius: '2px',
812
- overflow: 'hidden',
813
- },
814
- }, React.createElement('div', {
815
- style: {
816
- width: `${(completed / total) * 100}%`,
817
- height: '100%',
818
- backgroundColor: '#4caf50',
819
- },
820
- })),
821
- React.createElement('span', {
822
- key: 'text',
823
- style: { fontSize: '12px', opacity: 0.7 },
824
- }, `${completed}/${total}`),
825
- onTrack &&
826
- React.createElement('button', {
827
- key: 'track',
828
- onClick: (e) => {
829
- e.stopPropagation();
830
- onTrack(state.questId);
831
- },
832
- style: {
833
- padding: '4px 8px',
834
- fontSize: '10px',
835
- backgroundColor: isTracked ? '#64b5f6' : 'transparent',
836
- border: '1px solid #64b5f6',
837
- borderRadius: '4px',
838
- color: isTracked ? '#000' : '#64b5f6',
839
- cursor: 'pointer',
840
- },
841
- }, isTracked ? 'TRACKED' : 'TRACK'),
842
- ]),
843
- ]);
844
- }));
774
+ [
775
+ React.createElement(
776
+ "span",
777
+ {
778
+ key: "name",
779
+ style: { fontWeight: "bold" }
780
+ },
781
+ quest.name
782
+ ),
783
+ React.createElement(
784
+ "span",
785
+ {
786
+ key: "type",
787
+ style: {
788
+ fontSize: "12px",
789
+ padding: "2px 6px",
790
+ backgroundColor: getTypeColor(quest.type),
791
+ borderRadius: "4px"
792
+ }
793
+ },
794
+ quest.type.toUpperCase()
795
+ )
796
+ ]
797
+ ),
798
+ React.createElement(
799
+ "div",
800
+ {
801
+ key: "progress",
802
+ style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "8px" }
803
+ },
804
+ [
805
+ React.createElement(
806
+ "div",
807
+ {
808
+ key: "bar",
809
+ style: {
810
+ flex: 1,
811
+ height: "4px",
812
+ backgroundColor: "rgba(255, 255, 255, 0.2)",
813
+ borderRadius: "2px",
814
+ overflow: "hidden"
815
+ }
816
+ },
817
+ React.createElement("div", {
818
+ style: {
819
+ width: `${completed / total * 100}%`,
820
+ height: "100%",
821
+ backgroundColor: "#4caf50"
822
+ }
823
+ })
824
+ ),
825
+ React.createElement(
826
+ "span",
827
+ {
828
+ key: "text",
829
+ style: { fontSize: "12px", opacity: 0.7 }
830
+ },
831
+ `${completed}/${total}`
832
+ ),
833
+ onTrack && React.createElement(
834
+ "button",
835
+ {
836
+ key: "track",
837
+ onClick: (e) => {
838
+ e.stopPropagation();
839
+ onTrack(state.questId);
840
+ },
841
+ style: {
842
+ padding: "4px 8px",
843
+ fontSize: "10px",
844
+ backgroundColor: isTracked ? "#64b5f6" : "transparent",
845
+ border: "1px solid #64b5f6",
846
+ borderRadius: "4px",
847
+ color: isTracked ? "#000" : "#64b5f6",
848
+ cursor: "pointer"
849
+ }
850
+ },
851
+ isTracked ? "TRACKED" : "TRACK"
852
+ )
853
+ ]
854
+ )
855
+ ]
856
+ );
857
+ })
858
+ );
845
859
  };
846
860
  function getTypeColor(type) {
847
- switch (type) {
848
- case 'main':
849
- return '#f44336';
850
- case 'side':
851
- return '#2196f3';
852
- case 'daily':
853
- return '#4caf50';
854
- case 'weekly':
855
- return '#9c27b0';
856
- case 'achievement':
857
- return '#ff9800';
858
- case 'tutorial':
859
- return '#00bcd4';
860
- case 'hidden':
861
- return '#607d8b';
862
- default:
863
- return '#9e9e9e';
864
- }
861
+ switch (type) {
862
+ case "main":
863
+ return "#f44336";
864
+ case "side":
865
+ return "#2196f3";
866
+ case "daily":
867
+ return "#4caf50";
868
+ case "weekly":
869
+ return "#9c27b0";
870
+ case "achievement":
871
+ return "#ff9800";
872
+ case "tutorial":
873
+ return "#00bcd4";
874
+ case "hidden":
875
+ return "#607d8b";
876
+ default:
877
+ return "#9e9e9e";
878
+ }
865
879
  }
866
- const QuestTracker = ({ state, quest, showOptional = false, className = '', style, }) => {
867
- const objectives = showOptional ? state.objectives : state.objectives.filter((o) => !o.optional);
868
- return React.createElement('div', {
869
- className: `nice-quest-tracker ${className}`,
870
- style: {
871
- padding: '12px',
872
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
873
- borderRadius: '8px',
874
- color: 'white',
875
- minWidth: '200px',
876
- ...style,
880
+ const QuestTracker = ({
881
+ state,
882
+ quest,
883
+ showOptional = false,
884
+ className = "",
885
+ style
886
+ }) => {
887
+ const objectives = showOptional ? state.objectives : state.objectives.filter((o) => !o.optional);
888
+ return React.createElement(
889
+ "div",
890
+ {
891
+ className: `nice-quest-tracker ${className}`,
892
+ style: {
893
+ padding: "12px",
894
+ backgroundColor: "rgba(0, 0, 0, 0.6)",
895
+ borderRadius: "8px",
896
+ color: "white",
897
+ minWidth: "200px",
898
+ ...style
899
+ }
900
+ },
901
+ [
902
+ React.createElement(
903
+ "div",
904
+ {
905
+ key: "header",
906
+ style: {
907
+ fontWeight: "bold",
908
+ marginBottom: "8px",
909
+ paddingBottom: "8px",
910
+ borderBottom: "1px solid rgba(255, 255, 255, 0.2)"
911
+ }
877
912
  },
878
- }, [
879
- React.createElement('div', {
880
- key: 'header',
881
- style: {
882
- fontWeight: 'bold',
883
- marginBottom: '8px',
884
- paddingBottom: '8px',
885
- borderBottom: '1px solid rgba(255, 255, 255, 0.2)',
886
- },
887
- }, quest.name),
888
- React.createElement('div', {
889
- key: 'objectives',
890
- style: { display: 'flex', flexDirection: 'column', gap: '4px' },
891
- }, objectives.map((obj) => React.createElement('div', {
892
- key: obj.id,
893
- style: {
894
- display: 'flex',
895
- alignItems: 'center',
896
- gap: '8px',
913
+ quest.name
914
+ ),
915
+ React.createElement(
916
+ "div",
917
+ {
918
+ key: "objectives",
919
+ style: { display: "flex", flexDirection: "column", gap: "4px" }
920
+ },
921
+ objectives.map(
922
+ (obj) => React.createElement(
923
+ "div",
924
+ {
925
+ key: obj.id,
926
+ style: {
927
+ display: "flex",
928
+ alignItems: "center",
929
+ gap: "8px",
897
930
  opacity: obj.completed ? 0.5 : 1,
898
- textDecoration: obj.completed ? 'line-through' : 'none',
899
- fontSize: '14px',
931
+ textDecoration: obj.completed ? "line-through" : "none",
932
+ fontSize: "14px"
933
+ }
900
934
  },
901
- }, [
902
- React.createElement('span', {
903
- key: 'check',
904
- style: { color: obj.completed ? '#4caf50' : '#9e9e9e' },
905
- }, React.createElement(NiceIcon, {
906
- name: obj.completed ? 'check' : 'circle',
907
- size: 12,
908
- })),
909
- React.createElement('span', { key: 'desc' }, obj.description),
910
- obj.target > 1 &&
911
- React.createElement('span', {
912
- key: 'progress',
913
- style: { marginLeft: 'auto', fontSize: '12px', opacity: 0.7 },
914
- }, `${obj.current}/${obj.target}`),
915
- ]))),
916
- state.timeRemaining !== undefined &&
917
- state.timeRemaining > 0 &&
918
- React.createElement('div', {
919
- key: 'timer',
920
- style: {
921
- marginTop: '8px',
922
- paddingTop: '8px',
923
- borderTop: '1px solid rgba(255, 255, 255, 0.2)',
924
- textAlign: 'center',
925
- color: state.timeRemaining < 30000 ? '#f44336' : '#fff',
935
+ [
936
+ React.createElement(
937
+ "span",
938
+ {
939
+ key: "check",
940
+ style: { color: obj.completed ? "#4caf50" : "#9e9e9e" }
941
+ },
942
+ React.createElement(NiceIcon, {
943
+ name: obj.completed ? "check" : "circle",
944
+ size: 12
945
+ })
946
+ ),
947
+ React.createElement("span", { key: "desc" }, obj.description),
948
+ obj.target > 1 && React.createElement(
949
+ "span",
950
+ {
951
+ key: "progress",
952
+ style: { marginLeft: "auto", fontSize: "12px", opacity: 0.7 }
926
953
  },
927
- }, `Time: ${formatTime(state.timeRemaining)}`),
928
- ]);
954
+ `${obj.current}/${obj.target}`
955
+ )
956
+ ]
957
+ )
958
+ )
959
+ ),
960
+ state.timeRemaining !== void 0 && state.timeRemaining > 0 && React.createElement(
961
+ "div",
962
+ {
963
+ key: "timer",
964
+ style: {
965
+ marginTop: "8px",
966
+ paddingTop: "8px",
967
+ borderTop: "1px solid rgba(255, 255, 255, 0.2)",
968
+ textAlign: "center",
969
+ color: state.timeRemaining < 3e4 ? "#f44336" : "#fff"
970
+ }
971
+ },
972
+ `Time: ${formatTime(state.timeRemaining)}`
973
+ )
974
+ ]
975
+ );
929
976
  };
930
977
  function formatTime(ms) {
931
- const seconds = Math.floor(ms / 1000);
932
- const minutes = Math.floor(seconds / 60);
933
- const remainingSeconds = seconds % 60;
934
- return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
978
+ const seconds = Math.floor(ms / 1e3);
979
+ const minutes = Math.floor(seconds / 60);
980
+ const remainingSeconds = seconds % 60;
981
+ return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`;
935
982
  }
936
- /* ═══════════════════════════════════════════════════════════════
937
- UTILITY FUNCTIONS
938
- ══════════════════════════════════════════════════════════════════ */
939
983
  function createEmptyQuest(id, name) {
940
- return new QuestBuilder(id, name).build();
984
+ return new QuestBuilder(id, name).build();
941
985
  }
942
986
  const DIFFICULTY_COLORS = {
943
- trivial: '#9e9e9e',
944
- easy: '#4caf50',
945
- normal: '#2196f3',
946
- hard: '#ff9800',
947
- legendary: '#f44336',
987
+ trivial: "#9e9e9e",
988
+ easy: "#4caf50",
989
+ normal: "#2196f3",
990
+ hard: "#ff9800",
991
+ legendary: "#f44336"
948
992
  };
949
993
  const DIFFICULTY_XP_MULTIPLIERS = {
950
- trivial: 0.5,
951
- easy: 0.75,
952
- normal: 1,
953
- hard: 1.5,
954
- legendary: 2,
994
+ trivial: 0.5,
995
+ easy: 0.75,
996
+ normal: 1,
997
+ hard: 1.5,
998
+ legendary: 2
999
+ };
1000
+ export {
1001
+ DIFFICULTY_COLORS,
1002
+ DIFFICULTY_XP_MULTIPLIERS,
1003
+ QuestBuilder,
1004
+ QuestList,
1005
+ QuestManager,
1006
+ QuestTracker,
1007
+ createEmptyQuest
955
1008
  };
956
-
957
- export { DIFFICULTY_COLORS, DIFFICULTY_XP_MULTIPLIERS, QuestBuilder, QuestList, QuestManager, QuestTracker, createEmptyQuest };