@rb-games/core 0.1.0

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 (388) hide show
  1. package/README.md +488 -0
  2. package/dist/devtools/DraggableController.d.ts +10 -0
  3. package/dist/devtools/DraggableController.d.ts.map +1 -0
  4. package/dist/devtools/ResizableController.d.ts +19 -0
  5. package/dist/devtools/ResizableController.d.ts.map +1 -0
  6. package/dist/devtools/index.d.ts +7 -0
  7. package/dist/devtools/index.d.ts.map +1 -0
  8. package/dist/devtools/index.js +884 -0
  9. package/dist/devtools/index.js.map +1 -0
  10. package/dist/devtools/overlayPlugin.d.ts +3 -0
  11. package/dist/devtools/overlayPlugin.d.ts.map +1 -0
  12. package/dist/devtools/spinePropertiesPlugin.d.ts +3 -0
  13. package/dist/devtools/spinePropertiesPlugin.d.ts.map +1 -0
  14. package/dist/devtools/spriteTextPropertiesPlugin.d.ts +3 -0
  15. package/dist/devtools/spriteTextPropertiesPlugin.d.ts.map +1 -0
  16. package/dist/devtools/treePlugin.d.ts +7 -0
  17. package/dist/devtools/treePlugin.d.ts.map +1 -0
  18. package/dist/engine/PixiEngine.d.ts +404 -0
  19. package/dist/engine/PixiEngine.d.ts.map +1 -0
  20. package/dist/engine/index.d.ts +2 -0
  21. package/dist/engine/index.d.ts.map +1 -0
  22. package/dist/engine/index.js +1818 -0
  23. package/dist/engine/index.js.map +1 -0
  24. package/dist/filters/ChromaKeyFilter.d.ts +64 -0
  25. package/dist/filters/ChromaKeyFilter.d.ts.map +1 -0
  26. package/dist/filters/index.d.ts +2 -0
  27. package/dist/filters/index.d.ts.map +1 -0
  28. package/dist/filters/index.js +248 -0
  29. package/dist/filters/index.js.map +1 -0
  30. package/dist/helpers/AssetHelper.d.ts +117 -0
  31. package/dist/helpers/AssetHelper.d.ts.map +1 -0
  32. package/dist/helpers/SVGAssetHelper.d.ts +397 -0
  33. package/dist/helpers/SVGAssetHelper.d.ts.map +1 -0
  34. package/dist/helpers/SVGLoader.d.ts +46 -0
  35. package/dist/helpers/SVGLoader.d.ts.map +1 -0
  36. package/dist/helpers/SVGParser.d.ts +121 -0
  37. package/dist/helpers/SVGParser.d.ts.map +1 -0
  38. package/dist/helpers/eventBridge.d.ts +150 -0
  39. package/dist/helpers/eventBridge.d.ts.map +1 -0
  40. package/dist/helpers/index.d.ts +8 -0
  41. package/dist/helpers/index.d.ts.map +1 -0
  42. package/dist/helpers/index.js +702 -0
  43. package/dist/helpers/index.js.map +1 -0
  44. package/dist/helpers/mergeUtils.d.ts +21 -0
  45. package/dist/helpers/mergeUtils.d.ts.map +1 -0
  46. package/dist/helpers/resolvePublicPath.d.ts +6 -0
  47. package/dist/helpers/resolvePublicPath.d.ts.map +1 -0
  48. package/dist/i18n/index.d.ts +2 -0
  49. package/dist/i18n/index.d.ts.map +1 -0
  50. package/dist/i18n/index.js +527 -0
  51. package/dist/i18n/index.js.map +1 -0
  52. package/dist/i18n/sharedI18n.d.ts +11 -0
  53. package/dist/i18n/sharedI18n.d.ts.map +1 -0
  54. package/dist/layout/Align.d.ts +126 -0
  55. package/dist/layout/Align.d.ts.map +1 -0
  56. package/dist/layout/Bounds.d.ts +120 -0
  57. package/dist/layout/Bounds.d.ts.map +1 -0
  58. package/dist/layout/Distribute.d.ts +103 -0
  59. package/dist/layout/Distribute.d.ts.map +1 -0
  60. package/dist/layout/Flow.d.ts +213 -0
  61. package/dist/layout/Flow.d.ts.map +1 -0
  62. package/dist/layout/PositionUtils.d.ts +57 -0
  63. package/dist/layout/PositionUtils.d.ts.map +1 -0
  64. package/dist/layout/index.d.ts +6 -0
  65. package/dist/layout/index.d.ts.map +1 -0
  66. package/dist/layout/index.js +673 -0
  67. package/dist/layout/index.js.map +1 -0
  68. package/dist/particle/Emitter.d.ts +290 -0
  69. package/dist/particle/Emitter.d.ts.map +1 -0
  70. package/dist/particle/EmitterConfig.d.ts +228 -0
  71. package/dist/particle/EmitterConfig.d.ts.map +1 -0
  72. package/dist/particle/LinkedListContainer.d.ts +7 -0
  73. package/dist/particle/LinkedListContainer.d.ts.map +1 -0
  74. package/dist/particle/Particle.d.ts +63 -0
  75. package/dist/particle/Particle.d.ts.map +1 -0
  76. package/dist/particle/ParticleUtils.d.ts +97 -0
  77. package/dist/particle/ParticleUtils.d.ts.map +1 -0
  78. package/dist/particle/PropertyList.d.ts +40 -0
  79. package/dist/particle/PropertyList.d.ts.map +1 -0
  80. package/dist/particle/PropertyNode.d.ts +74 -0
  81. package/dist/particle/PropertyNode.d.ts.map +1 -0
  82. package/dist/particle/SpineEmitter.d.ts +55 -0
  83. package/dist/particle/SpineEmitter.d.ts.map +1 -0
  84. package/dist/particle/SpineParticle.d.ts +74 -0
  85. package/dist/particle/SpineParticle.d.ts.map +1 -0
  86. package/dist/particle/behaviors/AccelerationMovement.d.ts +62 -0
  87. package/dist/particle/behaviors/AccelerationMovement.d.ts.map +1 -0
  88. package/dist/particle/behaviors/Alpha.d.ts +60 -0
  89. package/dist/particle/behaviors/Alpha.d.ts.map +1 -0
  90. package/dist/particle/behaviors/AnimatedTexture.d.ts +111 -0
  91. package/dist/particle/behaviors/AnimatedTexture.d.ts.map +1 -0
  92. package/dist/particle/behaviors/Behaviors.d.ts +71 -0
  93. package/dist/particle/behaviors/Behaviors.d.ts.map +1 -0
  94. package/dist/particle/behaviors/BlendMode.d.ts +31 -0
  95. package/dist/particle/behaviors/BlendMode.d.ts.map +1 -0
  96. package/dist/particle/behaviors/BurstSpawn.d.ts +43 -0
  97. package/dist/particle/behaviors/BurstSpawn.d.ts.map +1 -0
  98. package/dist/particle/behaviors/Color.d.ts +60 -0
  99. package/dist/particle/behaviors/Color.d.ts.map +1 -0
  100. package/dist/particle/behaviors/MultiStateAnimatedTexture.d.ts +99 -0
  101. package/dist/particle/behaviors/MultiStateAnimatedTexture.d.ts.map +1 -0
  102. package/dist/particle/behaviors/OrderedTexture.d.ts +33 -0
  103. package/dist/particle/behaviors/OrderedTexture.d.ts.map +1 -0
  104. package/dist/particle/behaviors/PathMovement.d.ts +68 -0
  105. package/dist/particle/behaviors/PathMovement.d.ts.map +1 -0
  106. package/dist/particle/behaviors/PointSpawn.d.ts +21 -0
  107. package/dist/particle/behaviors/PointSpawn.d.ts.map +1 -0
  108. package/dist/particle/behaviors/RandomColor.d.ts +17 -0
  109. package/dist/particle/behaviors/RandomColor.d.ts.map +1 -0
  110. package/dist/particle/behaviors/RandomTexture.d.ts +32 -0
  111. package/dist/particle/behaviors/RandomTexture.d.ts.map +1 -0
  112. package/dist/particle/behaviors/Rotation.d.ts +114 -0
  113. package/dist/particle/behaviors/Rotation.d.ts.map +1 -0
  114. package/dist/particle/behaviors/Scale.d.ts +74 -0
  115. package/dist/particle/behaviors/Scale.d.ts.map +1 -0
  116. package/dist/particle/behaviors/ShapeSpawn.d.ts +58 -0
  117. package/dist/particle/behaviors/ShapeSpawn.d.ts.map +1 -0
  118. package/dist/particle/behaviors/SingleTexture.d.ts +32 -0
  119. package/dist/particle/behaviors/SingleTexture.d.ts.map +1 -0
  120. package/dist/particle/behaviors/SpeedMovement.d.ts +76 -0
  121. package/dist/particle/behaviors/SpeedMovement.d.ts.map +1 -0
  122. package/dist/particle/behaviors/SpineTexture.d.ts +173 -0
  123. package/dist/particle/behaviors/SpineTexture.d.ts.map +1 -0
  124. package/dist/particle/behaviors/ZindexBehavior.d.ts +16 -0
  125. package/dist/particle/behaviors/ZindexBehavior.d.ts.map +1 -0
  126. package/dist/particle/behaviors/editor/Types.d.ts +104 -0
  127. package/dist/particle/behaviors/editor/Types.d.ts.map +1 -0
  128. package/dist/particle/behaviors/editor/behaviors/AccelerationMovement.d.ts +2 -0
  129. package/dist/particle/behaviors/editor/behaviors/AccelerationMovement.d.ts.map +1 -0
  130. package/dist/particle/behaviors/editor/behaviors/Alpha.d.ts +2 -0
  131. package/dist/particle/behaviors/editor/behaviors/Alpha.d.ts.map +1 -0
  132. package/dist/particle/behaviors/editor/behaviors/AnimatedTexture.d.ts +2 -0
  133. package/dist/particle/behaviors/editor/behaviors/AnimatedTexture.d.ts.map +1 -0
  134. package/dist/particle/behaviors/editor/behaviors/BlendMode.d.ts +2 -0
  135. package/dist/particle/behaviors/editor/behaviors/BlendMode.d.ts.map +1 -0
  136. package/dist/particle/behaviors/editor/behaviors/BurstSpawn.d.ts +2 -0
  137. package/dist/particle/behaviors/editor/behaviors/BurstSpawn.d.ts.map +1 -0
  138. package/dist/particle/behaviors/editor/behaviors/Color.d.ts +2 -0
  139. package/dist/particle/behaviors/editor/behaviors/Color.d.ts.map +1 -0
  140. package/dist/particle/behaviors/editor/behaviors/OrderedTexture.d.ts +2 -0
  141. package/dist/particle/behaviors/editor/behaviors/OrderedTexture.d.ts.map +1 -0
  142. package/dist/particle/behaviors/editor/behaviors/PathMovement.d.ts +2 -0
  143. package/dist/particle/behaviors/editor/behaviors/PathMovement.d.ts.map +1 -0
  144. package/dist/particle/behaviors/editor/behaviors/PointSpawn.d.ts +2 -0
  145. package/dist/particle/behaviors/editor/behaviors/PointSpawn.d.ts.map +1 -0
  146. package/dist/particle/behaviors/editor/behaviors/RandomTexture.d.ts +2 -0
  147. package/dist/particle/behaviors/editor/behaviors/RandomTexture.d.ts.map +1 -0
  148. package/dist/particle/behaviors/editor/behaviors/Rotation.d.ts +2 -0
  149. package/dist/particle/behaviors/editor/behaviors/Rotation.d.ts.map +1 -0
  150. package/dist/particle/behaviors/editor/behaviors/Scale.d.ts +2 -0
  151. package/dist/particle/behaviors/editor/behaviors/Scale.d.ts.map +1 -0
  152. package/dist/particle/behaviors/editor/behaviors/ShapeSpawn.d.ts +2 -0
  153. package/dist/particle/behaviors/editor/behaviors/ShapeSpawn.d.ts.map +1 -0
  154. package/dist/particle/behaviors/editor/behaviors/SingleTexture.d.ts +2 -0
  155. package/dist/particle/behaviors/editor/behaviors/SingleTexture.d.ts.map +1 -0
  156. package/dist/particle/behaviors/editor/behaviors/SpeedMovement.d.ts +2 -0
  157. package/dist/particle/behaviors/editor/behaviors/SpeedMovement.d.ts.map +1 -0
  158. package/dist/particle/behaviors/editor/behaviors/index.d.ts +15 -0
  159. package/dist/particle/behaviors/editor/behaviors/index.d.ts.map +1 -0
  160. package/dist/particle/behaviors/editor/index.d.ts +5 -0
  161. package/dist/particle/behaviors/editor/index.d.ts.map +1 -0
  162. package/dist/particle/behaviors/editor/shapes/PolygonalChain.d.ts +2 -0
  163. package/dist/particle/behaviors/editor/shapes/PolygonalChain.d.ts.map +1 -0
  164. package/dist/particle/behaviors/editor/shapes/Rectangle.d.ts +2 -0
  165. package/dist/particle/behaviors/editor/shapes/Rectangle.d.ts.map +1 -0
  166. package/dist/particle/behaviors/editor/shapes/Torus.d.ts +2 -0
  167. package/dist/particle/behaviors/editor/shapes/Torus.d.ts.map +1 -0
  168. package/dist/particle/behaviors/index.d.ts +25 -0
  169. package/dist/particle/behaviors/index.d.ts.map +1 -0
  170. package/dist/particle/behaviors/shapes/PolygonalChain.d.ts +57 -0
  171. package/dist/particle/behaviors/shapes/PolygonalChain.d.ts.map +1 -0
  172. package/dist/particle/behaviors/shapes/Rectangle.d.ts +59 -0
  173. package/dist/particle/behaviors/shapes/Rectangle.d.ts.map +1 -0
  174. package/dist/particle/behaviors/shapes/SpawnShape.d.ts +32 -0
  175. package/dist/particle/behaviors/shapes/SpawnShape.d.ts.map +1 -0
  176. package/dist/particle/behaviors/shapes/Torus.d.ts +71 -0
  177. package/dist/particle/behaviors/shapes/Torus.d.ts.map +1 -0
  178. package/dist/particle/behaviors/shapes/index.d.ts +5 -0
  179. package/dist/particle/behaviors/shapes/index.d.ts.map +1 -0
  180. package/dist/particle/index.d.ts +11 -0
  181. package/dist/particle/index.d.ts.map +1 -0
  182. package/dist/particle/index.js +2845 -0
  183. package/dist/particle/index.js.map +1 -0
  184. package/dist/plugins/Plugin.types.d.ts +80 -0
  185. package/dist/plugins/Plugin.types.d.ts.map +1 -0
  186. package/dist/plugins/device/DeviceOptimizerPlugin.d.ts +187 -0
  187. package/dist/plugins/device/DeviceOptimizerPlugin.d.ts.map +1 -0
  188. package/dist/plugins/device/DeviceOptimizerPlugin.types.d.ts +134 -0
  189. package/dist/plugins/device/DeviceOptimizerPlugin.types.d.ts.map +1 -0
  190. package/dist/plugins/device/index.d.ts +3 -0
  191. package/dist/plugins/device/index.d.ts.map +1 -0
  192. package/dist/plugins/display/DisplayPlugin.d.ts +208 -0
  193. package/dist/plugins/display/DisplayPlugin.d.ts.map +1 -0
  194. package/dist/plugins/display/DisplayPlugin.types.d.ts +174 -0
  195. package/dist/plugins/display/DisplayPlugin.types.d.ts.map +1 -0
  196. package/dist/plugins/display/displayViewport.d.ts +10 -0
  197. package/dist/plugins/display/displayViewport.d.ts.map +1 -0
  198. package/dist/plugins/display/index.d.ts +4 -0
  199. package/dist/plugins/display/index.d.ts.map +1 -0
  200. package/dist/plugins/eventbus/EventBusPlugin.d.ts +21 -0
  201. package/dist/plugins/eventbus/EventBusPlugin.d.ts.map +1 -0
  202. package/dist/plugins/eventbus/EventBusPlugin.types.d.ts +24 -0
  203. package/dist/plugins/eventbus/EventBusPlugin.types.d.ts.map +1 -0
  204. package/dist/plugins/eventbus/index.d.ts +3 -0
  205. package/dist/plugins/eventbus/index.d.ts.map +1 -0
  206. package/dist/plugins/gsap/GsapPlugin.d.ts +307 -0
  207. package/dist/plugins/gsap/GsapPlugin.d.ts.map +1 -0
  208. package/dist/plugins/gsap/index.d.ts +2 -0
  209. package/dist/plugins/gsap/index.d.ts.map +1 -0
  210. package/dist/plugins/index.d.ts +13 -0
  211. package/dist/plugins/index.d.ts.map +1 -0
  212. package/dist/plugins/index.js +12806 -0
  213. package/dist/plugins/index.js.map +1 -0
  214. package/dist/plugins/input/InputPlugin.const.d.ts +80 -0
  215. package/dist/plugins/input/InputPlugin.const.d.ts.map +1 -0
  216. package/dist/plugins/input/InputPlugin.d.ts +141 -0
  217. package/dist/plugins/input/InputPlugin.d.ts.map +1 -0
  218. package/dist/plugins/input/InputPlugin.types.d.ts +41 -0
  219. package/dist/plugins/input/InputPlugin.types.d.ts.map +1 -0
  220. package/dist/plugins/input/KeyboardManager.d.ts +139 -0
  221. package/dist/plugins/input/KeyboardManager.d.ts.map +1 -0
  222. package/dist/plugins/input/KeyboardManager.types.d.ts +27 -0
  223. package/dist/plugins/input/KeyboardManager.types.d.ts.map +1 -0
  224. package/dist/plugins/input/index.d.ts +4 -0
  225. package/dist/plugins/input/index.d.ts.map +1 -0
  226. package/dist/plugins/language/I18NextPlugin.d.ts +30 -0
  227. package/dist/plugins/language/I18NextPlugin.d.ts.map +1 -0
  228. package/dist/plugins/language/I18NextPlugin.types.d.ts +29 -0
  229. package/dist/plugins/language/I18NextPlugin.types.d.ts.map +1 -0
  230. package/dist/plugins/language/index.d.ts +3 -0
  231. package/dist/plugins/language/index.d.ts.map +1 -0
  232. package/dist/plugins/resource/ResourcePlugin.d.ts +189 -0
  233. package/dist/plugins/resource/ResourcePlugin.d.ts.map +1 -0
  234. package/dist/plugins/resource/ResourcePlugin.types.d.ts +153 -0
  235. package/dist/plugins/resource/ResourcePlugin.types.d.ts.map +1 -0
  236. package/dist/plugins/resource/index.d.ts +3 -0
  237. package/dist/plugins/resource/index.d.ts.map +1 -0
  238. package/dist/plugins/scene/Scene.d.ts +203 -0
  239. package/dist/plugins/scene/Scene.d.ts.map +1 -0
  240. package/dist/plugins/scene/ScenePlugin.d.ts +162 -0
  241. package/dist/plugins/scene/ScenePlugin.d.ts.map +1 -0
  242. package/dist/plugins/scene/ScenePlugin.types.d.ts +35 -0
  243. package/dist/plugins/scene/ScenePlugin.types.d.ts.map +1 -0
  244. package/dist/plugins/scene/index.d.ts +4 -0
  245. package/dist/plugins/scene/index.d.ts.map +1 -0
  246. package/dist/plugins/sentry/SentryPlugin.d.ts +66 -0
  247. package/dist/plugins/sentry/SentryPlugin.d.ts.map +1 -0
  248. package/dist/plugins/sentry/SentryPlugin.types.d.ts +8 -0
  249. package/dist/plugins/sentry/SentryPlugin.types.d.ts.map +1 -0
  250. package/dist/plugins/sentry/index.d.ts +3 -0
  251. package/dist/plugins/sentry/index.d.ts.map +1 -0
  252. package/dist/plugins/service/ServiceAdapter.d.ts +88 -0
  253. package/dist/plugins/service/ServiceAdapter.d.ts.map +1 -0
  254. package/dist/plugins/service/ServiceEventHelper.d.ts +6 -0
  255. package/dist/plugins/service/ServiceEventHelper.d.ts.map +1 -0
  256. package/dist/plugins/service/ServicePlugin.d.ts +135 -0
  257. package/dist/plugins/service/ServicePlugin.d.ts.map +1 -0
  258. package/dist/plugins/service/ServicePlugin.types.d.ts +14 -0
  259. package/dist/plugins/service/ServicePlugin.types.d.ts.map +1 -0
  260. package/dist/plugins/service/adapters/DevAuthAdapter.d.ts +56 -0
  261. package/dist/plugins/service/adapters/DevAuthAdapter.d.ts.map +1 -0
  262. package/dist/plugins/service/adapters/RGSAdapter.d.ts +82 -0
  263. package/dist/plugins/service/adapters/RGSAdapter.d.ts.map +1 -0
  264. package/dist/plugins/service/adapters/index.d.ts +7 -0
  265. package/dist/plugins/service/adapters/index.d.ts.map +1 -0
  266. package/dist/plugins/service/adapters/resolvePublicIp.d.ts +10 -0
  267. package/dist/plugins/service/adapters/resolvePublicIp.d.ts.map +1 -0
  268. package/dist/plugins/service/index.d.ts +10 -0
  269. package/dist/plugins/service/index.d.ts.map +1 -0
  270. package/dist/plugins/service/types/api.types.d.ts +299 -0
  271. package/dist/plugins/service/types/api.types.d.ts.map +1 -0
  272. package/dist/plugins/service/types/index.d.ts +6 -0
  273. package/dist/plugins/service/types/index.d.ts.map +1 -0
  274. package/dist/plugins/skin/ISkin.d.ts +62 -0
  275. package/dist/plugins/skin/ISkin.d.ts.map +1 -0
  276. package/dist/plugins/skin/Skin.d.ts +155 -0
  277. package/dist/plugins/skin/Skin.d.ts.map +1 -0
  278. package/dist/plugins/skin/SkinPlugin.d.ts +285 -0
  279. package/dist/plugins/skin/SkinPlugin.d.ts.map +1 -0
  280. package/dist/plugins/skin/SkinPlugin.types.d.ts +56 -0
  281. package/dist/plugins/skin/SkinPlugin.types.d.ts.map +1 -0
  282. package/dist/plugins/skin/index.d.ts +5 -0
  283. package/dist/plugins/skin/index.d.ts.map +1 -0
  284. package/dist/plugins/sound/SoundPlugin.d.ts +319 -0
  285. package/dist/plugins/sound/SoundPlugin.d.ts.map +1 -0
  286. package/dist/plugins/sound/SoundPlugin.types.d.ts +102 -0
  287. package/dist/plugins/sound/SoundPlugin.types.d.ts.map +1 -0
  288. package/dist/plugins/sound/SoundTestGUI.d.ts +42 -0
  289. package/dist/plugins/sound/SoundTestGUI.d.ts.map +1 -0
  290. package/dist/plugins/sound/index.d.ts +4 -0
  291. package/dist/plugins/sound/index.d.ts.map +1 -0
  292. package/dist/state-machine/ConfigBuilder.d.ts +239 -0
  293. package/dist/state-machine/ConfigBuilder.d.ts.map +1 -0
  294. package/dist/state-machine/StateMachine.d.ts +251 -0
  295. package/dist/state-machine/StateMachine.d.ts.map +1 -0
  296. package/dist/state-machine/guards.d.ts +151 -0
  297. package/dist/state-machine/guards.d.ts.map +1 -0
  298. package/dist/state-machine/index.d.ts +5 -0
  299. package/dist/state-machine/index.d.ts.map +1 -0
  300. package/dist/state-machine/index.js +954 -0
  301. package/dist/state-machine/index.js.map +1 -0
  302. package/dist/state-machine/types.d.ts +65 -0
  303. package/dist/state-machine/types.d.ts.map +1 -0
  304. package/dist/store/DataStore.d.ts +167 -0
  305. package/dist/store/DataStore.d.ts.map +1 -0
  306. package/dist/store/index.d.ts +3 -0
  307. package/dist/store/index.d.ts.map +1 -0
  308. package/dist/store/index.js +197 -0
  309. package/dist/store/index.js.map +1 -0
  310. package/dist/ui/behaviors/ButtonBehavior.d.ts +245 -0
  311. package/dist/ui/behaviors/ButtonBehavior.d.ts.map +1 -0
  312. package/dist/ui/behaviors/InputBehavior.d.ts +169 -0
  313. package/dist/ui/behaviors/InputBehavior.d.ts.map +1 -0
  314. package/dist/ui/behaviors/ScrollbarBehavior.d.ts +371 -0
  315. package/dist/ui/behaviors/ScrollbarBehavior.d.ts.map +1 -0
  316. package/dist/ui/behaviors/index.d.ts +4 -0
  317. package/dist/ui/behaviors/index.d.ts.map +1 -0
  318. package/dist/ui/components/ButtonComp.d.ts +138 -0
  319. package/dist/ui/components/ButtonComp.d.ts.map +1 -0
  320. package/dist/ui/components/Comp.utils.d.ts +390 -0
  321. package/dist/ui/components/Comp.utils.d.ts.map +1 -0
  322. package/dist/ui/components/Component.types.d.ts +41 -0
  323. package/dist/ui/components/Component.types.d.ts.map +1 -0
  324. package/dist/ui/components/InputComp.d.ts +43 -0
  325. package/dist/ui/components/InputComp.d.ts.map +1 -0
  326. package/dist/ui/components/LabelBox.d.ts +49 -0
  327. package/dist/ui/components/LabelBox.d.ts.map +1 -0
  328. package/dist/ui/components/ListTableComp.d.ts +106 -0
  329. package/dist/ui/components/ListTableComp.d.ts.map +1 -0
  330. package/dist/ui/components/Skinable.d.ts +261 -0
  331. package/dist/ui/components/Skinable.d.ts.map +1 -0
  332. package/dist/ui/components/SliderComp.d.ts +60 -0
  333. package/dist/ui/components/SliderComp.d.ts.map +1 -0
  334. package/dist/ui/components/SpriteTextBBCode.d.ts +16 -0
  335. package/dist/ui/components/SpriteTextBBCode.d.ts.map +1 -0
  336. package/dist/ui/components/StepperComp.d.ts +89 -0
  337. package/dist/ui/components/StepperComp.d.ts.map +1 -0
  338. package/dist/ui/components/index.d.ts +12 -0
  339. package/dist/ui/components/index.d.ts.map +1 -0
  340. package/dist/ui/components/spriteText/SpriteText.d.ts +114 -0
  341. package/dist/ui/components/spriteText/SpriteText.d.ts.map +1 -0
  342. package/dist/ui/components/spriteText/SpriteText.types.d.ts +109 -0
  343. package/dist/ui/components/spriteText/SpriteText.types.d.ts.map +1 -0
  344. package/dist/ui/components/spriteText/SpriteTextAlignment.d.ts +25 -0
  345. package/dist/ui/components/spriteText/SpriteTextAlignment.d.ts.map +1 -0
  346. package/dist/ui/components/spriteText/SpriteTextBezier.d.ts +20 -0
  347. package/dist/ui/components/spriteText/SpriteTextBezier.d.ts.map +1 -0
  348. package/dist/ui/components/spriteText/SpriteTextCurve.d.ts +4 -0
  349. package/dist/ui/components/spriteText/SpriteTextCurve.d.ts.map +1 -0
  350. package/dist/ui/components/spriteText/SpriteTextKerning.d.ts +7 -0
  351. package/dist/ui/components/spriteText/SpriteTextKerning.d.ts.map +1 -0
  352. package/dist/ui/components/spriteText/SpriteTextTexture.d.ts +16 -0
  353. package/dist/ui/components/spriteText/SpriteTextTexture.d.ts.map +1 -0
  354. package/dist/ui/components/spriteText/SpriteTextWrap.d.ts +19 -0
  355. package/dist/ui/components/spriteText/SpriteTextWrap.d.ts.map +1 -0
  356. package/dist/ui/components/spriteText/index.d.ts +3 -0
  357. package/dist/ui/components/spriteText/index.d.ts.map +1 -0
  358. package/dist/ui/index.d.ts +3 -0
  359. package/dist/ui/index.d.ts.map +1 -0
  360. package/dist/ui/index.js +4778 -0
  361. package/dist/ui/index.js.map +1 -0
  362. package/dist/utils/ArrayUtils.d.ts +24 -0
  363. package/dist/utils/ArrayUtils.d.ts.map +1 -0
  364. package/dist/utils/ColorUtils.d.ts +34 -0
  365. package/dist/utils/ColorUtils.d.ts.map +1 -0
  366. package/dist/utils/DataInjector.d.ts +67 -0
  367. package/dist/utils/DataInjector.d.ts.map +1 -0
  368. package/dist/utils/Logger.d.ts +332 -0
  369. package/dist/utils/Logger.d.ts.map +1 -0
  370. package/dist/utils/NumberFormatter.d.ts +126 -0
  371. package/dist/utils/NumberFormatter.d.ts.map +1 -0
  372. package/dist/utils/ObjectUtils.d.ts +64 -0
  373. package/dist/utils/ObjectUtils.d.ts.map +1 -0
  374. package/dist/utils/PixiUtils.d.ts +118 -0
  375. package/dist/utils/PixiUtils.d.ts.map +1 -0
  376. package/dist/utils/Throttle.d.ts +103 -0
  377. package/dist/utils/Throttle.d.ts.map +1 -0
  378. package/dist/utils/index.d.ts +9 -0
  379. package/dist/utils/index.d.ts.map +1 -0
  380. package/dist/utils/index.js +899 -0
  381. package/dist/utils/index.js.map +1 -0
  382. package/dist/vite/index.d.ts +3 -0
  383. package/dist/vite/index.d.ts.map +1 -0
  384. package/dist/vite/index.js +126 -0
  385. package/dist/vite/index.js.map +1 -0
  386. package/dist/vite/mergeLocalesPlugin.d.ts +22 -0
  387. package/dist/vite/mergeLocalesPlugin.d.ts.map +1 -0
  388. package/package.json +143 -0
@@ -0,0 +1,2845 @@
1
+ import { Texture, Ticker, Point, Sprite, Container } from 'pixi.js';
2
+ import { Spine } from '@esotericsoftware/spine-pixi-v8';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+
10
+ // particle/ParticleUtils.ts
11
+ var ParticleUtils_exports = {};
12
+ __export(ParticleUtils_exports, {
13
+ DEG_TO_RADS: () => DEG_TO_RADS,
14
+ GetTextureFromString: () => GetTextureFromString,
15
+ combineRGBComponents: () => combineRGBComponents,
16
+ createSteppedGradient: () => createSteppedGradient,
17
+ generateEase: () => generateEase,
18
+ getBlendMode: () => getBlendMode,
19
+ hexToRGB: () => hexToRGB,
20
+ length: () => length,
21
+ normalize: () => normalize,
22
+ rotatePoint: () => rotatePoint,
23
+ scaleBy: () => scaleBy,
24
+ verbose: () => verbose
25
+ });
26
+
27
+ // particle/PropertyNode.ts
28
+ var PropertyNode = class _PropertyNode {
29
+ /**
30
+ * Value for the node.
31
+ */
32
+ value;
33
+ /**
34
+ * Time value for the node. Between 0-1.
35
+ */
36
+ time;
37
+ /**
38
+ * The next node in line.
39
+ */
40
+ next;
41
+ /**
42
+ * If this is the first node in the list, controls if the entire list is stepped or not.
43
+ */
44
+ isStepped;
45
+ ease;
46
+ /**
47
+ * @param value The value for this node
48
+ * @param time The time for this node, between 0-1
49
+ * @param [ease] Custom ease for this list. Only relevant for the first node.
50
+ */
51
+ constructor(value, time, ease) {
52
+ this.value = value;
53
+ this.time = time;
54
+ this.next = null;
55
+ this.isStepped = false;
56
+ if (ease) {
57
+ this.ease = typeof ease === "function" ? ease : generateEase(ease);
58
+ } else {
59
+ this.ease = null;
60
+ }
61
+ }
62
+ /**
63
+ * Creates a list of property values from a data object {list, isStepped} with a list of objects in
64
+ * the form {value, time}. Alternatively, the data object can be in the deprecated form of
65
+ * {start, end}.
66
+ * @param data The data for the list.
67
+ * @param data.list The array of value and time objects.
68
+ * @param data.isStepped If the list is stepped rather than interpolated.
69
+ * @param data.ease Custom ease for this list.
70
+ * @return The first node in the list
71
+ */
72
+ // eslint-disable-next-line max-len
73
+ static createList(data) {
74
+ if ("list" in data) {
75
+ const array = data.list;
76
+ let node;
77
+ const { value, time } = array[0];
78
+ const first = node = new _PropertyNode(typeof value === "string" ? hexToRGB(value) : value, time, data.ease);
79
+ if (array.length > 2 || array.length === 2 && array[1].value !== value) {
80
+ for (let i = 1; i < array.length; ++i) {
81
+ const { value: value2, time: time2 } = array[i];
82
+ node.next = new _PropertyNode(typeof value2 === "string" ? hexToRGB(value2) : value2, time2);
83
+ node = node.next;
84
+ }
85
+ }
86
+ first.isStepped = !!data.isStepped;
87
+ return first;
88
+ }
89
+ const start = new _PropertyNode(typeof data.start === "string" ? hexToRGB(data.start) : data.start, 0);
90
+ if (data.end !== data.start) {
91
+ start.next = new _PropertyNode(typeof data.end === "string" ? hexToRGB(data.end) : data.end, 1);
92
+ }
93
+ return start;
94
+ }
95
+ };
96
+
97
+ // particle/ParticleUtils.ts
98
+ var GetTextureFromString = Texture.from;
99
+ var verbose = false;
100
+ var DEG_TO_RADS = Math.PI / 180;
101
+ function rotatePoint(angle, p) {
102
+ if (!angle) return;
103
+ const s = Math.sin(angle);
104
+ const c = Math.cos(angle);
105
+ const xnew = p.x * c - p.y * s;
106
+ const ynew = p.x * s + p.y * c;
107
+ p.x = xnew;
108
+ p.y = ynew;
109
+ }
110
+ function combineRGBComponents(r, g, b) {
111
+ return (
112
+ /* a << 24 |*/
113
+ r << 16 | g << 8 | b
114
+ );
115
+ }
116
+ function length(point) {
117
+ return Math.sqrt(point.x * point.x + point.y * point.y);
118
+ }
119
+ function normalize(point) {
120
+ const oneOverLen = 1 / length(point);
121
+ point.x *= oneOverLen;
122
+ point.y *= oneOverLen;
123
+ }
124
+ function scaleBy(point, value) {
125
+ point.x *= value;
126
+ point.y *= value;
127
+ }
128
+ function hexToRGB(color, output) {
129
+ if (!output) {
130
+ output = {};
131
+ }
132
+ if (color.charAt(0) === "#") {
133
+ color = color.substr(1);
134
+ } else if (color.indexOf("0x") === 0) {
135
+ color = color.substr(2);
136
+ }
137
+ let alpha;
138
+ if (color.length === 8) {
139
+ alpha = color.substr(0, 2);
140
+ color = color.substr(2);
141
+ }
142
+ output.r = parseInt(color.substr(0, 2), 16);
143
+ output.g = parseInt(color.substr(2, 2), 16);
144
+ output.b = parseInt(color.substr(4, 2), 16);
145
+ if (alpha) {
146
+ output.a = parseInt(alpha, 16);
147
+ }
148
+ return output;
149
+ }
150
+ function generateEase(segments) {
151
+ const qty = segments.length;
152
+ const oneOverQty = 1 / qty;
153
+ return function(time) {
154
+ const i = qty * time | 0;
155
+ const t = (time - i * oneOverQty) * qty;
156
+ const s = segments[i] || segments[qty - 1];
157
+ return s.s + t * (2 * (1 - t) * (s.cp - s.s) + t * (s.e - s.s));
158
+ };
159
+ }
160
+ function getBlendMode(name) {
161
+ if (!name) return "normal";
162
+ return name;
163
+ }
164
+ function createSteppedGradient(list, numSteps = 10) {
165
+ if (typeof numSteps !== "number" || numSteps <= 0) {
166
+ numSteps = 10;
167
+ }
168
+ const first = new PropertyNode(hexToRGB(list[0].value), list[0].time);
169
+ first.isStepped = true;
170
+ let currentNode = first;
171
+ let current = list[0];
172
+ let nextIndex = 1;
173
+ let next = list[nextIndex];
174
+ for (let i = 1; i < numSteps; ++i) {
175
+ let lerp = i / numSteps;
176
+ while (lerp > next.time) {
177
+ current = next;
178
+ next = list[++nextIndex];
179
+ }
180
+ lerp = (lerp - current.time) / (next.time - current.time);
181
+ const curVal = hexToRGB(current.value);
182
+ const nextVal = hexToRGB(next.value);
183
+ const output = {
184
+ r: (nextVal.r - curVal.r) * lerp + curVal.r,
185
+ g: (nextVal.g - curVal.g) * lerp + curVal.g,
186
+ b: (nextVal.b - curVal.b) * lerp + curVal.b
187
+ };
188
+ currentNode.next = new PropertyNode(output, i / numSteps);
189
+ currentNode = currentNode.next;
190
+ }
191
+ return first;
192
+ }
193
+ var Particle = class extends Sprite {
194
+ /**
195
+ * The emitter that controls this particle.
196
+ */
197
+ emitter;
198
+ /**
199
+ * The maximum lifetime of this particle, in seconds.
200
+ */
201
+ maxLife;
202
+ /**
203
+ * The current age of the particle, in seconds.
204
+ */
205
+ age;
206
+ /**
207
+ * The current age of the particle as a normalized value between 0 and 1.
208
+ */
209
+ agePercent;
210
+ /**
211
+ * One divided by the max life of the particle, saved for slightly faster math.
212
+ */
213
+ oneOverLife;
214
+ /**
215
+ * Reference to the next particle in the list.
216
+ */
217
+ next;
218
+ /**
219
+ * Reference to the previous particle in the list.
220
+ */
221
+ prev;
222
+ prevChild;
223
+ nextChild;
224
+ /**
225
+ * Static per-particle configuration for behaviors to use. Is not cleared when recycling.
226
+ */
227
+ config;
228
+ /**
229
+ * @param emitter The emitter that controls this particle.
230
+ */
231
+ constructor(emitter) {
232
+ super();
233
+ this.prevChild = this.nextChild = null;
234
+ this.emitter = emitter;
235
+ this.config = {};
236
+ this.anchor.x = this.anchor.y = 0.5;
237
+ this.maxLife = 0;
238
+ this.age = 0;
239
+ this.agePercent = 0;
240
+ this.oneOverLife = 0;
241
+ this.next = null;
242
+ this.prev = null;
243
+ this.init = this.init;
244
+ this.kill = this.kill;
245
+ }
246
+ /**
247
+ * Initializes the particle for use, based on the properties that have to
248
+ * have been set already on the particle.
249
+ */
250
+ init(maxLife) {
251
+ this.maxLife = maxLife;
252
+ this.age = this.agePercent = 0;
253
+ this.rotation = 0;
254
+ this.position.x = this.position.y = 0;
255
+ this.scale.x = this.scale.y = 1;
256
+ this.tint = 16777215;
257
+ this.alpha = 1;
258
+ this.oneOverLife = 1 / this.maxLife;
259
+ this.visible = true;
260
+ }
261
+ /**
262
+ * Kills the particle, removing it from the display list
263
+ * and telling the emitter to recycle it.
264
+ */
265
+ kill() {
266
+ this.emitter.recycle(this);
267
+ }
268
+ /**
269
+ * Destroys the particle, removing references and preventing future use.
270
+ */
271
+ destroy() {
272
+ if (this.parent) {
273
+ this.parent.removeChild(this);
274
+ }
275
+ this.emitter = this.next = this.prev = null;
276
+ super.destroy();
277
+ }
278
+ };
279
+
280
+ // particle/behaviors/Behaviors.ts
281
+ var BehaviorOrder = /* @__PURE__ */ ((BehaviorOrder2) => {
282
+ BehaviorOrder2[BehaviorOrder2["Spawn"] = 0] = "Spawn";
283
+ BehaviorOrder2[BehaviorOrder2["Normal"] = 2] = "Normal";
284
+ BehaviorOrder2[BehaviorOrder2["Late"] = 5] = "Late";
285
+ return BehaviorOrder2;
286
+ })(BehaviorOrder || {});
287
+ var ticker = Ticker.shared;
288
+ var PositionParticle = Symbol("Position particle per emitter position");
289
+ var Emitter = class _Emitter {
290
+ static knownBehaviors = {};
291
+ /**
292
+ * Registers a new behavior, so that it will be recognized when initializing emitters.
293
+ * Behaviors registered later with duplicate types will override older ones, although there is no limit on
294
+ * the allowed types.
295
+ * @param constructor The behavior class to register.
296
+ */
297
+ static registerBehavior(constructor) {
298
+ _Emitter.knownBehaviors[constructor.type] = constructor;
299
+ }
300
+ /**
301
+ * Active initialization behaviors for this emitter.
302
+ */
303
+ initBehaviors;
304
+ /**
305
+ * Active update behaviors for this emitter.
306
+ */
307
+ updateBehaviors;
308
+ /**
309
+ * Active recycle behaviors for this emitter.
310
+ */
311
+ recycleBehaviors;
312
+ // properties for individual particles
313
+ /**
314
+ * The minimum lifetime for a particle, in seconds.
315
+ */
316
+ minLifetime;
317
+ /**
318
+ * The maximum lifetime for a particle, in seconds.
319
+ */
320
+ maxLifetime;
321
+ /**
322
+ * An easing function for nonlinear interpolation of values. Accepts a single
323
+ * parameter of time as a value from 0-1, inclusive. Expected outputs are values
324
+ * from 0-1, inclusive.
325
+ */
326
+ customEase;
327
+ // properties for spawning particles
328
+ /**
329
+ * Time between particle spawns in seconds.
330
+ */
331
+ _frequency;
332
+ /**
333
+ * Chance that a particle will be spawned on each opportunity to spawn one.
334
+ * 0 is 0%, 1 is 100%.
335
+ */
336
+ spawnChance;
337
+ /**
338
+ * Maximum number of particles to keep alive at a time. If this limit
339
+ * is reached, no more particles will spawn until some have died.
340
+ */
341
+ maxParticles;
342
+ /**
343
+ * The amount of time in seconds to emit for before setting emit to false.
344
+ * A value of -1 is an unlimited amount of time.
345
+ */
346
+ emitterLifetime;
347
+ /**
348
+ * Position at which to spawn particles, relative to the emitter's owner's origin.
349
+ * For example, the flames of a rocket travelling right might have a spawnPos
350
+ * of {x:-50, y:0}.
351
+ * to spawn at the rear of the rocket.
352
+ * To change this, use updateSpawnPos().
353
+ */
354
+ spawnPos;
355
+ /**
356
+ * Number of particles to spawn time that the frequency allows for particles to spawn.
357
+ */
358
+ particlesPerWave;
359
+ /**
360
+ * Rotation of the emitter or emitter's owner in degrees. This is added to
361
+ * the calculated spawn angle.
362
+ * To change this, use rotate().
363
+ */
364
+ rotation;
365
+ /**
366
+ * The world position of the emitter's owner, to add spawnPos to when
367
+ * spawning particles. To change this, use updateOwnerPos().
368
+ */
369
+ ownerPos;
370
+ /**
371
+ * The origin + spawnPos in the previous update, so that the spawn position
372
+ * can be interpolated to space out particles better.
373
+ */
374
+ _prevEmitterPos;
375
+ /**
376
+ * If _prevEmitterPos is valid, to prevent interpolation on the first update
377
+ */
378
+ _prevPosIsValid;
379
+ /**
380
+ * If either ownerPos or spawnPos has changed since the previous update.
381
+ */
382
+ _posChanged;
383
+ /**
384
+ * The container to add particles to.
385
+ */
386
+ _parent;
387
+ /**
388
+ * If particles should be added at the back of the display list instead of the front.
389
+ */
390
+ addAtBack;
391
+ /**
392
+ * The current number of active particles.
393
+ */
394
+ particleCount;
395
+ /**
396
+ * If particles should be emitted during update() calls. Setting this to false
397
+ * stops new particles from being created, but allows existing ones to die out.
398
+ */
399
+ _emit;
400
+ /**
401
+ * The timer for when to spawn particles in seconds, where numbers less
402
+ * than 0 mean that particles should be spawned.
403
+ */
404
+ _spawnTimer;
405
+ /**
406
+ * The life of the emitter in seconds.
407
+ */
408
+ _emitterLife;
409
+ /**
410
+ * The particles that are active and on the display list. This is the first particle in a
411
+ * linked list.
412
+ */
413
+ _activeParticlesFirst;
414
+ /**
415
+ * The particles that are active and on the display list. This is the last particle in a
416
+ * linked list.
417
+ */
418
+ _activeParticlesLast;
419
+ /**
420
+ * The particles that are not currently being used. This is the first particle in a
421
+ * linked list.
422
+ */
423
+ _poolFirst;
424
+ /**
425
+ * The original config object that this emitter was initialized with.
426
+ */
427
+ _origConfig;
428
+ /**
429
+ * If the update function is called automatically from the shared ticker.
430
+ * Setting this to false requires calling the update function manually.
431
+ */
432
+ _autoUpdate;
433
+ /**
434
+ * If the emitter should destroy itself when all particles have died out. This is set by
435
+ * playOnceAndDestroy();
436
+ */
437
+ _destroyWhenComplete;
438
+ /**
439
+ * A callback for when all particles have died out. This is set by
440
+ * playOnceAndDestroy() or playOnce();
441
+ */
442
+ _completeCallback;
443
+ /**
444
+ * Factory method to create a new particle. Override this in subclasses
445
+ * to create custom particle types (e.g., SpineParticle).
446
+ */
447
+ createParticle() {
448
+ return new Particle(this);
449
+ }
450
+ /**
451
+ * @param particleParent The container to add the particles to.
452
+ * @param particleImages A texture or array of textures to use
453
+ * for the particles. Strings will be turned
454
+ * into textures via Texture.from().
455
+ * @param config A configuration object containing settings for the emitter.
456
+ * @param config.emit If config.emit is explicitly passed as false, the
457
+ * Emitter will start disabled.
458
+ * @param config.autoUpdate If config.autoUpdate is explicitly passed as
459
+ * true, the Emitter will automatically call
460
+ * update via the PIXI shared ticker.
461
+ */
462
+ constructor(particleParent, config) {
463
+ this.initBehaviors = [];
464
+ this.updateBehaviors = [];
465
+ this.recycleBehaviors = [];
466
+ this.minLifetime = 0;
467
+ this.maxLifetime = 0;
468
+ this.customEase = null;
469
+ this._frequency = 1;
470
+ this.spawnChance = 1;
471
+ this.maxParticles = 1e3;
472
+ this.emitterLifetime = -1;
473
+ this.spawnPos = new Point();
474
+ this.particlesPerWave = 1;
475
+ this.rotation = 0;
476
+ this.ownerPos = new Point();
477
+ this._prevEmitterPos = new Point();
478
+ this._prevPosIsValid = false;
479
+ this._posChanged = false;
480
+ this._parent = null;
481
+ this.addAtBack = false;
482
+ this.particleCount = 0;
483
+ this._emit = false;
484
+ this._spawnTimer = 0;
485
+ this._emitterLife = -1;
486
+ this._activeParticlesFirst = null;
487
+ this._activeParticlesLast = null;
488
+ this._poolFirst = null;
489
+ this._origConfig = null;
490
+ this._autoUpdate = false;
491
+ this._destroyWhenComplete = false;
492
+ this._completeCallback = null;
493
+ this.parent = particleParent;
494
+ if (config) {
495
+ this.init(config);
496
+ }
497
+ this.recycle = this.recycle;
498
+ this.update = this.update;
499
+ this.rotate = this.rotate;
500
+ this.updateSpawnPos = this.updateSpawnPos;
501
+ this.updateOwnerPos = this.updateOwnerPos;
502
+ }
503
+ /**
504
+ * Time between particle spawns in seconds. If this value is not a number greater than 0,
505
+ * it will be set to 1 (particle per second) to prevent infinite loops.
506
+ */
507
+ get frequency() {
508
+ return this._frequency;
509
+ }
510
+ set frequency(value) {
511
+ if (typeof value === "number" && value > 0) {
512
+ this._frequency = value;
513
+ } else {
514
+ this._frequency = 1;
515
+ }
516
+ }
517
+ /**
518
+ * The container to add particles to. Settings this will dump any active particles.
519
+ */
520
+ get parent() {
521
+ return this._parent;
522
+ }
523
+ set parent(value) {
524
+ this.cleanup();
525
+ this._parent = value;
526
+ }
527
+ /**
528
+ * Sets up the emitter based on the config settings.
529
+ * @param config A configuration object containing settings for the emitter.
530
+ */
531
+ init(config) {
532
+ if (!config) {
533
+ return;
534
+ }
535
+ this.cleanup();
536
+ this._origConfig = config;
537
+ this.minLifetime = config.lifetime.min;
538
+ this.maxLifetime = config.lifetime.max;
539
+ if (config.ease) {
540
+ this.customEase = typeof config.ease === "function" ? config.ease : generateEase(config.ease);
541
+ } else {
542
+ this.customEase = null;
543
+ }
544
+ this.particlesPerWave = 1;
545
+ if (config.particlesPerWave && config.particlesPerWave > 1) {
546
+ this.particlesPerWave = config.particlesPerWave;
547
+ }
548
+ this.frequency = config.frequency;
549
+ this.spawnChance = typeof config.spawnChance === "number" && config.spawnChance > 0 ? config.spawnChance : 1;
550
+ this.emitterLifetime = config.emitterLifetime || -1;
551
+ this.maxParticles = config.maxParticles ?? 1e3;
552
+ this.addAtBack = !!config.addAtBack;
553
+ this.rotation = 0;
554
+ this.ownerPos.set(0);
555
+ if (config.pos) {
556
+ this.spawnPos.copyFrom(config.pos);
557
+ } else {
558
+ this.spawnPos.set(0);
559
+ }
560
+ this._prevEmitterPos.copyFrom(this.spawnPos);
561
+ this._prevPosIsValid = false;
562
+ this._spawnTimer = 0;
563
+ this.emit = config.emit === void 0 ? true : !!config.emit;
564
+ this.autoUpdate = !!config.autoUpdate;
565
+ const behaviors = config.behaviors.map((data) => {
566
+ const constructor = _Emitter.knownBehaviors[data.type];
567
+ if (!constructor) {
568
+ console.error(`Unknown behavior: ${data.type}`);
569
+ return null;
570
+ }
571
+ return new constructor(data.config);
572
+ }).filter((b) => !!b);
573
+ behaviors.push(PositionParticle);
574
+ behaviors.sort((a, b) => {
575
+ if (a === PositionParticle) {
576
+ return b.order === 0 /* Spawn */ ? 1 : -1;
577
+ } else if (b === PositionParticle) {
578
+ return a.order === 0 /* Spawn */ ? -1 : 1;
579
+ }
580
+ return a.order - b.order;
581
+ });
582
+ this.initBehaviors = behaviors.slice();
583
+ this.updateBehaviors = behaviors.filter((b) => b !== PositionParticle && b.updateParticle);
584
+ this.recycleBehaviors = behaviors.filter((b) => b !== PositionParticle && b.recycleParticle);
585
+ }
586
+ /**
587
+ * Gets the instantiated behavior of the specified type, if it is present on this emitter.
588
+ * @param type The behavior type to find.
589
+ */
590
+ getBehavior(type) {
591
+ if (!_Emitter.knownBehaviors[type]) return null;
592
+ return this.initBehaviors.find((b) => b instanceof _Emitter.knownBehaviors[type]) || null;
593
+ }
594
+ /**
595
+ * Fills the pool with the specified number of particles, so that they don't have to be instantiated later.
596
+ * @param count The number of particles to create.
597
+ */
598
+ fillPool(count) {
599
+ for (; count > 0; --count) {
600
+ const p = new Particle(this);
601
+ p.next = this._poolFirst;
602
+ this._poolFirst = p;
603
+ }
604
+ }
605
+ /**
606
+ * Recycles an individual particle. For internal use only.
607
+ * @param particle The particle to recycle.
608
+ * @param fromCleanup If this is being called to manually clean up all particles.
609
+ * @internal
610
+ */
611
+ recycle(particle, fromCleanup = false) {
612
+ var _a, _b;
613
+ for (let i = 0; i < this.recycleBehaviors.length; ++i) {
614
+ (_b = (_a = this.recycleBehaviors[i]).recycleParticle) == null ? void 0 : _b.call(_a, particle, !fromCleanup);
615
+ }
616
+ if (particle.next) {
617
+ particle.next.prev = particle.prev;
618
+ }
619
+ if (particle.prev) {
620
+ particle.prev.next = particle.next;
621
+ }
622
+ if (particle === this._activeParticlesLast) {
623
+ this._activeParticlesLast = particle.prev;
624
+ }
625
+ if (particle === this._activeParticlesFirst) {
626
+ this._activeParticlesFirst = particle.next;
627
+ }
628
+ particle.prev = null;
629
+ particle.next = this._poolFirst;
630
+ this._poolFirst = particle;
631
+ if (particle.parent) {
632
+ particle.parent.removeChild(particle);
633
+ }
634
+ --this.particleCount;
635
+ }
636
+ /**
637
+ * Sets the rotation of the emitter to a new value. This rotates the spawn position in addition
638
+ * to particle direction.
639
+ * @param newRot The new rotation, in degrees.
640
+ */
641
+ rotate(newRot) {
642
+ if (this.rotation === newRot) return;
643
+ const diff = newRot - this.rotation;
644
+ this.rotation = newRot;
645
+ rotatePoint(diff, this.spawnPos);
646
+ this._posChanged = true;
647
+ }
648
+ /**
649
+ * Changes the spawn position of the emitter.
650
+ * @param x The new x value of the spawn position for the emitter.
651
+ * @param y The new y value of the spawn position for the emitter.
652
+ */
653
+ updateSpawnPos(x, y) {
654
+ this._posChanged = true;
655
+ this.spawnPos.x = x;
656
+ this.spawnPos.y = y;
657
+ }
658
+ /**
659
+ * Changes the position of the emitter's owner. You should call this if you are adding
660
+ * particles to the world container that your emitter's owner is moving around in.
661
+ * @param x The new x value of the emitter's owner.
662
+ * @param y The new y value of the emitter's owner.
663
+ */
664
+ updateOwnerPos(x, y) {
665
+ this._posChanged = true;
666
+ this.ownerPos.x = x;
667
+ this.ownerPos.y = y;
668
+ }
669
+ /**
670
+ * Prevents emitter position interpolation in the next update.
671
+ * This should be used if you made a major position change of your emitter's owner
672
+ * that was not normal movement.
673
+ */
674
+ resetPositionTracking() {
675
+ this._prevPosIsValid = false;
676
+ }
677
+ /**
678
+ * If particles should be emitted during update() calls. Setting this to false
679
+ * stops new particles from being created, but allows existing ones to die out.
680
+ */
681
+ get emit() {
682
+ return this._emit;
683
+ }
684
+ set emit(value) {
685
+ this._emit = !!value;
686
+ this._emitterLife = this.emitterLifetime;
687
+ }
688
+ /**
689
+ * If the update function is called automatically from the shared ticker.
690
+ * Setting this to false requires calling the update function manually.
691
+ */
692
+ get autoUpdate() {
693
+ return this._autoUpdate;
694
+ }
695
+ set autoUpdate(value) {
696
+ if (this._autoUpdate && !value) {
697
+ ticker.remove(this._update, this);
698
+ } else if (!this._autoUpdate && value) {
699
+ ticker.add(this._update, this);
700
+ }
701
+ this._autoUpdate = !!value;
702
+ }
703
+ /**
704
+ * Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself
705
+ * when particle emission is complete.
706
+ * @param callback Callback for when emission is complete (all particles have died off)
707
+ */
708
+ playOnceAndDestroy(callback) {
709
+ this.autoUpdate = true;
710
+ this.emit = true;
711
+ this._destroyWhenComplete = true;
712
+ this._completeCallback = callback;
713
+ }
714
+ /**
715
+ * Starts emitting particles and optionally calls a callback when particle emission is complete.
716
+ * @param callback Callback for when emission is complete (all particles have died off)
717
+ */
718
+ playOnce(callback) {
719
+ this.emit = true;
720
+ this._completeCallback = callback;
721
+ }
722
+ _update(ticker2) {
723
+ this.update(ticker2.deltaTime);
724
+ }
725
+ /**
726
+ * Updates all particles spawned by this emitter and emits new ones.
727
+ * @param delta Time elapsed since the previous frame, in __seconds__.
728
+ */
729
+ update(delta) {
730
+ if (this._autoUpdate) {
731
+ delta = ticker.elapsedMS * 1e-3;
732
+ }
733
+ if (!this._parent) return;
734
+ for (let particle = this._activeParticlesFirst, next; particle; particle = next) {
735
+ next = particle.next;
736
+ particle.age += delta;
737
+ if (particle.age > particle.maxLife || particle.age < 0) {
738
+ this.recycle(particle);
739
+ } else {
740
+ let lerp = particle.age * particle.oneOverLife;
741
+ if (this.customEase) {
742
+ if (this.customEase.length === 4) {
743
+ lerp = this.customEase(lerp, 0, 1, 1);
744
+ } else {
745
+ lerp = this.customEase(lerp);
746
+ }
747
+ }
748
+ particle.agePercent = lerp;
749
+ for (let i = 0; i < this.updateBehaviors.length; ++i) {
750
+ if (this.updateBehaviors[i].updateParticle(particle, delta)) {
751
+ this.recycle(particle);
752
+ break;
753
+ }
754
+ }
755
+ }
756
+ }
757
+ let prevX = 0;
758
+ let prevY = 0;
759
+ if (this._prevPosIsValid) {
760
+ prevX = this._prevEmitterPos.x;
761
+ prevY = this._prevEmitterPos.y;
762
+ }
763
+ const curX = this.ownerPos.x + this.spawnPos.x;
764
+ const curY = this.ownerPos.y + this.spawnPos.y;
765
+ if (this._emit) {
766
+ this._spawnTimer -= delta < 0 ? 0 : delta;
767
+ while (this._spawnTimer <= 0) {
768
+ if (this._emitterLife >= 0) {
769
+ this._emitterLife -= this._frequency;
770
+ if (this._emitterLife <= 0) {
771
+ this._spawnTimer = 0;
772
+ this._emitterLife = 0;
773
+ this.emit = false;
774
+ break;
775
+ }
776
+ }
777
+ if (this.particleCount >= this.maxParticles) {
778
+ this._spawnTimer += this._frequency;
779
+ continue;
780
+ }
781
+ let emitPosX;
782
+ let emitPosY;
783
+ if (this._prevPosIsValid && this._posChanged) {
784
+ const lerp = 1 + this._spawnTimer / delta;
785
+ emitPosX = (curX - prevX) * lerp + prevX;
786
+ emitPosY = (curY - prevY) * lerp + prevY;
787
+ } else {
788
+ emitPosX = curX;
789
+ emitPosY = curY;
790
+ }
791
+ let waveFirst = null;
792
+ let waveLast = null;
793
+ for (let len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount), i = 0; i < len; ++i) {
794
+ if (this.spawnChance < 1 && Math.random() >= this.spawnChance) {
795
+ continue;
796
+ }
797
+ let lifetime;
798
+ if (this.minLifetime === this.maxLifetime) {
799
+ lifetime = this.minLifetime;
800
+ } else {
801
+ lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime;
802
+ }
803
+ if (-this._spawnTimer >= lifetime) {
804
+ continue;
805
+ }
806
+ let p;
807
+ if (this._poolFirst) {
808
+ p = this._poolFirst;
809
+ this._poolFirst = this._poolFirst.next;
810
+ p.next = null;
811
+ } else {
812
+ p = this.createParticle();
813
+ }
814
+ p.init(lifetime);
815
+ if (this.addAtBack) {
816
+ this._parent.addChildAt(p, 0);
817
+ } else {
818
+ this._parent.addChild(p);
819
+ }
820
+ if (waveFirst) {
821
+ waveLast.next = p;
822
+ p.prev = waveLast;
823
+ waveLast = p;
824
+ } else {
825
+ waveLast = waveFirst = p;
826
+ }
827
+ ++this.particleCount;
828
+ }
829
+ if (waveFirst) {
830
+ if (this._activeParticlesLast) {
831
+ this._activeParticlesLast.next = waveFirst;
832
+ waveFirst.prev = this._activeParticlesLast;
833
+ this._activeParticlesLast = waveLast;
834
+ } else {
835
+ this._activeParticlesFirst = waveFirst;
836
+ this._activeParticlesLast = waveLast;
837
+ }
838
+ for (let i = 0; i < this.initBehaviors.length; ++i) {
839
+ const behavior = this.initBehaviors[i];
840
+ if (behavior === PositionParticle) {
841
+ for (let particle = waveFirst, next; particle; particle = next) {
842
+ next = particle.next;
843
+ if (this.rotation !== 0) {
844
+ rotatePoint(this.rotation, particle.position);
845
+ particle.rotation += this.rotation;
846
+ }
847
+ particle.position.x += emitPosX;
848
+ particle.position.y += emitPosY;
849
+ particle.age += -this._spawnTimer;
850
+ let lerp = particle.age * particle.oneOverLife;
851
+ if (this.customEase) {
852
+ if (this.customEase.length === 4) {
853
+ lerp = this.customEase(lerp, 0, 1, 1);
854
+ } else {
855
+ lerp = this.customEase(lerp);
856
+ }
857
+ }
858
+ particle.agePercent = lerp;
859
+ }
860
+ } else {
861
+ behavior.initParticles(waveFirst);
862
+ }
863
+ }
864
+ for (let particle = waveFirst, next; particle; particle = next) {
865
+ next = particle.next;
866
+ for (let i = 0; i < this.updateBehaviors.length; ++i) {
867
+ if (this.updateBehaviors[i].updateParticle(particle, -this._spawnTimer)) {
868
+ this.recycle(particle);
869
+ break;
870
+ }
871
+ }
872
+ }
873
+ }
874
+ this._spawnTimer += this._frequency;
875
+ }
876
+ }
877
+ if (this._posChanged) {
878
+ this._prevEmitterPos.x = curX;
879
+ this._prevEmitterPos.y = curY;
880
+ this._prevPosIsValid = true;
881
+ this._posChanged = false;
882
+ }
883
+ if (!this._emit && !this._activeParticlesFirst) {
884
+ if (this._completeCallback) {
885
+ const cb = this._completeCallback;
886
+ this._completeCallback = null;
887
+ cb();
888
+ }
889
+ if (this._destroyWhenComplete) {
890
+ this.destroy();
891
+ }
892
+ }
893
+ }
894
+ /**
895
+ * Emits a single wave of particles, using standard spawnChance & particlesPerWave settings. Does not affect
896
+ * regular spawning through the frequency, and ignores the emit property. The max particle count is respected, however,
897
+ * so if there are already too many particles then nothing will happen.
898
+ */
899
+ emitNow() {
900
+ const emitPosX = this.ownerPos.x + this.spawnPos.x;
901
+ const emitPosY = this.ownerPos.y + this.spawnPos.y;
902
+ let waveFirst = null;
903
+ let waveLast = null;
904
+ for (let len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount), i = 0; i < len; ++i) {
905
+ if (this.spawnChance < 1 && Math.random() >= this.spawnChance) {
906
+ continue;
907
+ }
908
+ let p;
909
+ if (this._poolFirst) {
910
+ p = this._poolFirst;
911
+ this._poolFirst = this._poolFirst.next;
912
+ p.next = null;
913
+ } else {
914
+ p = this.createParticle();
915
+ }
916
+ let lifetime;
917
+ if (this.minLifetime === this.maxLifetime) {
918
+ lifetime = this.minLifetime;
919
+ } else {
920
+ lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime;
921
+ }
922
+ p.init(lifetime);
923
+ if (this.addAtBack) {
924
+ this._parent.addChildAt(p, 0);
925
+ } else {
926
+ this._parent.addChild(p);
927
+ }
928
+ if (waveFirst) {
929
+ waveLast.next = p;
930
+ p.prev = waveLast;
931
+ waveLast = p;
932
+ } else {
933
+ waveLast = waveFirst = p;
934
+ }
935
+ ++this.particleCount;
936
+ }
937
+ if (waveFirst) {
938
+ if (this._activeParticlesLast) {
939
+ this._activeParticlesLast.next = waveFirst;
940
+ waveFirst.prev = this._activeParticlesLast;
941
+ this._activeParticlesLast = waveLast;
942
+ } else {
943
+ this._activeParticlesFirst = waveFirst;
944
+ this._activeParticlesLast = waveLast;
945
+ }
946
+ for (let i = 0; i < this.initBehaviors.length; ++i) {
947
+ const behavior = this.initBehaviors[i];
948
+ if (behavior === PositionParticle) {
949
+ for (let particle = waveFirst, next; particle; particle = next) {
950
+ next = particle.next;
951
+ if (this.rotation !== 0) {
952
+ rotatePoint(this.rotation, particle.position);
953
+ particle.rotation += this.rotation;
954
+ }
955
+ particle.position.x += emitPosX;
956
+ particle.position.y += emitPosY;
957
+ }
958
+ } else {
959
+ behavior.initParticles(waveFirst);
960
+ }
961
+ }
962
+ }
963
+ }
964
+ /**
965
+ * Kills all active particles immediately.
966
+ */
967
+ cleanup() {
968
+ let particle;
969
+ let next;
970
+ for (particle = this._activeParticlesFirst; particle; particle = next) {
971
+ next = particle.next;
972
+ this.recycle(particle, true);
973
+ }
974
+ this._activeParticlesFirst = this._activeParticlesLast = null;
975
+ this.particleCount = 0;
976
+ }
977
+ /**
978
+ * If this emitter has been destroyed. Note that a destroyed emitter can still be reused, after
979
+ * having a new parent set and being reinitialized.
980
+ */
981
+ get destroyed() {
982
+ return !(this._parent && this.initBehaviors.length);
983
+ }
984
+ /**
985
+ * Destroys the emitter and all of its particles.
986
+ */
987
+ destroy() {
988
+ this.autoUpdate = false;
989
+ this.cleanup();
990
+ let next;
991
+ for (let particle = this._poolFirst; particle; particle = next) {
992
+ next = particle.next;
993
+ particle.destroy();
994
+ }
995
+ this._poolFirst = this._parent = this.spawnPos = this.ownerPos = this.customEase = this._completeCallback = null;
996
+ this.initBehaviors.length = this.updateBehaviors.length = this.recycleBehaviors.length = 0;
997
+ }
998
+ };
999
+
1000
+ // particle/behaviors/index.ts
1001
+ var behaviors_exports = {};
1002
+ __export(behaviors_exports, {
1003
+ AccelerationBehavior: () => AccelerationBehavior,
1004
+ AlphaBehavior: () => AlphaBehavior,
1005
+ BehaviorOrder: () => BehaviorOrder,
1006
+ BlendModeBehavior: () => BlendModeBehavior,
1007
+ BurstSpawnBehavior: () => BurstSpawnBehavior,
1008
+ ColorBehavior: () => ColorBehavior,
1009
+ MultiStateAnimatedTextureBehavior: () => MultiStateAnimatedTextureBehavior,
1010
+ NoRotationBehavior: () => NoRotationBehavior,
1011
+ OrderedTextureBehavior: () => OrderedTextureBehavior,
1012
+ PathBehavior: () => PathBehavior,
1013
+ PointSpawnBehavior: () => PointSpawnBehavior,
1014
+ RandomAnimatedTextureBehavior: () => RandomAnimatedTextureBehavior,
1015
+ RandomColor: () => RandomColor,
1016
+ RandomTextureBehavior: () => RandomTextureBehavior,
1017
+ RotationBehavior: () => RotationBehavior,
1018
+ ScaleBehavior: () => ScaleBehavior,
1019
+ ShapeSpawnBehavior: () => ShapeSpawnBehavior,
1020
+ SingleAnimatedTextureBehavior: () => SingleAnimatedTextureBehavior,
1021
+ SingleTextureBehavior: () => SingleTextureBehavior,
1022
+ SpeedBehavior: () => SpeedBehavior,
1023
+ SpineAnimationBehavior: () => SpineAnimationBehavior,
1024
+ SpineAnimationSequenceBehavior: () => SpineAnimationSequenceBehavior,
1025
+ SpineRandomSkinBehavior: () => SpineRandomSkinBehavior,
1026
+ StaticAlphaBehavior: () => StaticAlphaBehavior,
1027
+ StaticColorBehavior: () => StaticColorBehavior,
1028
+ StaticRotationBehavior: () => StaticRotationBehavior,
1029
+ StaticScaleBehavior: () => StaticScaleBehavior,
1030
+ StaticSpeedBehavior: () => StaticSpeedBehavior,
1031
+ ZIndexBehavior: () => ZIndexBehavior,
1032
+ editor: () => Types_exports,
1033
+ spawnShapes: () => shapes_exports
1034
+ });
1035
+
1036
+ // particle/behaviors/shapes/index.ts
1037
+ var shapes_exports = {};
1038
+ __export(shapes_exports, {
1039
+ PolygonalChain: () => PolygonalChain,
1040
+ Rectangle: () => Rectangle,
1041
+ Torus: () => Torus
1042
+ });
1043
+
1044
+ // particle/behaviors/shapes/Rectangle.ts
1045
+ var Rectangle = class {
1046
+ static type = "rect";
1047
+ static editorConfig = null;
1048
+ /**
1049
+ * X (left) position of the rectangle.
1050
+ */
1051
+ x;
1052
+ /**
1053
+ * Y (top) position of the rectangle.
1054
+ */
1055
+ y;
1056
+ /**
1057
+ * Width of the rectangle.
1058
+ */
1059
+ w;
1060
+ /**
1061
+ * Height of the rectangle.
1062
+ */
1063
+ h;
1064
+ constructor(config) {
1065
+ this.x = config.x;
1066
+ this.y = config.y;
1067
+ this.w = config.w;
1068
+ this.h = config.h;
1069
+ }
1070
+ getRandPos(particle) {
1071
+ particle.x = Math.random() * this.w + this.x;
1072
+ particle.y = Math.random() * this.h + this.y;
1073
+ }
1074
+ };
1075
+
1076
+ // particle/behaviors/shapes/Torus.ts
1077
+ var Torus = class {
1078
+ static type = "torus";
1079
+ static editorConfig = null;
1080
+ /**
1081
+ * X position of the center of the shape.
1082
+ */
1083
+ x;
1084
+ /**
1085
+ * Y position of the center of the shape.
1086
+ */
1087
+ y;
1088
+ /**
1089
+ * Radius of circle, or outer radius of a ring.
1090
+ */
1091
+ radius;
1092
+ /**
1093
+ * Inner radius of a ring. Use 0 to have a circle.
1094
+ */
1095
+ innerRadius;
1096
+ /**
1097
+ * If rotation should be applied to particles.
1098
+ */
1099
+ rotation;
1100
+ constructor(config) {
1101
+ this.x = config.x || 0;
1102
+ this.y = config.y || 0;
1103
+ this.radius = config.radius;
1104
+ this.innerRadius = config.innerRadius || 0;
1105
+ this.rotation = !!config.affectRotation;
1106
+ }
1107
+ getRandPos(particle) {
1108
+ if (this.innerRadius !== this.radius) {
1109
+ particle.x = Math.random() * (this.radius - this.innerRadius) + this.innerRadius;
1110
+ } else {
1111
+ particle.x = this.radius;
1112
+ }
1113
+ particle.y = 0;
1114
+ const angle = Math.random() * Math.PI * 2;
1115
+ if (this.rotation) {
1116
+ particle.rotation += angle;
1117
+ }
1118
+ rotatePoint(angle, particle.position);
1119
+ particle.position.x += this.x;
1120
+ particle.position.y += this.y;
1121
+ }
1122
+ };
1123
+
1124
+ // particle/behaviors/shapes/PolygonalChain.ts
1125
+ var PolygonalChain = class {
1126
+ static type = "polygonalChain";
1127
+ static editorConfig = null;
1128
+ /**
1129
+ * List of segment objects in the chain.
1130
+ */
1131
+ segments;
1132
+ /**
1133
+ * Total length of all segments of the chain.
1134
+ */
1135
+ totalLength;
1136
+ /**
1137
+ * Total length of segments up to and including the segment of the same index.
1138
+ * Used for weighted random selection of segment.
1139
+ */
1140
+ countingLengths;
1141
+ /**
1142
+ * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains.
1143
+ */
1144
+ constructor(data) {
1145
+ this.segments = [];
1146
+ this.countingLengths = [];
1147
+ this.totalLength = 0;
1148
+ this.init(data);
1149
+ }
1150
+ /**
1151
+ * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains.
1152
+ */
1153
+ init(data) {
1154
+ if (!data || !data.length) {
1155
+ this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 });
1156
+ } else if (Array.isArray(data[0])) {
1157
+ for (let i = 0; i < data.length; ++i) {
1158
+ const chain = data[i];
1159
+ let prevPoint = chain[0];
1160
+ for (let j = 1; j < chain.length; ++j) {
1161
+ const second = chain[j];
1162
+ this.segments.push({ p1: prevPoint, p2: second, l: 0 });
1163
+ prevPoint = second;
1164
+ }
1165
+ }
1166
+ } else {
1167
+ let prevPoint = data[0];
1168
+ for (let i = 1; i < data.length; ++i) {
1169
+ const second = data[i];
1170
+ this.segments.push({ p1: prevPoint, p2: second, l: 0 });
1171
+ prevPoint = second;
1172
+ }
1173
+ }
1174
+ for (let i = 0; i < this.segments.length; ++i) {
1175
+ const { p1, p2 } = this.segments[i];
1176
+ const segLength = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
1177
+ this.segments[i].l = segLength;
1178
+ this.totalLength += segLength;
1179
+ this.countingLengths.push(this.totalLength);
1180
+ }
1181
+ }
1182
+ /**
1183
+ * Gets a random point in the chain.
1184
+ * @param out The point to store the selected position in.
1185
+ */
1186
+ getRandPos(out) {
1187
+ const rand = Math.random() * this.totalLength;
1188
+ let chosenSeg;
1189
+ let lerp;
1190
+ if (this.segments.length === 1) {
1191
+ chosenSeg = this.segments[0];
1192
+ lerp = rand;
1193
+ } else {
1194
+ for (let i = 0; i < this.countingLengths.length; ++i) {
1195
+ if (rand < this.countingLengths[i]) {
1196
+ chosenSeg = this.segments[i];
1197
+ lerp = i === 0 ? rand : rand - this.countingLengths[i - 1];
1198
+ break;
1199
+ }
1200
+ }
1201
+ }
1202
+ lerp /= chosenSeg.l || 1;
1203
+ const { p1, p2 } = chosenSeg;
1204
+ out.x = p1.x + lerp * (p2.x - p1.x);
1205
+ out.y = p1.y + lerp * (p2.y - p1.y);
1206
+ }
1207
+ };
1208
+
1209
+ // particle/behaviors/editor/Types.ts
1210
+ var Types_exports = {};
1211
+ var AccelerationBehavior = class {
1212
+ static type = "moveAcceleration";
1213
+ static editorConfig = null;
1214
+ // doesn't _really_ need to be late, but doing so ensures that we can override any
1215
+ // rotation behavior that is mistakenly added
1216
+ order = 5 /* Late */;
1217
+ minStart;
1218
+ maxStart;
1219
+ accel;
1220
+ rotate;
1221
+ maxSpeed;
1222
+ constructor(config) {
1223
+ this.minStart = config.minStart;
1224
+ this.maxStart = config.maxStart;
1225
+ this.accel = config.accel;
1226
+ this.rotate = !!config.rotate;
1227
+ this.maxSpeed = config.maxSpeed ?? 0;
1228
+ }
1229
+ initParticles(first) {
1230
+ let next = first;
1231
+ while (next) {
1232
+ const speed = Math.random() * (this.maxStart - this.minStart) + this.minStart;
1233
+ if (!next.config.velocity) {
1234
+ next.config.velocity = new Point(speed, 0);
1235
+ } else {
1236
+ next.config.velocity.set(speed, 0);
1237
+ }
1238
+ rotatePoint(next.rotation, next.config.velocity);
1239
+ next = next.next;
1240
+ }
1241
+ }
1242
+ updateParticle(particle, deltaSec) {
1243
+ const vel = particle.config.velocity;
1244
+ const oldVX = vel.x;
1245
+ const oldVY = vel.y;
1246
+ vel.x += this.accel.x * deltaSec;
1247
+ vel.y += this.accel.y * deltaSec;
1248
+ if (this.maxSpeed) {
1249
+ const currentSpeed = length(vel);
1250
+ if (currentSpeed > this.maxSpeed) {
1251
+ scaleBy(vel, this.maxSpeed / currentSpeed);
1252
+ }
1253
+ }
1254
+ particle.x += (oldVX + vel.x) / 2 * deltaSec;
1255
+ particle.y += (oldVY + vel.y) / 2 * deltaSec;
1256
+ if (this.rotate) {
1257
+ particle.rotation = Math.atan2(vel.y, vel.x);
1258
+ }
1259
+ }
1260
+ };
1261
+
1262
+ // particle/PropertyList.ts
1263
+ function intValueSimple(lerp) {
1264
+ if (this.ease) lerp = this.ease(lerp);
1265
+ return (this.first.next.value - this.first.value) * lerp + this.first.value;
1266
+ }
1267
+ function intColorSimple(lerp) {
1268
+ if (this.ease) lerp = this.ease(lerp);
1269
+ const curVal = this.first.value;
1270
+ const nextVal = this.first.next.value;
1271
+ const r = (nextVal.r - curVal.r) * lerp + curVal.r;
1272
+ const g = (nextVal.g - curVal.g) * lerp + curVal.g;
1273
+ const b = (nextVal.b - curVal.b) * lerp + curVal.b;
1274
+ return combineRGBComponents(r, g, b);
1275
+ }
1276
+ function intValueComplex(lerp) {
1277
+ if (this.ease) lerp = this.ease(lerp);
1278
+ let current = this.first;
1279
+ let next = current.next;
1280
+ while (lerp > next.time) {
1281
+ current = next;
1282
+ next = next.next;
1283
+ }
1284
+ lerp = (lerp - current.time) / (next.time - current.time);
1285
+ return (next.value - current.value) * lerp + current.value;
1286
+ }
1287
+ function intColorComplex(lerp) {
1288
+ if (this.ease) lerp = this.ease(lerp);
1289
+ let current = this.first;
1290
+ let next = current.next;
1291
+ while (lerp > next.time) {
1292
+ current = next;
1293
+ next = next.next;
1294
+ }
1295
+ lerp = (lerp - current.time) / (next.time - current.time);
1296
+ const curVal = current.value;
1297
+ const nextVal = next.value;
1298
+ const r = (nextVal.r - curVal.r) * lerp + curVal.r;
1299
+ const g = (nextVal.g - curVal.g) * lerp + curVal.g;
1300
+ const b = (nextVal.b - curVal.b) * lerp + curVal.b;
1301
+ return combineRGBComponents(r, g, b);
1302
+ }
1303
+ function intValueStepped(lerp) {
1304
+ if (this.ease) lerp = this.ease(lerp);
1305
+ let current = this.first;
1306
+ while (current.next && lerp > current.next.time) {
1307
+ current = current.next;
1308
+ }
1309
+ return current.value;
1310
+ }
1311
+ function intColorStepped(lerp) {
1312
+ if (this.ease) lerp = this.ease(lerp);
1313
+ let current = this.first;
1314
+ while (current.next && lerp > current.next.time) {
1315
+ current = current.next;
1316
+ }
1317
+ const curVal = current.value;
1318
+ return combineRGBComponents(curVal.r, curVal.g, curVal.b);
1319
+ }
1320
+ var PropertyList = class {
1321
+ /**
1322
+ * The first property node in the linked list.
1323
+ */
1324
+ first;
1325
+ /**
1326
+ * Calculates the correct value for the current interpolation value. This method is set in
1327
+ * the reset() method.
1328
+ * @param lerp The interpolation value from 0-1.
1329
+ * @return The interpolated value. Colors are converted to the hex value.
1330
+ */
1331
+ interpolate;
1332
+ /**
1333
+ * A custom easing method for this list.
1334
+ * @param lerp The interpolation value from 0-1.
1335
+ * @return The eased value, also from 0-1.
1336
+ */
1337
+ ease;
1338
+ /**
1339
+ * If this list manages colors, which requires a different method for interpolation.
1340
+ */
1341
+ isColor;
1342
+ /**
1343
+ * @param isColor If this list handles color values
1344
+ */
1345
+ constructor(isColor = false) {
1346
+ this.first = null;
1347
+ this.isColor = !!isColor;
1348
+ this.interpolate = null;
1349
+ this.ease = null;
1350
+ }
1351
+ /**
1352
+ * Resets the list for use.
1353
+ * @param first The first node in the list.
1354
+ * @param first.isStepped If the values should be stepped instead of interpolated linearly.
1355
+ */
1356
+ reset(first) {
1357
+ this.first = first;
1358
+ const isSimple = first.next && first.next.time >= 1;
1359
+ if (isSimple) {
1360
+ this.interpolate = this.isColor ? intColorSimple : intValueSimple;
1361
+ } else if (first.isStepped) {
1362
+ this.interpolate = this.isColor ? intColorStepped : intValueStepped;
1363
+ } else {
1364
+ this.interpolate = this.isColor ? intColorComplex : intValueComplex;
1365
+ }
1366
+ this.ease = this.first.ease;
1367
+ }
1368
+ };
1369
+
1370
+ // particle/behaviors/Alpha.ts
1371
+ var AlphaBehavior = class {
1372
+ static type = "alpha";
1373
+ static editorConfig = null;
1374
+ order = 2 /* Normal */;
1375
+ list;
1376
+ constructor(config) {
1377
+ this.list = new PropertyList(false);
1378
+ this.list.reset(PropertyNode.createList(config.alpha));
1379
+ }
1380
+ initParticles(first) {
1381
+ let next = first;
1382
+ while (next) {
1383
+ next.alpha = this.list.first.value;
1384
+ next = next.next;
1385
+ }
1386
+ }
1387
+ updateParticle(particle) {
1388
+ particle.alpha = this.list.interpolate(particle.agePercent);
1389
+ }
1390
+ };
1391
+ var StaticAlphaBehavior = class {
1392
+ static type = "alphaStatic";
1393
+ static editorConfig = null;
1394
+ order = 2 /* Normal */;
1395
+ value;
1396
+ constructor(config) {
1397
+ this.value = config.alpha;
1398
+ }
1399
+ initParticles(first) {
1400
+ let next = first;
1401
+ while (next) {
1402
+ next.alpha = this.value;
1403
+ next = next.next;
1404
+ }
1405
+ }
1406
+ };
1407
+ function getTextures(textures) {
1408
+ const outTextures = [];
1409
+ for (let j = 0; j < textures.length; ++j) {
1410
+ let tex = textures[j];
1411
+ if (typeof tex === "string") {
1412
+ outTextures.push(GetTextureFromString(tex));
1413
+ } else if (tex instanceof Texture) {
1414
+ outTextures.push(tex);
1415
+ } else {
1416
+ let dupe = tex.count || 1;
1417
+ if (typeof tex.texture === "string") {
1418
+ tex = GetTextureFromString(tex.texture);
1419
+ } else {
1420
+ tex = tex.texture;
1421
+ }
1422
+ for (; dupe > 0; --dupe) {
1423
+ outTextures.push(tex);
1424
+ }
1425
+ }
1426
+ }
1427
+ return outTextures;
1428
+ }
1429
+ var RandomAnimatedTextureBehavior = class {
1430
+ static type = "animatedRandom";
1431
+ static editorConfig = null;
1432
+ order = 2 /* Normal */;
1433
+ anims;
1434
+ constructor(config) {
1435
+ this.anims = [];
1436
+ for (let i = 0; i < config.anims.length; ++i) {
1437
+ const anim = config.anims[i];
1438
+ const textures = getTextures(anim.textures);
1439
+ const framerate = anim.framerate < 0 ? -1 : anim.framerate > 0 ? anim.framerate : 60;
1440
+ const parsedAnim = {
1441
+ textures,
1442
+ duration: framerate > 0 ? textures.length / framerate : 0,
1443
+ framerate,
1444
+ loop: framerate > 0 ? !!anim.loop : false
1445
+ };
1446
+ this.anims.push(parsedAnim);
1447
+ }
1448
+ }
1449
+ initParticles(first) {
1450
+ let next = first;
1451
+ while (next) {
1452
+ const index = Math.floor(Math.random() * this.anims.length);
1453
+ const anim = next.config.anim = this.anims[index];
1454
+ next.texture = anim.textures[0];
1455
+ next.config.animElapsed = 0;
1456
+ if (anim.framerate === -1) {
1457
+ next.config.animDuration = next.maxLife;
1458
+ next.config.animFramerate = anim.textures.length / next.maxLife;
1459
+ } else {
1460
+ next.config.animDuration = anim.duration;
1461
+ next.config.animFramerate = anim.framerate;
1462
+ }
1463
+ next = next.next;
1464
+ }
1465
+ }
1466
+ updateParticle(particle, deltaSec) {
1467
+ const config = particle.config;
1468
+ const anim = config.anim;
1469
+ config.animElapsed += deltaSec;
1470
+ if (config.animElapsed >= config.animDuration) {
1471
+ if (config.anim.loop) {
1472
+ config.animElapsed = config.animElapsed % config.animDuration;
1473
+ } else {
1474
+ config.animElapsed = config.animDuration - 1e-6;
1475
+ }
1476
+ }
1477
+ const frame = config.animElapsed * config.animFramerate + 1e-7 | 0;
1478
+ particle.texture = anim.textures[frame] || anim.textures[anim.textures.length - 1] || Texture.EMPTY;
1479
+ }
1480
+ };
1481
+ var SingleAnimatedTextureBehavior = class {
1482
+ static type = "animatedSingle";
1483
+ static editorConfig = null;
1484
+ order = 2 /* Normal */;
1485
+ anim;
1486
+ constructor(config) {
1487
+ const anim = config.anim;
1488
+ const textures = getTextures(anim.textures);
1489
+ const framerate = anim.framerate < 0 ? -1 : anim.framerate > 0 ? anim.framerate : 60;
1490
+ this.anim = {
1491
+ textures,
1492
+ duration: framerate > 0 ? textures.length / framerate : 0,
1493
+ framerate,
1494
+ loop: framerate > 0 ? !!anim.loop : false
1495
+ };
1496
+ }
1497
+ initParticles(first) {
1498
+ let next = first;
1499
+ const anim = this.anim;
1500
+ while (next) {
1501
+ next.texture = anim.textures[0];
1502
+ next.config.animElapsed = 0;
1503
+ if (anim.framerate === -1) {
1504
+ next.config.animDuration = next.maxLife;
1505
+ next.config.animFramerate = anim.textures.length / next.maxLife;
1506
+ } else {
1507
+ next.config.animDuration = anim.duration;
1508
+ next.config.animFramerate = anim.framerate;
1509
+ }
1510
+ next = next.next;
1511
+ }
1512
+ }
1513
+ updateParticle(particle, deltaSec) {
1514
+ const anim = this.anim;
1515
+ const config = particle.config;
1516
+ config.animElapsed += deltaSec;
1517
+ if (config.animElapsed >= config.animDuration) {
1518
+ if (anim.loop) {
1519
+ config.animElapsed = config.animElapsed % config.animDuration;
1520
+ } else {
1521
+ config.animElapsed = config.animDuration - 1e-6;
1522
+ }
1523
+ }
1524
+ const frame = config.animElapsed * config.animFramerate + 1e-7 | 0;
1525
+ particle.texture = anim.textures[frame] || anim.textures[anim.textures.length - 1] || Texture.EMPTY;
1526
+ }
1527
+ };
1528
+
1529
+ // particle/behaviors/BlendMode.ts
1530
+ var BlendModeBehavior = class {
1531
+ static type = "blendMode";
1532
+ static editorConfig = null;
1533
+ order = 2 /* Normal */;
1534
+ value;
1535
+ constructor(config) {
1536
+ this.value = config.blendMode;
1537
+ }
1538
+ initParticles(first) {
1539
+ let next = first;
1540
+ while (next) {
1541
+ next.blendMode = getBlendMode(this.value);
1542
+ next = next.next;
1543
+ }
1544
+ }
1545
+ };
1546
+
1547
+ // particle/behaviors/BurstSpawn.ts
1548
+ var BurstSpawnBehavior = class {
1549
+ static type = "spawnBurst";
1550
+ static editorConfig = null;
1551
+ order = 0 /* Spawn */;
1552
+ spacing;
1553
+ start;
1554
+ distance;
1555
+ constructor(config) {
1556
+ this.spacing = config.spacing * DEG_TO_RADS;
1557
+ this.start = config.start * DEG_TO_RADS;
1558
+ this.distance = config.distance;
1559
+ }
1560
+ initParticles(first) {
1561
+ let count = 0;
1562
+ let next = first;
1563
+ while (next) {
1564
+ let angle;
1565
+ if (this.spacing) {
1566
+ angle = this.start + this.spacing * count;
1567
+ } else {
1568
+ angle = Math.random() * Math.PI * 2;
1569
+ }
1570
+ next.rotation = angle;
1571
+ if (this.distance) {
1572
+ next.position.x = this.distance;
1573
+ rotatePoint(angle, next.position);
1574
+ }
1575
+ next = next.next;
1576
+ ++count;
1577
+ }
1578
+ }
1579
+ };
1580
+
1581
+ // particle/behaviors/Color.ts
1582
+ var ColorBehavior = class {
1583
+ static type = "color";
1584
+ static editorConfig = null;
1585
+ order = 2 /* Normal */;
1586
+ list;
1587
+ constructor(config) {
1588
+ this.list = new PropertyList(true);
1589
+ this.list.reset(PropertyNode.createList(config.color));
1590
+ }
1591
+ initParticles(first) {
1592
+ let next = first;
1593
+ const color = this.list.first.value;
1594
+ const tint = combineRGBComponents(color.r, color.g, color.b);
1595
+ while (next) {
1596
+ next.tint = tint;
1597
+ next = next.next;
1598
+ }
1599
+ }
1600
+ updateParticle(particle) {
1601
+ particle.tint = this.list.interpolate(particle.agePercent);
1602
+ }
1603
+ };
1604
+ var StaticColorBehavior = class {
1605
+ static type = "colorStatic";
1606
+ static editorConfig = null;
1607
+ order = 2 /* Normal */;
1608
+ value;
1609
+ constructor(config) {
1610
+ let color = config.color;
1611
+ if (color.charAt(0) === "#") {
1612
+ color = color.substr(1);
1613
+ } else if (color.indexOf("0x") === 0) {
1614
+ color = color.substr(2);
1615
+ }
1616
+ this.value = parseInt(color, 16);
1617
+ }
1618
+ initParticles(first) {
1619
+ let next = first;
1620
+ while (next) {
1621
+ next.tint = this.value;
1622
+ next = next.next;
1623
+ }
1624
+ }
1625
+ };
1626
+
1627
+ // particle/behaviors/OrderedTexture.ts
1628
+ var OrderedTextureBehavior = class {
1629
+ static type = "textureOrdered";
1630
+ static editorConfig = null;
1631
+ order = 2 /* Normal */;
1632
+ textures;
1633
+ index;
1634
+ constructor(config) {
1635
+ this.index = 0;
1636
+ this.textures = config.textures.map((tex) => typeof tex === "string" ? GetTextureFromString(tex) : tex);
1637
+ }
1638
+ initParticles(first) {
1639
+ let next = first;
1640
+ while (next) {
1641
+ next.texture = this.textures[this.index];
1642
+ if (++this.index >= this.textures.length) {
1643
+ this.index = 0;
1644
+ }
1645
+ next = next.next;
1646
+ }
1647
+ }
1648
+ };
1649
+ var helperPoint = new Point();
1650
+ var MATH_FUNCS = [
1651
+ "E",
1652
+ "LN2",
1653
+ "LN10",
1654
+ "LOG2E",
1655
+ "LOG10E",
1656
+ "PI",
1657
+ "SQRT1_2",
1658
+ "SQRT2",
1659
+ "abs",
1660
+ "acos",
1661
+ "acosh",
1662
+ "asin",
1663
+ "asinh",
1664
+ "atan",
1665
+ "atanh",
1666
+ "atan2",
1667
+ "cbrt",
1668
+ "ceil",
1669
+ "cos",
1670
+ "cosh",
1671
+ "exp",
1672
+ "expm1",
1673
+ "floor",
1674
+ "fround",
1675
+ "hypot",
1676
+ "log",
1677
+ "log1p",
1678
+ "log10",
1679
+ "log2",
1680
+ "max",
1681
+ "min",
1682
+ "pow",
1683
+ "random",
1684
+ "round",
1685
+ "sign",
1686
+ "sin",
1687
+ "sinh",
1688
+ "sqrt",
1689
+ "tan",
1690
+ "tanh"
1691
+ ];
1692
+ var WHITELISTER = new RegExp(
1693
+ [
1694
+ // Allow the 4 basic operations, parentheses and all numbers/decimals, as well
1695
+ // as 'x', for the variable usage.
1696
+ "[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]"
1697
+ ].concat(MATH_FUNCS).join("|"),
1698
+ "g"
1699
+ );
1700
+ function parsePath(pathString) {
1701
+ const matches = pathString.match(WHITELISTER);
1702
+ for (let i = matches.length - 1; i >= 0; --i) {
1703
+ if (MATH_FUNCS.indexOf(matches[i]) >= 0) {
1704
+ matches[i] = `Math.${matches[i]}`;
1705
+ }
1706
+ }
1707
+ pathString = matches.join("");
1708
+ return new Function("x", `return ${pathString};`);
1709
+ }
1710
+ var PathBehavior = class {
1711
+ static type = "movePath";
1712
+ static editorConfig = null;
1713
+ // *MUST* happen after other behaviors do initialization so that we can read initial transformations
1714
+ order = 5 /* Late */;
1715
+ /**
1716
+ * The function representing the path the particle should take.
1717
+ */
1718
+ path;
1719
+ list;
1720
+ minMult;
1721
+ constructor(config) {
1722
+ if (config.path) {
1723
+ if (typeof config.path === "function") {
1724
+ this.path = config.path;
1725
+ } else {
1726
+ try {
1727
+ this.path = parsePath(config.path);
1728
+ } catch (e) {
1729
+ this.path = null;
1730
+ }
1731
+ }
1732
+ } else {
1733
+ this.path = (x) => x;
1734
+ }
1735
+ this.list = new PropertyList(false);
1736
+ this.list.reset(PropertyNode.createList(config.speed));
1737
+ this.minMult = config.minMult ?? 1;
1738
+ }
1739
+ initParticles(first) {
1740
+ let next = first;
1741
+ while (next) {
1742
+ next.config.initRotation = next.rotation;
1743
+ if (!next.config.initPosition) {
1744
+ next.config.initPosition = new Point(next.x, next.y);
1745
+ } else {
1746
+ next.config.initPosition.copyFrom(next.position);
1747
+ }
1748
+ next.config.movement = 0;
1749
+ const mult = Math.random() * (1 - this.minMult) + this.minMult;
1750
+ next.config.speedMult = mult;
1751
+ next = next.next;
1752
+ }
1753
+ }
1754
+ updateParticle(particle, deltaSec) {
1755
+ const speed = this.list.interpolate(particle.agePercent) * particle.config.speedMult;
1756
+ particle.config.movement += speed * deltaSec;
1757
+ helperPoint.x = particle.config.movement;
1758
+ helperPoint.y = this.path(helperPoint.x);
1759
+ rotatePoint(particle.config.initRotation, helperPoint);
1760
+ particle.position.x = particle.config.initPosition.x + helperPoint.x;
1761
+ particle.position.y = particle.config.initPosition.y + helperPoint.y;
1762
+ }
1763
+ };
1764
+
1765
+ // particle/behaviors/PointSpawn.ts
1766
+ var PointSpawnBehavior = class {
1767
+ static type = "spawnPoint";
1768
+ static editorConfig = null;
1769
+ order = 0 /* Spawn */;
1770
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1771
+ initParticles(_first) {
1772
+ }
1773
+ };
1774
+
1775
+ // particle/behaviors/RandomTexture.ts
1776
+ var RandomTextureBehavior = class {
1777
+ static type = "textureRandom";
1778
+ static editorConfig = null;
1779
+ order = 2 /* Normal */;
1780
+ textures;
1781
+ constructor(config) {
1782
+ this.textures = config.textures.map((tex) => typeof tex === "string" ? GetTextureFromString(tex) : tex);
1783
+ }
1784
+ initParticles(first) {
1785
+ let next = first;
1786
+ while (next) {
1787
+ const index = Math.floor(Math.random() * this.textures.length);
1788
+ next.texture = this.textures[index];
1789
+ next = next.next;
1790
+ }
1791
+ }
1792
+ };
1793
+
1794
+ // particle/behaviors/Rotation.ts
1795
+ var RotationBehavior = class {
1796
+ static type = "rotation";
1797
+ static editorConfig = null;
1798
+ order = 2 /* Normal */;
1799
+ minStart;
1800
+ maxStart;
1801
+ minSpeed;
1802
+ maxSpeed;
1803
+ accel;
1804
+ constructor(config) {
1805
+ this.minStart = config.minStart * DEG_TO_RADS;
1806
+ this.maxStart = config.maxStart * DEG_TO_RADS;
1807
+ this.minSpeed = config.minSpeed * DEG_TO_RADS;
1808
+ this.maxSpeed = config.maxSpeed * DEG_TO_RADS;
1809
+ this.accel = config.accel * DEG_TO_RADS;
1810
+ }
1811
+ initParticles(first) {
1812
+ let next = first;
1813
+ while (next) {
1814
+ if (this.minStart === this.maxStart) {
1815
+ next.rotation += this.maxStart;
1816
+ } else {
1817
+ next.rotation += Math.random() * (this.maxStart - this.minStart) + this.minStart;
1818
+ }
1819
+ next.config.rotSpeed = Math.random() * (this.maxSpeed - this.minSpeed) + this.minSpeed;
1820
+ next = next.next;
1821
+ }
1822
+ }
1823
+ updateParticle(particle, deltaSec) {
1824
+ if (this.accel) {
1825
+ const oldSpeed = particle.config.rotSpeed;
1826
+ particle.config.rotSpeed += this.accel * deltaSec;
1827
+ particle.rotation += (particle.config.rotSpeed + oldSpeed) / 2 * deltaSec;
1828
+ } else {
1829
+ particle.rotation += particle.config.rotSpeed * deltaSec;
1830
+ }
1831
+ }
1832
+ };
1833
+ var StaticRotationBehavior = class {
1834
+ static type = "rotationStatic";
1835
+ static editorConfig = null;
1836
+ order = 2 /* Normal */;
1837
+ min;
1838
+ max;
1839
+ constructor(config) {
1840
+ this.min = config.min * DEG_TO_RADS;
1841
+ this.max = config.max * DEG_TO_RADS;
1842
+ }
1843
+ initParticles(first) {
1844
+ let next = first;
1845
+ while (next) {
1846
+ if (this.min === this.max) {
1847
+ next.rotation += this.max;
1848
+ } else {
1849
+ next.rotation += Math.random() * (this.max - this.min) + this.min;
1850
+ }
1851
+ next = next.next;
1852
+ }
1853
+ }
1854
+ };
1855
+ var NoRotationBehavior = class {
1856
+ static type = "noRotation";
1857
+ static editorConfig = null;
1858
+ order = 5 /* Late */ + 1;
1859
+ rotation;
1860
+ constructor(config) {
1861
+ this.rotation = (config.rotation || 0) * DEG_TO_RADS;
1862
+ }
1863
+ initParticles(first) {
1864
+ let next = first;
1865
+ while (next) {
1866
+ next.rotation = this.rotation;
1867
+ next = next.next;
1868
+ }
1869
+ }
1870
+ };
1871
+
1872
+ // particle/behaviors/Scale.ts
1873
+ var ScaleBehavior = class {
1874
+ static type = "scale";
1875
+ static editorConfig = null;
1876
+ order = 2 /* Normal */;
1877
+ list;
1878
+ minMult;
1879
+ constructor(config) {
1880
+ this.list = new PropertyList(false);
1881
+ this.list.reset(PropertyNode.createList(config.scale));
1882
+ this.minMult = config.minMult ?? 1;
1883
+ }
1884
+ initParticles(first) {
1885
+ let next = first;
1886
+ while (next) {
1887
+ const mult = Math.random() * (1 - this.minMult) + this.minMult;
1888
+ next.config.scaleMult = mult;
1889
+ next.scale.x = next.scale.y = this.list.first.value * mult;
1890
+ next = next.next;
1891
+ }
1892
+ }
1893
+ updateParticle(particle) {
1894
+ particle.scale.x = particle.scale.y = this.list.interpolate(particle.agePercent) * particle.config.scaleMult;
1895
+ }
1896
+ };
1897
+ var StaticScaleBehavior = class {
1898
+ static type = "scaleStatic";
1899
+ static editorConfig = null;
1900
+ order = 2 /* Normal */;
1901
+ min;
1902
+ max;
1903
+ constructor(config) {
1904
+ this.min = config.min;
1905
+ this.max = config.max;
1906
+ }
1907
+ initParticles(first) {
1908
+ let next = first;
1909
+ while (next) {
1910
+ const scale = Math.random() * (this.max - this.min) + this.min;
1911
+ next.scale.x = next.scale.y = scale;
1912
+ next = next.next;
1913
+ }
1914
+ }
1915
+ };
1916
+
1917
+ // particle/behaviors/ShapeSpawn.ts
1918
+ var ShapeSpawnBehavior = class _ShapeSpawnBehavior {
1919
+ static type = "spawnShape";
1920
+ static editorConfig = null;
1921
+ /**
1922
+ * Dictionary of all registered shape classes.
1923
+ */
1924
+ static shapes = {};
1925
+ /**
1926
+ * Registers a shape to be used by the ShapeSpawn behavior.
1927
+ * @param constructor The shape class constructor to use, with a static `type` property to reference it by.
1928
+ * @param typeOverride An optional type override, primarily for registering a shape under multiple names.
1929
+ */
1930
+ static registerShape(constructor, typeOverride) {
1931
+ _ShapeSpawnBehavior.shapes[typeOverride || constructor.type] = constructor;
1932
+ }
1933
+ order = 0 /* Spawn */;
1934
+ shape;
1935
+ constructor(config) {
1936
+ const ShapeClass = _ShapeSpawnBehavior.shapes[config.type];
1937
+ if (!ShapeClass) {
1938
+ throw new Error(`No shape found with type '${config.type}'`);
1939
+ }
1940
+ this.shape = new ShapeClass(config.data);
1941
+ }
1942
+ initParticles(first) {
1943
+ let next = first;
1944
+ while (next) {
1945
+ this.shape.getRandPos(next);
1946
+ next = next.next;
1947
+ }
1948
+ }
1949
+ };
1950
+ ShapeSpawnBehavior.registerShape(PolygonalChain);
1951
+ ShapeSpawnBehavior.registerShape(Rectangle);
1952
+ ShapeSpawnBehavior.registerShape(Torus);
1953
+ ShapeSpawnBehavior.registerShape(Torus, "circle");
1954
+
1955
+ // particle/behaviors/SingleTexture.ts
1956
+ var SingleTextureBehavior = class {
1957
+ static type = "textureSingle";
1958
+ static editorConfig = null;
1959
+ order = 2 /* Normal */;
1960
+ texture;
1961
+ constructor(config) {
1962
+ this.texture = typeof config.texture === "string" ? GetTextureFromString(config.texture) : config.texture;
1963
+ }
1964
+ initParticles(first) {
1965
+ let next = first;
1966
+ while (next) {
1967
+ next.texture = this.texture;
1968
+ next = next.next;
1969
+ }
1970
+ }
1971
+ };
1972
+ var SpeedBehavior = class {
1973
+ static type = "moveSpeed";
1974
+ static editorConfig = null;
1975
+ order = 5 /* Late */;
1976
+ list;
1977
+ minMult;
1978
+ constructor(config) {
1979
+ this.list = new PropertyList(false);
1980
+ this.list.reset(PropertyNode.createList(config.speed));
1981
+ this.minMult = config.minMult ?? 1;
1982
+ }
1983
+ initParticles(first) {
1984
+ let next = first;
1985
+ while (next) {
1986
+ const mult = Math.random() * (1 - this.minMult) + this.minMult;
1987
+ next.config.speedMult = mult;
1988
+ if (!next.config.velocity) {
1989
+ next.config.velocity = new Point(this.list.first.value * mult, 0);
1990
+ } else {
1991
+ next.config.velocity.set(this.list.first.value * mult, 0);
1992
+ }
1993
+ rotatePoint(next.rotation, next.config.velocity);
1994
+ next = next.next;
1995
+ }
1996
+ }
1997
+ updateParticle(particle, deltaSec) {
1998
+ const speed = this.list.interpolate(particle.agePercent) * particle.config.speedMult;
1999
+ const vel = particle.config.velocity;
2000
+ normalize(vel);
2001
+ scaleBy(vel, speed);
2002
+ particle.x += vel.x * deltaSec;
2003
+ particle.y += vel.y * deltaSec;
2004
+ }
2005
+ };
2006
+ var StaticSpeedBehavior = class {
2007
+ static type = "moveSpeedStatic";
2008
+ static editorConfig = null;
2009
+ order = 5 /* Late */;
2010
+ min;
2011
+ max;
2012
+ constructor(config) {
2013
+ this.min = config.min;
2014
+ this.max = config.max;
2015
+ }
2016
+ initParticles(first) {
2017
+ let next = first;
2018
+ while (next) {
2019
+ const speed = Math.random() * (this.max - this.min) + this.min;
2020
+ if (!next.config.velocity) {
2021
+ next.config.velocity = new Point(speed, 0);
2022
+ } else {
2023
+ next.config.velocity.set(speed, 0);
2024
+ }
2025
+ rotatePoint(next.rotation, next.config.velocity);
2026
+ next = next.next;
2027
+ }
2028
+ }
2029
+ updateParticle(particle, deltaSec) {
2030
+ const velocity = particle.config.velocity;
2031
+ particle.x += velocity.x * deltaSec;
2032
+ particle.y += velocity.y * deltaSec;
2033
+ }
2034
+ };
2035
+
2036
+ // particle/behaviors/RandomColor.ts
2037
+ var RandomColor = class {
2038
+ static type = "rngcolor";
2039
+ static editorConfig;
2040
+ order = 2 /* Normal */;
2041
+ list;
2042
+ constructor(config) {
2043
+ this.list = config.colour.map((color) => hexToRGB(color));
2044
+ }
2045
+ initParticles(first) {
2046
+ let next = first;
2047
+ while (next) {
2048
+ const index = Math.floor(Math.random() * this.list.length);
2049
+ const color = this.list[index];
2050
+ const tint = combineRGBComponents(color.r, color.g, color.b);
2051
+ next.tint = tint;
2052
+ next = next.next;
2053
+ }
2054
+ }
2055
+ };
2056
+
2057
+ // particle/behaviors/ZindexBehavior.ts
2058
+ var ZIndexBehavior = class {
2059
+ static type = "zIndex";
2060
+ static editorConfig;
2061
+ order = 2 /* Normal */;
2062
+ list;
2063
+ constructor(config) {
2064
+ this.list = new PropertyList(false);
2065
+ this.list.reset(PropertyNode.createList(config.zIndex));
2066
+ }
2067
+ initParticles(first) {
2068
+ let next = first;
2069
+ while (next) {
2070
+ next = next.next;
2071
+ }
2072
+ }
2073
+ updateParticle(particle) {
2074
+ particle.zIndex = this.list.interpolate(particle.agePercent);
2075
+ }
2076
+ };
2077
+ function getTextures2(textures) {
2078
+ const outTextures = [];
2079
+ for (let j = 0; j < textures.length; ++j) {
2080
+ let tex = textures[j];
2081
+ if (typeof tex === "string") {
2082
+ outTextures.push(GetTextureFromString(tex));
2083
+ } else if (tex instanceof Texture) {
2084
+ outTextures.push(tex);
2085
+ } else {
2086
+ let dupe = tex.count || 1;
2087
+ if (typeof tex.texture === "string") {
2088
+ tex = GetTextureFromString(tex.texture);
2089
+ } else {
2090
+ tex = tex.texture;
2091
+ }
2092
+ for (; dupe > 0; --dupe) {
2093
+ outTextures.push(tex);
2094
+ }
2095
+ }
2096
+ }
2097
+ return outTextures;
2098
+ }
2099
+ function parseAnimationState(state) {
2100
+ const textures = getTextures2(state.textures);
2101
+ const framerate = state.framerate < 0 ? -1 : state.framerate > 0 ? state.framerate : 60;
2102
+ return {
2103
+ textures,
2104
+ duration: framerate > 0 ? textures.length / framerate : 0,
2105
+ framerate,
2106
+ loop: framerate > 0 ? !!state.loop : false
2107
+ };
2108
+ }
2109
+ var MultiStateAnimatedTextureBehavior = class {
2110
+ static type = "multiStateAnimated";
2111
+ static editorConfig = null;
2112
+ order = 2 /* Normal */;
2113
+ sets;
2114
+ initialState;
2115
+ constructor(config) {
2116
+ this.initialState = config.initialState || "default";
2117
+ this.sets = [];
2118
+ for (const set of config.sets) {
2119
+ const parsedSet = {
2120
+ id: set.id,
2121
+ states: {}
2122
+ };
2123
+ for (const [stateName, stateConfig] of Object.entries(set.states)) {
2124
+ parsedSet.states[stateName] = parseAnimationState(stateConfig);
2125
+ }
2126
+ this.sets.push(parsedSet);
2127
+ }
2128
+ }
2129
+ initParticles(first) {
2130
+ let next = first;
2131
+ while (next) {
2132
+ const particle = next;
2133
+ const setIndex = Math.floor(Math.random() * this.sets.length);
2134
+ const set = this.sets[setIndex];
2135
+ particle.config.animSet = set;
2136
+ particle.config.animSetId = set.id;
2137
+ particle.config.animStateName = this.initialState;
2138
+ this.applyState(particle, this.initialState);
2139
+ particle.config.setState = (stateName) => {
2140
+ if (particle.config.animStateName !== stateName) {
2141
+ this.applyState(particle, stateName);
2142
+ }
2143
+ };
2144
+ next = next.next;
2145
+ }
2146
+ }
2147
+ applyState(particle, stateName) {
2148
+ const set = particle.config.animSet;
2149
+ const state = set.states[stateName];
2150
+ if (!state) {
2151
+ console.warn(`[MultiStateAnimatedTexture] State '${stateName}' not found in set '${set.id}'`);
2152
+ return;
2153
+ }
2154
+ particle.config.animStateName = stateName;
2155
+ particle.config.anim = state;
2156
+ particle.config.animElapsed = 0;
2157
+ particle.texture = state.textures[0] || Texture.EMPTY;
2158
+ if (state.framerate === -1) {
2159
+ particle.config.animDuration = particle.maxLife;
2160
+ particle.config.animFramerate = state.textures.length / particle.maxLife;
2161
+ } else {
2162
+ particle.config.animDuration = state.duration;
2163
+ particle.config.animFramerate = state.framerate;
2164
+ }
2165
+ }
2166
+ updateParticle(particle, deltaSec) {
2167
+ const config = particle.config;
2168
+ const anim = config.anim;
2169
+ if (!anim || !anim.textures.length) return;
2170
+ config.animElapsed += deltaSec;
2171
+ if (config.animElapsed >= config.animDuration) {
2172
+ if (anim.loop) {
2173
+ config.animElapsed = config.animElapsed % config.animDuration;
2174
+ } else {
2175
+ config.animElapsed = config.animDuration - 1e-6;
2176
+ }
2177
+ }
2178
+ const frame = config.animElapsed * config.animFramerate + 1e-7 | 0;
2179
+ particle.texture = anim.textures[frame] || anim.textures[anim.textures.length - 1] || Texture.EMPTY;
2180
+ }
2181
+ };
2182
+
2183
+ // particle/behaviors/SpineTexture.ts
2184
+ var SpineAnimationBehavior = class {
2185
+ static type = "spineAnimation";
2186
+ static editorConfig = null;
2187
+ order = 2 /* Normal */;
2188
+ animation;
2189
+ loop;
2190
+ timeScale;
2191
+ skin;
2192
+ skins;
2193
+ constructor(config) {
2194
+ this.animation = config.animation;
2195
+ this.loop = config.loop ?? false;
2196
+ this.timeScale = config.timeScale ?? 1;
2197
+ this.skin = config.skin ?? null;
2198
+ this.skins = config.skins ?? null;
2199
+ }
2200
+ /**
2201
+ * Initialize particles with Spine animation and skin
2202
+ */
2203
+ initParticles(first) {
2204
+ let next = first;
2205
+ while (next) {
2206
+ const particle = next;
2207
+ if (particle.spine) {
2208
+ if (this.skins && this.skins.length > 0) {
2209
+ const randomIndex = Math.floor(Math.random() * this.skins.length);
2210
+ const skinName = this.skins[randomIndex];
2211
+ particle.spine.skeleton.setSkinByName(skinName);
2212
+ particle.spine.skeleton.setSlotsToSetupPose();
2213
+ } else if (this.skin) {
2214
+ particle.spine.skeleton.setSkinByName(this.skin);
2215
+ particle.spine.skeleton.setSlotsToSetupPose();
2216
+ }
2217
+ const trackEntry = particle.spine.state.setAnimation(0, this.animation, this.loop);
2218
+ if (trackEntry) {
2219
+ trackEntry.timeScale = this.timeScale;
2220
+ }
2221
+ }
2222
+ next = particle.next;
2223
+ }
2224
+ }
2225
+ /**
2226
+ * Update is not needed - Spine handles its own animation updates
2227
+ */
2228
+ updateParticle(_particle, _deltaSec) {
2229
+ }
2230
+ };
2231
+ var SpineRandomSkinBehavior = class {
2232
+ static type = "spineRandomSkin";
2233
+ static editorConfig = null;
2234
+ order = 2 /* Normal */ - 1;
2235
+ // Run before animation behavior
2236
+ skins;
2237
+ constructor(config) {
2238
+ this.skins = config.skins;
2239
+ }
2240
+ initParticles(first) {
2241
+ let next = first;
2242
+ while (next) {
2243
+ const particle = next;
2244
+ if (particle.spine && this.skins.length > 0) {
2245
+ const randomIndex = Math.floor(Math.random() * this.skins.length);
2246
+ const skinName = this.skins[randomIndex];
2247
+ particle.spine.skeleton.setSkinByName(skinName);
2248
+ particle.spine.skeleton.setSlotsToSetupPose();
2249
+ }
2250
+ next = particle.next;
2251
+ }
2252
+ }
2253
+ };
2254
+ var SpineAnimationSequenceBehavior = class {
2255
+ static type = "spineAnimationSequence";
2256
+ static editorConfig = null;
2257
+ order = 2 /* Normal */;
2258
+ animationList;
2259
+ loop;
2260
+ timeScale;
2261
+ skin;
2262
+ skins;
2263
+ constructor(config) {
2264
+ this.animationList = config.animation.list;
2265
+ this.loop = config.loop ?? false;
2266
+ this.timeScale = config.timeScale ?? 1;
2267
+ this.skin = config.skin ?? null;
2268
+ this.skins = config.skins ?? null;
2269
+ }
2270
+ /**
2271
+ * Initialize particles with skin and first animation
2272
+ */
2273
+ initParticles(first) {
2274
+ let next = first;
2275
+ while (next) {
2276
+ const particle = next;
2277
+ if (particle.spine) {
2278
+ if (this.skins && this.skins.length > 0) {
2279
+ const randomIndex = Math.floor(Math.random() * this.skins.length);
2280
+ const skinName = this.skins[randomIndex];
2281
+ particle.spine.skeleton.setSkinByName(skinName);
2282
+ particle.spine.skeleton.setSlotsToSetupPose();
2283
+ } else if (this.skin) {
2284
+ particle.spine.skeleton.setSkinByName(this.skin);
2285
+ particle.spine.skeleton.setSlotsToSetupPose();
2286
+ }
2287
+ if (this.animationList.length > 0) {
2288
+ const firstAnim = this.animationList[0];
2289
+ const trackEntry = particle.spine.state.setAnimation(0, firstAnim.value, this.loop);
2290
+ if (trackEntry) {
2291
+ trackEntry.timeScale = this.timeScale;
2292
+ }
2293
+ }
2294
+ particle.config.spineAnimIndex = 0;
2295
+ }
2296
+ next = particle.next;
2297
+ }
2298
+ }
2299
+ /**
2300
+ * Update particle - check if we need to switch to next animation
2301
+ */
2302
+ updateParticle(particle, _deltaSec) {
2303
+ const spineParticle = particle;
2304
+ if (!spineParticle.spine) return;
2305
+ const currentIndex = spineParticle.config.spineAnimIndex ?? 0;
2306
+ const agePercent = spineParticle.agePercent;
2307
+ for (let i = currentIndex + 1; i < this.animationList.length; i++) {
2308
+ const keyframe = this.animationList[i];
2309
+ if (agePercent >= keyframe.time) {
2310
+ const trackEntry = spineParticle.spine.state.setAnimation(0, keyframe.value, this.loop);
2311
+ if (trackEntry) {
2312
+ trackEntry.timeScale = this.timeScale;
2313
+ }
2314
+ spineParticle.config.spineAnimIndex = i;
2315
+ }
2316
+ }
2317
+ }
2318
+ };
2319
+
2320
+ // particle/EmitterConfig.ts
2321
+ function upgradeConfig(config, art) {
2322
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2323
+ if ("behaviors" in config) {
2324
+ return config;
2325
+ }
2326
+ const out = {
2327
+ lifetime: config.lifetime,
2328
+ ease: config.ease,
2329
+ particlesPerWave: config.particlesPerWave,
2330
+ frequency: config.frequency,
2331
+ spawnChance: config.spawnChance,
2332
+ emitterLifetime: config.emitterLifetime,
2333
+ maxParticles: config.maxParticles,
2334
+ addAtBack: config.addAtBack,
2335
+ pos: config.pos,
2336
+ emit: config.emit,
2337
+ autoUpdate: config.autoUpdate,
2338
+ behaviors: []
2339
+ };
2340
+ if (config.alpha) {
2341
+ if ("start" in config.alpha) {
2342
+ if (config.alpha.start === config.alpha.end) {
2343
+ if (config.alpha.start !== 1) {
2344
+ out.behaviors.push({
2345
+ type: "alphaStatic",
2346
+ config: { alpha: config.alpha.start }
2347
+ });
2348
+ }
2349
+ } else {
2350
+ const list = {
2351
+ list: [
2352
+ { time: 0, value: config.alpha.start },
2353
+ { time: 1, value: config.alpha.end }
2354
+ ]
2355
+ };
2356
+ out.behaviors.push({
2357
+ type: "alpha",
2358
+ config: { alpha: list }
2359
+ });
2360
+ }
2361
+ } else if (config.alpha.list.length === 1) {
2362
+ if (config.alpha.list[0].value !== 1) {
2363
+ out.behaviors.push({
2364
+ type: "alphaStatic",
2365
+ config: { alpha: config.alpha.list[0].value }
2366
+ });
2367
+ }
2368
+ } else {
2369
+ out.behaviors.push({
2370
+ type: "alpha",
2371
+ config: { alpha: config.alpha }
2372
+ });
2373
+ }
2374
+ }
2375
+ if (config.acceleration && (config.acceleration.x || config.acceleration.y)) {
2376
+ let minStart;
2377
+ let maxStart;
2378
+ if ("start" in config.speed) {
2379
+ minStart = config.speed.start * (config.speed.minimumSpeedMultiplier ?? 1);
2380
+ maxStart = config.speed.start;
2381
+ } else {
2382
+ minStart = config.speed.list[0].value * (config.minimumSpeedMultiplier ?? 1);
2383
+ maxStart = config.speed.list[0].value;
2384
+ }
2385
+ out.behaviors.push({
2386
+ type: "moveAcceleration",
2387
+ config: {
2388
+ accel: config.acceleration,
2389
+ minStart,
2390
+ maxStart,
2391
+ rotate: !config.noRotation,
2392
+ maxSpeed: config.maxSpeed
2393
+ }
2394
+ });
2395
+ } else if ((_a = config.extraData) == null ? void 0 : _a.path) {
2396
+ let list;
2397
+ let mult;
2398
+ if ("start" in config.speed) {
2399
+ mult = config.speed.minimumSpeedMultiplier ?? 1;
2400
+ if (config.speed.start === config.speed.end) {
2401
+ list = {
2402
+ list: [{ time: 0, value: config.speed.start }]
2403
+ };
2404
+ } else {
2405
+ list = {
2406
+ list: [
2407
+ { time: 0, value: config.speed.start },
2408
+ { time: 1, value: config.speed.end }
2409
+ ]
2410
+ };
2411
+ }
2412
+ } else {
2413
+ list = config.speed;
2414
+ mult = config.minimumSpeedMultiplier ?? 1;
2415
+ }
2416
+ out.behaviors.push({
2417
+ type: "movePath",
2418
+ config: {
2419
+ path: config.extraData.path,
2420
+ speed: list,
2421
+ minMult: mult
2422
+ }
2423
+ });
2424
+ } else {
2425
+ if (config.speed) {
2426
+ if ("start" in config.speed) {
2427
+ if (config.speed.start === config.speed.end) {
2428
+ out.behaviors.push({
2429
+ type: "moveSpeedStatic",
2430
+ config: {
2431
+ min: config.speed.start * (config.speed.minimumSpeedMultiplier ?? 1),
2432
+ max: config.speed.start
2433
+ }
2434
+ });
2435
+ } else {
2436
+ const list = {
2437
+ list: [
2438
+ { time: 0, value: config.speed.start },
2439
+ { time: 1, value: config.speed.end }
2440
+ ]
2441
+ };
2442
+ out.behaviors.push({
2443
+ type: "moveSpeed",
2444
+ config: { speed: list, minMult: config.speed.minimumSpeedMultiplier }
2445
+ });
2446
+ }
2447
+ } else if (config.speed.list.length === 1) {
2448
+ out.behaviors.push({
2449
+ type: "moveSpeedStatic",
2450
+ config: {
2451
+ min: config.speed.list[0].value * (config.minimumSpeedMultiplier ?? 1),
2452
+ max: config.speed.list[0].value
2453
+ }
2454
+ });
2455
+ } else {
2456
+ out.behaviors.push({
2457
+ type: "moveSpeed",
2458
+ config: { speed: config.speed, minMult: config.minimumSpeedMultiplier ?? 1 }
2459
+ });
2460
+ }
2461
+ }
2462
+ }
2463
+ if (config.scale) {
2464
+ if ("start" in config.scale) {
2465
+ const mult = config.scale.minimumScaleMultiplier ?? 1;
2466
+ if (config.scale.start === config.scale.end) {
2467
+ out.behaviors.push({
2468
+ type: "scaleStatic",
2469
+ config: {
2470
+ min: config.scale.start * mult,
2471
+ max: config.scale.start
2472
+ }
2473
+ });
2474
+ } else {
2475
+ const list = {
2476
+ list: [
2477
+ { time: 0, value: config.scale.start },
2478
+ { time: 1, value: config.scale.end }
2479
+ ]
2480
+ };
2481
+ out.behaviors.push({
2482
+ type: "scale",
2483
+ config: { scale: list, minMult: mult }
2484
+ });
2485
+ }
2486
+ } else if (config.scale.list.length === 1) {
2487
+ const mult = config.minimumScaleMultiplier ?? 1;
2488
+ const scale = config.scale.list[0].value;
2489
+ out.behaviors.push({
2490
+ type: "scaleStatic",
2491
+ config: { min: scale * mult, max: scale }
2492
+ });
2493
+ } else {
2494
+ out.behaviors.push({
2495
+ type: "scale",
2496
+ config: { scale: config.scale, minMult: config.minimumScaleMultiplier ?? 1 }
2497
+ });
2498
+ }
2499
+ }
2500
+ if (config.color) {
2501
+ if ("start" in config.color) {
2502
+ if (config.color.start === config.color.end) {
2503
+ if (config.color.start !== "ffffff") {
2504
+ out.behaviors.push({
2505
+ type: "colorStatic",
2506
+ config: { color: config.color.start }
2507
+ });
2508
+ }
2509
+ } else {
2510
+ const list = {
2511
+ list: [
2512
+ { time: 0, value: config.color.start },
2513
+ { time: 1, value: config.color.end }
2514
+ ]
2515
+ };
2516
+ out.behaviors.push({
2517
+ type: "color",
2518
+ config: { color: list }
2519
+ });
2520
+ }
2521
+ } else if (config.color.list.length === 1) {
2522
+ if (config.color.list[0].value !== "ffffff") {
2523
+ out.behaviors.push({
2524
+ type: "colorStatic",
2525
+ config: { color: config.color.list[0].value }
2526
+ });
2527
+ }
2528
+ } else {
2529
+ out.behaviors.push({
2530
+ type: "color",
2531
+ config: { color: config.color }
2532
+ });
2533
+ }
2534
+ }
2535
+ if (config.rotationAcceleration || ((_b = config.rotationSpeed) == null ? void 0 : _b.min) || ((_c = config.rotationSpeed) == null ? void 0 : _c.max)) {
2536
+ out.behaviors.push({
2537
+ type: "rotation",
2538
+ config: {
2539
+ accel: config.rotationAcceleration || 0,
2540
+ minSpeed: ((_d = config.rotationSpeed) == null ? void 0 : _d.min) || 0,
2541
+ maxSpeed: ((_e = config.rotationSpeed) == null ? void 0 : _e.max) || 0,
2542
+ minStart: ((_f = config.startRotation) == null ? void 0 : _f.min) || 0,
2543
+ maxStart: ((_g = config.startRotation) == null ? void 0 : _g.max) || 0
2544
+ }
2545
+ });
2546
+ } else if (((_h = config.startRotation) == null ? void 0 : _h.min) || ((_i = config.startRotation) == null ? void 0 : _i.max)) {
2547
+ out.behaviors.push({
2548
+ type: "rotationStatic",
2549
+ config: {
2550
+ min: ((_j = config.startRotation) == null ? void 0 : _j.min) || 0,
2551
+ max: ((_k = config.startRotation) == null ? void 0 : _k.max) || 0
2552
+ }
2553
+ });
2554
+ }
2555
+ if (config.noRotation) {
2556
+ out.behaviors.push({
2557
+ type: "noRotation",
2558
+ config: {}
2559
+ });
2560
+ }
2561
+ if (config.blendMode && config.blendMode !== "normal") {
2562
+ out.behaviors.push({
2563
+ type: "blendMode",
2564
+ config: {
2565
+ blendMode: config.blendMode
2566
+ }
2567
+ });
2568
+ }
2569
+ if (Array.isArray(art) && typeof art[0] !== "string" && "framerate" in art[0]) {
2570
+ for (let i = 0; i < art.length; ++i) {
2571
+ if (art[i].framerate === "matchLife") {
2572
+ art[i].framerate = -1;
2573
+ }
2574
+ }
2575
+ out.behaviors.push({
2576
+ type: "animatedRandom",
2577
+ config: {
2578
+ anims: art
2579
+ }
2580
+ });
2581
+ } else if (typeof art !== "string" && "framerate" in art) {
2582
+ if (art.framerate === "matchLife") {
2583
+ art.framerate = -1;
2584
+ }
2585
+ out.behaviors.push({
2586
+ type: "animatedSingle",
2587
+ config: {
2588
+ anim: art
2589
+ }
2590
+ });
2591
+ } else if (config.orderedArt && Array.isArray(art)) {
2592
+ out.behaviors.push({
2593
+ type: "textureOrdered",
2594
+ config: {
2595
+ textures: art
2596
+ }
2597
+ });
2598
+ } else if (Array.isArray(art)) {
2599
+ out.behaviors.push({
2600
+ type: "textureRandom",
2601
+ config: {
2602
+ textures: art
2603
+ }
2604
+ });
2605
+ } else {
2606
+ out.behaviors.push({
2607
+ type: "textureSingle",
2608
+ config: {
2609
+ texture: art
2610
+ }
2611
+ });
2612
+ }
2613
+ if (config.spawnType === "burst") {
2614
+ out.behaviors.push({
2615
+ type: "spawnBurst",
2616
+ config: {
2617
+ start: config.angleStart || 0,
2618
+ spacing: config.particleSpacing,
2619
+ // older formats bursted from a single point
2620
+ distance: 0
2621
+ }
2622
+ });
2623
+ } else if (config.spawnType === "point") {
2624
+ out.behaviors.push({
2625
+ type: "spawnPoint",
2626
+ config: {}
2627
+ });
2628
+ } else {
2629
+ let shape;
2630
+ if (config.spawnType === "ring") {
2631
+ shape = {
2632
+ type: "torus",
2633
+ data: {
2634
+ x: config.spawnCircle.x,
2635
+ y: config.spawnCircle.y,
2636
+ radius: config.spawnCircle.r,
2637
+ innerRadius: config.spawnCircle.minR,
2638
+ affectRotation: true
2639
+ }
2640
+ };
2641
+ } else if (config.spawnType === "circle") {
2642
+ shape = {
2643
+ type: "torus",
2644
+ data: {
2645
+ x: config.spawnCircle.x,
2646
+ y: config.spawnCircle.y,
2647
+ radius: config.spawnCircle.r,
2648
+ innerRadius: 0,
2649
+ affectRotation: false
2650
+ }
2651
+ };
2652
+ } else if (config.spawnType === "rect") {
2653
+ shape = {
2654
+ type: "rect",
2655
+ data: config.spawnRect
2656
+ };
2657
+ } else if (config.spawnType === "polygonalChain") {
2658
+ shape = {
2659
+ type: "polygonalChain",
2660
+ data: config.spawnPolygon
2661
+ };
2662
+ }
2663
+ if (shape) {
2664
+ out.behaviors.push({
2665
+ type: "spawnShape",
2666
+ config: shape
2667
+ });
2668
+ }
2669
+ }
2670
+ return out;
2671
+ }
2672
+ var SpineParticle = class extends Container {
2673
+ /**
2674
+ * The Spine instance for this particle.
2675
+ */
2676
+ spine;
2677
+ /**
2678
+ * The emitter that controls this particle.
2679
+ * Using any to avoid circular dependency with SpineEmitter.
2680
+ */
2681
+ emitter;
2682
+ /**
2683
+ * The maximum lifetime of this particle, in seconds.
2684
+ */
2685
+ maxLife;
2686
+ /**
2687
+ * The current age of the particle, in seconds.
2688
+ */
2689
+ age;
2690
+ /**
2691
+ * The current age of the particle as a normalized value between 0 and 1.
2692
+ */
2693
+ agePercent;
2694
+ /**
2695
+ * One divided by the max life of the particle, saved for slightly faster math.
2696
+ */
2697
+ oneOverLife;
2698
+ /**
2699
+ * Reference to the next particle in the list.
2700
+ */
2701
+ next;
2702
+ /**
2703
+ * Reference to the previous particle in the list.
2704
+ */
2705
+ prev;
2706
+ prevChild;
2707
+ nextChild;
2708
+ /**
2709
+ * Static per-particle configuration for behaviors to use. Is not cleared when recycling.
2710
+ */
2711
+ config;
2712
+ /**
2713
+ * @param emitter The emitter that controls this particle.
2714
+ */
2715
+ constructor(emitter) {
2716
+ super();
2717
+ this.prevChild = this.nextChild = null;
2718
+ this.emitter = emitter;
2719
+ this.config = {};
2720
+ this.maxLife = 0;
2721
+ this.age = 0;
2722
+ this.agePercent = 0;
2723
+ this.oneOverLife = 0;
2724
+ this.next = null;
2725
+ this.prev = null;
2726
+ this.init = this.init;
2727
+ this.kill = this.kill;
2728
+ }
2729
+ /**
2730
+ * Sets the Spine instance for this particle.
2731
+ * Called by SpineEmitter when creating the particle.
2732
+ */
2733
+ setSpine(spine) {
2734
+ this.spine = spine;
2735
+ this.addChild(spine);
2736
+ }
2737
+ /**
2738
+ * Initializes the particle for use, based on the properties that have to
2739
+ * have been set already on the particle.
2740
+ */
2741
+ init(maxLife) {
2742
+ this.maxLife = maxLife;
2743
+ this.age = this.agePercent = 0;
2744
+ this.rotation = 0;
2745
+ this.position.x = this.position.y = 0;
2746
+ this.scale.x = this.scale.y = 1;
2747
+ this.alpha = 1;
2748
+ this.oneOverLife = 1 / this.maxLife;
2749
+ this.visible = true;
2750
+ if (this.spine) {
2751
+ this.spine.state.clearTracks();
2752
+ this.spine.skeleton.setToSetupPose();
2753
+ }
2754
+ }
2755
+ /**
2756
+ * Kills the particle, removing it from the display list
2757
+ * and telling the emitter to recycle it.
2758
+ */
2759
+ kill() {
2760
+ this.emitter.recycle(this);
2761
+ }
2762
+ /**
2763
+ * Destroys the particle, removing references and preventing future use.
2764
+ */
2765
+ destroy() {
2766
+ if (this.parent) {
2767
+ this.parent.removeChild(this);
2768
+ }
2769
+ if (this.spine) {
2770
+ this.spine.destroy();
2771
+ }
2772
+ this.emitter = this.next = this.prev = null;
2773
+ super.destroy();
2774
+ }
2775
+ };
2776
+ var SpineEmitter = class extends Emitter {
2777
+ /**
2778
+ * Skeleton asset key for creating Spine instances
2779
+ */
2780
+ skeletonKey;
2781
+ /**
2782
+ * Atlas asset key for creating Spine instances
2783
+ */
2784
+ atlasKey;
2785
+ constructor(particleParent, config) {
2786
+ const fullConfig = {
2787
+ ...config,
2788
+ pos: config.pos ?? { x: 0, y: 0 }
2789
+ };
2790
+ super(particleParent, fullConfig);
2791
+ this.skeletonKey = "";
2792
+ this.atlasKey = "";
2793
+ if (config.spineData) {
2794
+ this.skeletonKey = config.spineData.skeleton;
2795
+ this.atlasKey = config.spineData.atlas;
2796
+ }
2797
+ }
2798
+ /**
2799
+ * Override createParticle to return SpineParticle instead of Particle.
2800
+ * This is called by the base Emitter when spawning new particles.
2801
+ * Returns any to satisfy base class signature while actually returning SpineParticle.
2802
+ */
2803
+ createParticle() {
2804
+ const particle = new SpineParticle(this);
2805
+ const spine = Spine.from({
2806
+ skeleton: this.skeletonKey,
2807
+ atlas: this.atlasKey
2808
+ });
2809
+ particle.setSpine(spine);
2810
+ return particle;
2811
+ }
2812
+ };
2813
+
2814
+ // particle/index.ts
2815
+ Emitter.registerBehavior(AccelerationBehavior);
2816
+ Emitter.registerBehavior(AlphaBehavior);
2817
+ Emitter.registerBehavior(StaticAlphaBehavior);
2818
+ Emitter.registerBehavior(RandomAnimatedTextureBehavior);
2819
+ Emitter.registerBehavior(SingleAnimatedTextureBehavior);
2820
+ Emitter.registerBehavior(BlendModeBehavior);
2821
+ Emitter.registerBehavior(BurstSpawnBehavior);
2822
+ Emitter.registerBehavior(ColorBehavior);
2823
+ Emitter.registerBehavior(StaticColorBehavior);
2824
+ Emitter.registerBehavior(OrderedTextureBehavior);
2825
+ Emitter.registerBehavior(PathBehavior);
2826
+ Emitter.registerBehavior(PointSpawnBehavior);
2827
+ Emitter.registerBehavior(RandomTextureBehavior);
2828
+ Emitter.registerBehavior(RotationBehavior);
2829
+ Emitter.registerBehavior(StaticRotationBehavior);
2830
+ Emitter.registerBehavior(NoRotationBehavior);
2831
+ Emitter.registerBehavior(ScaleBehavior);
2832
+ Emitter.registerBehavior(StaticScaleBehavior);
2833
+ Emitter.registerBehavior(ShapeSpawnBehavior);
2834
+ Emitter.registerBehavior(SingleTextureBehavior);
2835
+ Emitter.registerBehavior(SpeedBehavior);
2836
+ Emitter.registerBehavior(StaticSpeedBehavior);
2837
+ Emitter.registerBehavior(MultiStateAnimatedTextureBehavior);
2838
+ Emitter.registerBehavior(ZIndexBehavior);
2839
+ Emitter.registerBehavior(SpineAnimationBehavior);
2840
+ Emitter.registerBehavior(SpineRandomSkinBehavior);
2841
+ Emitter.registerBehavior(SpineAnimationSequenceBehavior);
2842
+
2843
+ export { Emitter, Particle, ParticleUtils_exports as ParticleUtils, PropertyList, PropertyNode, SpineEmitter, SpineParticle, behaviors_exports as behaviors, upgradeConfig };
2844
+ //# sourceMappingURL=index.js.map
2845
+ //# sourceMappingURL=index.js.map