@nayan-ui/games 1.20.0 → 1.21.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 (552) hide show
  1. package/lib/module/games/arrows/Arrows.js +1 -1
  2. package/lib/module/games/arrows/ArrowsScene.js +1 -1
  3. package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -1
  4. package/lib/module/games/balloon-blaster/BalloonBlasterScene.js +1 -1
  5. package/lib/module/games/bike-racing/BikeMeshes.js +1 -1
  6. package/lib/module/games/bike-racing/BikeRacing.js +1 -1
  7. package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -1
  8. package/lib/module/games/bike-racing/BikeRacingScene.js +1 -1
  9. package/lib/module/games/block-blast/BlockBlast.js +1 -1
  10. package/lib/module/games/block-blast/BlockBlastScene.js +1 -1
  11. package/lib/module/games/block-breaker/BlockBreaker.js +1 -1
  12. package/lib/module/games/block-breaker/BlockBreakerScene.js +1 -1
  13. package/lib/module/games/bluk/Bluk.js +1 -1
  14. package/lib/module/games/bluk/BlukScene.js +1 -1
  15. package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -1
  16. package/lib/module/games/bubble-shooter/BubbleShooterScene.js +1 -1
  17. package/lib/module/games/candy-crush/CandyCrush.js +1 -1
  18. package/lib/module/games/candy-crush/CandyCrushScene.js +1 -1
  19. package/lib/module/games/car-racing/CarMeshes.js +1 -1
  20. package/lib/module/games/car-racing/CarRacing.js +1 -1
  21. package/lib/module/games/car-racing/CarRacingScene.js +1 -1
  22. package/lib/module/games/chameleon-run/ChameleonRun.js +1 -1
  23. package/lib/module/games/chameleon-run/ChameleonRunBackdrop.js +1 -1
  24. package/lib/module/games/chameleon-run/ChameleonRunMeshes.js +1 -1
  25. package/lib/module/games/checkers/Checkers.js +1 -1
  26. package/lib/module/games/checkers/CheckersScene.js +1 -1
  27. package/lib/module/games/color-switch/ColorSwitch.js +1 -1
  28. package/lib/module/games/color-switch/ColorSwitchScene.js +1 -1
  29. package/lib/module/games/colors-sort/ColorsSort.js +1 -1
  30. package/lib/module/games/colors-sort/ColorsSortScene.js +1 -1
  31. package/lib/module/games/connect-em-all/ConnectEmAll.js +1 -1
  32. package/lib/module/games/connect-em-all/ConnectEmAllScene.js +1 -1
  33. package/lib/module/games/crossy-road/CrossyRoad.js +1 -1
  34. package/lib/module/games/crossy-road/CrossyRoadMeshes.js +1 -1
  35. package/lib/module/games/crossy-road/CrossyRoadPerson.js +1 -1
  36. package/lib/module/games/dino-jump/DinoJump.js +1 -1
  37. package/lib/module/games/dino-jump/DinoJumpScene.js +1 -1
  38. package/lib/module/games/dots-and-boxes/DotsAndBoxes.js +1 -1
  39. package/lib/module/games/dots-and-boxes/DotsAndBoxesScene.js +1 -1
  40. package/lib/module/games/falling-sticks/FallingSticks.js +1 -1
  41. package/lib/module/games/falling-sticks/FallingSticksScene.js +1 -1
  42. package/lib/module/games/find-different-number/FindDifferentNumber.js +1 -1
  43. package/lib/module/games/find-different-number/FindDifferentNumberScene.js +1 -1
  44. package/lib/module/games/flappy-bird/FlappyBird.js +1 -1
  45. package/lib/module/games/flappy-bird/FlappyBirdScene.js +1 -1
  46. package/lib/module/games/fruit-merger/FruitMerger.js +1 -1
  47. package/lib/module/games/fruit-merger/FruitMergerScene.js +1 -1
  48. package/lib/module/games/fruit-ninja/FruitNinja.js +1 -1
  49. package/lib/module/games/fruit-ninja/FruitNinjaScene.js +1 -1
  50. package/lib/module/games/fruit-ninja/FruitNinjaWorld.js +1 -1
  51. package/lib/module/games/game-2048/Game2048.js +1 -1
  52. package/lib/module/games/game-2048/Game2048Scene.js +1 -1
  53. package/lib/module/games/knife-hit/KnifeHit.js +1 -1
  54. package/lib/module/games/knife-hit/KnifeHitScene.js +1 -1
  55. package/lib/module/games/ludo-king/LudoKing.js +1 -1
  56. package/lib/module/games/ludo-king/LudoKingScene.js +1 -1
  57. package/lib/module/games/maze-runner/MazeRunner.js +1 -1
  58. package/lib/module/games/maze-runner/MazeRunnerScene.js +1 -1
  59. package/lib/module/games/memory-match/MemoryMatch.js +1 -1
  60. package/lib/module/games/memory-match/MemoryMatchScene.js +1 -1
  61. package/lib/module/games/mine-sweeper/MineSweeper.js +1 -1
  62. package/lib/module/games/mine-sweeper/MineSweeperScene.js +1 -1
  63. package/lib/module/games/mob-control/MobControl.js +1 -1
  64. package/lib/module/games/mob-control/MobControlGame.js +1 -1
  65. package/lib/module/games/mob-control/MobControlMeshes.js +1 -1
  66. package/lib/module/games/mob-control/MobControlRenderer.js +1 -1
  67. package/lib/module/games/mob-control/MobControlRules.js +1 -1
  68. package/lib/module/games/mob-control/MobControlScene.js +1 -1
  69. package/lib/module/games/nuts-and-bolts/NutsAndBolts.js +1 -1
  70. package/lib/module/games/nuts-and-bolts/NutsAndBoltsScene.js +1 -1
  71. package/lib/module/games/pac-man/PacMan.js +1 -1
  72. package/lib/module/games/pac-man/PacManGame.js +1 -1
  73. package/lib/module/games/pac-man/PacManScene.js +1 -1
  74. package/lib/module/games/paper-io/PaperIo.js +1 -1
  75. package/lib/module/games/paper-io/PaperIoMeshes.js +1 -1
  76. package/lib/module/games/paper-io/PaperIoScene.js +1 -1
  77. package/lib/module/games/penguin-run/PenguinMeshes.js +1 -1
  78. package/lib/module/games/penguin-run/PenguinRun.js +1 -1
  79. package/lib/module/games/penguin-run/PenguinRunScene.js +1 -1
  80. package/lib/module/games/perfect-circle/PerfectCircle.js +1 -1
  81. package/lib/module/games/perfect-circle/PerfectCircleScene.js +1 -1
  82. package/lib/module/games/pipe-connect/PipeConnect.js +1 -1
  83. package/lib/module/games/pipe-connect/PipeConnectScene.js +1 -1
  84. package/lib/module/games/play-with-tua/PlayWithTua.js +1 -1
  85. package/lib/module/games/popit-fidget/PopitFidget.js +1 -1
  86. package/lib/module/games/popit-fidget/PopitFidgetScene.js +1 -1
  87. package/lib/module/games/reversi/Reversi.js +1 -1
  88. package/lib/module/games/reversi/ReversiScene.js +1 -1
  89. package/lib/module/games/search-grid/SearchGrid.js +1 -1
  90. package/lib/module/games/search-grid/SearchGridScene.js +1 -1
  91. package/lib/module/games/shared/BackdropCard.js +1 -1
  92. package/lib/module/games/shared/EngineBackdrop.js +1 -1
  93. package/lib/module/games/shared/EngineBlasts.js +1 -1
  94. package/lib/module/games/shared/EngineBlocks.js +1 -1
  95. package/lib/module/games/shared/EngineDice.js +1 -1
  96. package/lib/module/games/shared/EngineFruits.js +1 -1
  97. package/lib/module/games/shared/EngineGameLoader.js +1 -1
  98. package/lib/module/games/shared/EngineGameScreen.js +1 -1
  99. package/lib/module/games/shared/EngineGlyphs.js +1 -1
  100. package/lib/module/games/shared/EngineHud.js +1 -1
  101. package/lib/module/games/shared/EngineMeadow.js +1 -1
  102. package/lib/module/games/shared/EngineTouchSurface.js +1 -1
  103. package/lib/module/games/shared/GameActivity.js +1 -1
  104. package/lib/module/games/shared/GameLoading.js +1 -1
  105. package/lib/module/games/shared/GameLoadingTransition.js +1 -1
  106. package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -1
  107. package/lib/module/games/sliding-numbers/SlidingNumbersScene.js +1 -1
  108. package/lib/module/games/snake-3d/Snake3D.js +1 -1
  109. package/lib/module/games/snake-3d/Snake3DScene.js +1 -1
  110. package/lib/module/games/snakes-and-ladders/SnakesAndLadders.js +1 -1
  111. package/lib/module/games/snakes-and-ladders/SnakesAndLaddersScene.js +1 -1
  112. package/lib/module/games/space-fighter/SpaceFighter.js +1 -1
  113. package/lib/module/games/space-fighter/SpaceFighterScene.js +1 -1
  114. package/lib/module/games/spider-solitaire/SpiderSolitaire.js +1 -1
  115. package/lib/module/games/spider-solitaire/SpiderSolitaireScene.js +1 -1
  116. package/lib/module/games/stack-tower/StackTower.js +1 -1
  117. package/lib/module/games/stack-tower/StackTowerScene.js +1 -1
  118. package/lib/module/games/sudoku/Sudoku.js +1 -1
  119. package/lib/module/games/sudoku/SudokuScene.js +1 -1
  120. package/lib/module/games/tangram/Tangram.js +1 -1
  121. package/lib/module/games/tangram/TangramScene.js +1 -1
  122. package/lib/module/games/tank-1990/Tank1990.js +1 -1
  123. package/lib/module/games/tank-1990/Tank1990Scene.js +1 -1
  124. package/lib/module/games/tic-tac-toe/TicTacToe.js +1 -1
  125. package/lib/module/games/tic-tac-toe/TicTacToeScene.js +1 -1
  126. package/lib/module/games/tile-home/TileHome.js +1 -1
  127. package/lib/module/games/tile-home/TileHomeScene.js +1 -1
  128. package/lib/module/games/treasure-hunt/TreasureHunt.js +1 -1
  129. package/lib/module/games/treasure-hunt/TreasureHuntConstants.js +1 -1
  130. package/lib/module/games/treasure-hunt/TreasureHuntModel.js +1 -1
  131. package/lib/module/games/treasure-hunt/TreasureHuntScene.js +1 -1
  132. package/lib/module/games/whack-a-mole/WhackAMole.js +1 -1
  133. package/lib/module/games/whack-a-mole/WhackAMoleScene.js +1 -1
  134. package/lib/module/helpers/GameSettingsModal.js +1 -1
  135. package/lib/module/helpers/GameTheme.js +1 -1
  136. package/package.json +1 -2
  137. package/src/assets/fonts/Inter-SemiBold.ttf +0 -0
  138. package/src/assets/models/explorer/explorer.glb +0 -0
  139. package/src/assets/models/explorer/params.json +0 -51
  140. package/src/assets/models/explorer/source.json +0 -222
  141. package/src/assets/models/play-with-tua/play-with-tua.glb +0 -0
  142. package/src/assets/models/play-with-tua/sources.json +0 -141
  143. package/src/assets/sfx/balloon_pop.wav +0 -0
  144. package/src/assets/sfx/blocked.wav +0 -0
  145. package/src/assets/sfx/boing.wav +0 -0
  146. package/src/assets/sfx/bonus.wav +0 -0
  147. package/src/assets/sfx/boom.wav +0 -0
  148. package/src/assets/sfx/bump.wav +0 -0
  149. package/src/assets/sfx/cannon.wav +0 -0
  150. package/src/assets/sfx/capture.wav +0 -0
  151. package/src/assets/sfx/card_flip.wav +0 -0
  152. package/src/assets/sfx/card_place.wav +0 -0
  153. package/src/assets/sfx/catch.wav +0 -0
  154. package/src/assets/sfx/chime.wav +0 -0
  155. package/src/assets/sfx/chomp.wav +0 -0
  156. package/src/assets/sfx/chomp_alt.wav +0 -0
  157. package/src/assets/sfx/clack.wav +0 -0
  158. package/src/assets/sfx/clang.wav +0 -0
  159. package/src/assets/sfx/clash.wav +0 -0
  160. package/src/assets/sfx/click.wav +0 -0
  161. package/src/assets/sfx/coin.wav +0 -0
  162. package/src/assets/sfx/combo.wav +0 -0
  163. package/src/assets/sfx/crash.wav +0 -0
  164. package/src/assets/sfx/crunch.wav +0 -0
  165. package/src/assets/sfx/dance.wav +0 -0
  166. package/src/assets/sfx/deselect.wav +0 -0
  167. package/src/assets/sfx/dice_roll.wav +0 -0
  168. package/src/assets/sfx/die.wav +0 -0
  169. package/src/assets/sfx/draw.wav +0 -0
  170. package/src/assets/sfx/drop.wav +0 -0
  171. package/src/assets/sfx/eat.wav +0 -0
  172. package/src/assets/sfx/engine.wav +0 -0
  173. package/src/assets/sfx/error.wav +0 -0
  174. package/src/assets/sfx/flag.wav +0 -0
  175. package/src/assets/sfx/flap.wav +0 -0
  176. package/src/assets/sfx/flip_disc.wav +0 -0
  177. package/src/assets/sfx/footstep_run.wav +0 -0
  178. package/src/assets/sfx/footstep_walk.wav +0 -0
  179. package/src/assets/sfx/game_over.wav +0 -0
  180. package/src/assets/sfx/gate.wav +0 -0
  181. package/src/assets/sfx/hit.wav +0 -0
  182. package/src/assets/sfx/hop.wav +0 -0
  183. package/src/assets/sfx/hurt.wav +0 -0
  184. package/src/assets/sfx/invalid.wav +0 -0
  185. package/src/assets/sfx/jump.wav +0 -0
  186. package/src/assets/sfx/ladder.wav +0 -0
  187. package/src/assets/sfx/land.wav +0 -0
  188. package/src/assets/sfx/laugh.wav +0 -0
  189. package/src/assets/sfx/lose.wav +0 -0
  190. package/src/assets/sfx/merge.wav +0 -0
  191. package/src/assets/sfx/miss.wav +0 -0
  192. package/src/assets/sfx/nitro.wav +0 -0
  193. package/src/assets/sfx/pew.wav +0 -0
  194. package/src/assets/sfx/place.wav +0 -0
  195. package/src/assets/sfx/pling.wav +0 -0
  196. package/src/assets/sfx/point.wav +0 -0
  197. package/src/assets/sfx/pop.wav +0 -0
  198. package/src/assets/sfx/pop_soft.wav +0 -0
  199. package/src/assets/sfx/power_up.wav +0 -0
  200. package/src/assets/sfx/reveal.wav +0 -0
  201. package/src/assets/sfx/robot.wav +0 -0
  202. package/src/assets/sfx/rotate.wav +0 -0
  203. package/src/assets/sfx/run_steps.wav +0 -0
  204. package/src/assets/sfx/select.wav +0 -0
  205. package/src/assets/sfx/shuffle.wav +0 -0
  206. package/src/assets/sfx/six.wav +0 -0
  207. package/src/assets/sfx/slice.wav +0 -0
  208. package/src/assets/sfx/slide.wav +0 -0
  209. package/src/assets/sfx/snake.wav +0 -0
  210. package/src/assets/sfx/snap.wav +0 -0
  211. package/src/assets/sfx/splash.wav +0 -0
  212. package/src/assets/sfx/star.wav +0 -0
  213. package/src/assets/sfx/start.wav +0 -0
  214. package/src/assets/sfx/swoosh.wav +0 -0
  215. package/src/assets/sfx/tap.wav +0 -0
  216. package/src/assets/sfx/thud.wav +0 -0
  217. package/src/assets/sfx/thunk.wav +0 -0
  218. package/src/assets/sfx/tick.wav +0 -0
  219. package/src/assets/sfx/time_up.wav +0 -0
  220. package/src/assets/sfx/tock.wav +0 -0
  221. package/src/assets/sfx/walk_steps.wav +0 -0
  222. package/src/assets/sfx/warning.wav +0 -0
  223. package/src/assets/sfx/whack.wav +0 -0
  224. package/src/assets/sfx/whoosh.wav +0 -0
  225. package/src/assets/sfx/win.wav +0 -0
  226. package/src/assets/sfx/zap.wav +0 -0
  227. package/src/assets/textures/ad_bolt.png +0 -0
  228. package/src/assets/textures/ad_bubbles.png +0 -0
  229. package/src/assets/textures/ad_chevrons.png +0 -0
  230. package/src/assets/textures/asphalt.png +0 -0
  231. package/src/assets/textures/bark.jpg +0 -0
  232. package/src/assets/textures/explorer-atlas.png +0 -0
  233. package/src/assets/textures/facade.png +0 -0
  234. package/src/assets/textures/grass.png +0 -0
  235. package/src/assets/textures/leaves.png +0 -0
  236. package/src/assets/textures/limestone.jpg +0 -0
  237. package/src/assets/textures/meadow.jpg +0 -0
  238. package/src/assets/textures/nature-sources.json +0 -87
  239. package/src/assets/textures/pine.png +0 -0
  240. package/src/assets/textures/river.jpg +0 -0
  241. package/src/assets/textures/soft_glow.png +0 -0
  242. package/src/games/arrows/Arrows.tsx +0 -69
  243. package/src/games/arrows/ArrowsConstants.ts +0 -107
  244. package/src/games/arrows/ArrowsGame.ts +0 -735
  245. package/src/games/arrows/ArrowsScene.ts +0 -395
  246. package/src/games/balloon-blaster/BalloonBlaster.tsx +0 -75
  247. package/src/games/balloon-blaster/BalloonBlasterConstants.ts +0 -79
  248. package/src/games/balloon-blaster/BalloonBlasterGame.ts +0 -287
  249. package/src/games/balloon-blaster/BalloonBlasterPhysics.ts +0 -95
  250. package/src/games/balloon-blaster/BalloonBlasterScene.ts +0 -225
  251. package/src/games/bike-racing/BikeMeshes.ts +0 -273
  252. package/src/games/bike-racing/BikeRacing.tsx +0 -211
  253. package/src/games/bike-racing/BikeRacingConstants.ts +0 -103
  254. package/src/games/bike-racing/BikeRacingGame.ts +0 -557
  255. package/src/games/bike-racing/BikeRacingScene.ts +0 -119
  256. package/src/games/block-blast/BlockBlast.tsx +0 -73
  257. package/src/games/block-blast/BlockBlastConstants.ts +0 -179
  258. package/src/games/block-blast/BlockBlastGame.ts +0 -471
  259. package/src/games/block-blast/BlockBlastScene.ts +0 -156
  260. package/src/games/block-breaker/BlockBreaker.tsx +0 -79
  261. package/src/games/block-breaker/BlockBreakerConstants.ts +0 -139
  262. package/src/games/block-breaker/BlockBreakerGame.ts +0 -459
  263. package/src/games/block-breaker/BlockBreakerScene.ts +0 -257
  264. package/src/games/bluk/Bluk.tsx +0 -82
  265. package/src/games/bluk/BlukConstants.ts +0 -121
  266. package/src/games/bluk/BlukGame.ts +0 -323
  267. package/src/games/bluk/BlukRules.ts +0 -154
  268. package/src/games/bluk/BlukScene.ts +0 -514
  269. package/src/games/bubble-shooter/BubbleShooter.tsx +0 -76
  270. package/src/games/bubble-shooter/BubbleShooterConstants.ts +0 -103
  271. package/src/games/bubble-shooter/BubbleShooterGame.ts +0 -459
  272. package/src/games/bubble-shooter/BubbleShooterScene.ts +0 -158
  273. package/src/games/candy-crush/CandyCrush.tsx +0 -77
  274. package/src/games/candy-crush/CandyCrushConstants.ts +0 -94
  275. package/src/games/candy-crush/CandyCrushGame.ts +0 -477
  276. package/src/games/candy-crush/CandyCrushScene.ts +0 -209
  277. package/src/games/car-racing/CarMeshes.ts +0 -440
  278. package/src/games/car-racing/CarRacing.tsx +0 -211
  279. package/src/games/car-racing/CarRacingConstants.ts +0 -167
  280. package/src/games/car-racing/CarRacingFacade.ts +0 -40
  281. package/src/games/car-racing/CarRacingGame.ts +0 -539
  282. package/src/games/car-racing/CarRacingScene.ts +0 -1026
  283. package/src/games/car-racing/CarRacingScenery.ts +0 -265
  284. package/src/games/chameleon-run/ChameleonRun.tsx +0 -96
  285. package/src/games/chameleon-run/ChameleonRunBackdrop.ts +0 -186
  286. package/src/games/chameleon-run/ChameleonRunConstants.ts +0 -47
  287. package/src/games/chameleon-run/ChameleonRunGame.ts +0 -309
  288. package/src/games/chameleon-run/ChameleonRunMeshes.ts +0 -305
  289. package/src/games/chameleon-run/ChameleonRunRules.ts +0 -252
  290. package/src/games/chameleon-run/ChameleonRunScene.ts +0 -310
  291. package/src/games/checkers/Checkers.tsx +0 -83
  292. package/src/games/checkers/CheckersAI.ts +0 -255
  293. package/src/games/checkers/CheckersConstants.ts +0 -68
  294. package/src/games/checkers/CheckersGame.ts +0 -322
  295. package/src/games/checkers/CheckersRules.ts +0 -167
  296. package/src/games/checkers/CheckersScene.ts +0 -308
  297. package/src/games/color-switch/ColorSwitch.tsx +0 -75
  298. package/src/games/color-switch/ColorSwitchConstants.ts +0 -61
  299. package/src/games/color-switch/ColorSwitchGame.ts +0 -329
  300. package/src/games/color-switch/ColorSwitchScene.ts +0 -220
  301. package/src/games/colors-sort/ColorsSort.tsx +0 -82
  302. package/src/games/colors-sort/ColorsSortConstants.ts +0 -119
  303. package/src/games/colors-sort/ColorsSortGame.ts +0 -246
  304. package/src/games/colors-sort/ColorsSortScene.ts +0 -315
  305. package/src/games/connect-em-all/ConnectEmAll.tsx +0 -70
  306. package/src/games/connect-em-all/ConnectEmAllConstants.ts +0 -77
  307. package/src/games/connect-em-all/ConnectEmAllGame.ts +0 -401
  308. package/src/games/connect-em-all/ConnectEmAllScene.ts +0 -235
  309. package/src/games/crossy-road/CrossyRoad.tsx +0 -74
  310. package/src/games/crossy-road/CrossyRoadCamera.ts +0 -59
  311. package/src/games/crossy-road/CrossyRoadConstants.ts +0 -132
  312. package/src/games/crossy-road/CrossyRoadGame.ts +0 -293
  313. package/src/games/crossy-road/CrossyRoadMeshes.ts +0 -195
  314. package/src/games/crossy-road/CrossyRoadPerson.ts +0 -198
  315. package/src/games/crossy-road/CrossyRoadRules.ts +0 -99
  316. package/src/games/crossy-road/CrossyRoadScene.ts +0 -355
  317. package/src/games/dino-jump/DinoJump.tsx +0 -77
  318. package/src/games/dino-jump/DinoJumpConstants.ts +0 -80
  319. package/src/games/dino-jump/DinoJumpGame.ts +0 -344
  320. package/src/games/dino-jump/DinoJumpScene.ts +0 -686
  321. package/src/games/dots-and-boxes/DotsAndBoxes.tsx +0 -83
  322. package/src/games/dots-and-boxes/DotsAndBoxesConstants.ts +0 -77
  323. package/src/games/dots-and-boxes/DotsAndBoxesGame.ts +0 -271
  324. package/src/games/dots-and-boxes/DotsAndBoxesScene.ts +0 -249
  325. package/src/games/falling-sticks/FallingSticks.tsx +0 -72
  326. package/src/games/falling-sticks/FallingSticksConstants.ts +0 -62
  327. package/src/games/falling-sticks/FallingSticksGame.ts +0 -220
  328. package/src/games/falling-sticks/FallingSticksRules.ts +0 -145
  329. package/src/games/falling-sticks/FallingSticksScene.ts +0 -245
  330. package/src/games/find-different-number/FindDifferentNumber.tsx +0 -74
  331. package/src/games/find-different-number/FindDifferentNumberConstants.ts +0 -74
  332. package/src/games/find-different-number/FindDifferentNumberGame.ts +0 -174
  333. package/src/games/find-different-number/FindDifferentNumberRules.ts +0 -43
  334. package/src/games/find-different-number/FindDifferentNumberScene.ts +0 -193
  335. package/src/games/flappy-bird/FlappyBird.tsx +0 -73
  336. package/src/games/flappy-bird/FlappyBirdConstants.ts +0 -95
  337. package/src/games/flappy-bird/FlappyBirdGame.ts +0 -375
  338. package/src/games/flappy-bird/FlappyBirdScene.ts +0 -630
  339. package/src/games/fruit-merger/FruitMerger.tsx +0 -73
  340. package/src/games/fruit-merger/FruitMergerConstants.ts +0 -102
  341. package/src/games/fruit-merger/FruitMergerGame.ts +0 -285
  342. package/src/games/fruit-merger/FruitMergerRules.ts +0 -286
  343. package/src/games/fruit-merger/FruitMergerScene.ts +0 -498
  344. package/src/games/fruit-ninja/FruitNinja.tsx +0 -129
  345. package/src/games/fruit-ninja/FruitNinjaConstants.ts +0 -107
  346. package/src/games/fruit-ninja/FruitNinjaGame.ts +0 -391
  347. package/src/games/fruit-ninja/FruitNinjaScene.ts +0 -319
  348. package/src/games/fruit-ninja/FruitNinjaWorld.ts +0 -17
  349. package/src/games/game-2048/Game2048.tsx +0 -84
  350. package/src/games/game-2048/Game2048Constants.ts +0 -68
  351. package/src/games/game-2048/Game2048Game.ts +0 -181
  352. package/src/games/game-2048/Game2048Rules.ts +0 -101
  353. package/src/games/game-2048/Game2048Scene.ts +0 -206
  354. package/src/games/knife-hit/KnifeHit.tsx +0 -78
  355. package/src/games/knife-hit/KnifeHitConstants.ts +0 -89
  356. package/src/games/knife-hit/KnifeHitGame.ts +0 -264
  357. package/src/games/knife-hit/KnifeHitScene.ts +0 -360
  358. package/src/games/ludo-king/LudoKing.tsx +0 -86
  359. package/src/games/ludo-king/LudoKingConstants.ts +0 -212
  360. package/src/games/ludo-king/LudoKingGame.ts +0 -326
  361. package/src/games/ludo-king/LudoKingRules.ts +0 -143
  362. package/src/games/ludo-king/LudoKingScene.ts +0 -397
  363. package/src/games/maze-runner/MazeRunner.tsx +0 -88
  364. package/src/games/maze-runner/MazeRunnerConstants.ts +0 -65
  365. package/src/games/maze-runner/MazeRunnerGame.ts +0 -176
  366. package/src/games/maze-runner/MazeRunnerRules.ts +0 -161
  367. package/src/games/maze-runner/MazeRunnerScene.ts +0 -245
  368. package/src/games/memory-match/MemoryMatch.tsx +0 -77
  369. package/src/games/memory-match/MemoryMatchConstants.ts +0 -105
  370. package/src/games/memory-match/MemoryMatchGame.ts +0 -222
  371. package/src/games/memory-match/MemoryMatchRules.ts +0 -38
  372. package/src/games/memory-match/MemoryMatchScene.ts +0 -268
  373. package/src/games/mine-sweeper/MineSweeper.tsx +0 -77
  374. package/src/games/mine-sweeper/MineSweeperConstants.ts +0 -94
  375. package/src/games/mine-sweeper/MineSweeperGame.ts +0 -234
  376. package/src/games/mine-sweeper/MineSweeperRules.ts +0 -67
  377. package/src/games/mine-sweeper/MineSweeperScene.ts +0 -262
  378. package/src/games/mob-control/MobControl.tsx +0 -73
  379. package/src/games/mob-control/MobControlConstants.ts +0 -106
  380. package/src/games/mob-control/MobControlGame.ts +0 -176
  381. package/src/games/mob-control/MobControlMeshes.ts +0 -85
  382. package/src/games/mob-control/MobControlRenderer.ts +0 -108
  383. package/src/games/mob-control/MobControlRules.ts +0 -522
  384. package/src/games/mob-control/MobControlScene.ts +0 -399
  385. package/src/games/number-search/NumberSearch.tsx +0 -18
  386. package/src/games/number-search/NumberSearchNumbers.ts +0 -623
  387. package/src/games/nuts-and-bolts/NutsAndBolts.tsx +0 -85
  388. package/src/games/nuts-and-bolts/NutsAndBoltsConstants.ts +0 -75
  389. package/src/games/nuts-and-bolts/NutsAndBoltsGame.ts +0 -298
  390. package/src/games/nuts-and-bolts/NutsAndBoltsRules.ts +0 -474
  391. package/src/games/nuts-and-bolts/NutsAndBoltsScene.ts +0 -498
  392. package/src/games/pac-man/PacMan.tsx +0 -86
  393. package/src/games/pac-man/PacManConstants.ts +0 -169
  394. package/src/games/pac-man/PacManGame.ts +0 -406
  395. package/src/games/pac-man/PacManRules.ts +0 -255
  396. package/src/games/pac-man/PacManScene.ts +0 -387
  397. package/src/games/paper-io/PaperIo.tsx +0 -91
  398. package/src/games/paper-io/PaperIoConstants.ts +0 -86
  399. package/src/games/paper-io/PaperIoGame.ts +0 -193
  400. package/src/games/paper-io/PaperIoMeshes.ts +0 -233
  401. package/src/games/paper-io/PaperIoRules.ts +0 -315
  402. package/src/games/paper-io/PaperIoScene.ts +0 -310
  403. package/src/games/penguin-run/PenguinMeshes.ts +0 -269
  404. package/src/games/penguin-run/PenguinModel.ts +0 -712
  405. package/src/games/penguin-run/PenguinRun.tsx +0 -77
  406. package/src/games/penguin-run/PenguinRunConstants.ts +0 -69
  407. package/src/games/penguin-run/PenguinRunGame.ts +0 -406
  408. package/src/games/penguin-run/PenguinRunScene.ts +0 -949
  409. package/src/games/perfect-circle/PerfectCircle.tsx +0 -74
  410. package/src/games/perfect-circle/PerfectCircleConstants.ts +0 -52
  411. package/src/games/perfect-circle/PerfectCircleGame.ts +0 -153
  412. package/src/games/perfect-circle/PerfectCircleRules.ts +0 -111
  413. package/src/games/perfect-circle/PerfectCircleScene.ts +0 -176
  414. package/src/games/pipe-connect/PipeConnect.tsx +0 -69
  415. package/src/games/pipe-connect/PipeConnectConstants.ts +0 -101
  416. package/src/games/pipe-connect/PipeConnectGame.ts +0 -179
  417. package/src/games/pipe-connect/PipeConnectRules.ts +0 -326
  418. package/src/games/pipe-connect/PipeConnectScene.ts +0 -271
  419. package/src/games/play-with-tua/PlayWithTua.tsx +0 -123
  420. package/src/games/play-with-tua/PlayWithTuaConstants.ts +0 -70
  421. package/src/games/play-with-tua/PlayWithTuaGame.ts +0 -167
  422. package/src/games/play-with-tua/PlayWithTuaModel.ts +0 -42
  423. package/src/games/play-with-tua/PlayWithTuaScene.ts +0 -36
  424. package/src/games/popit-fidget/PopitFidget.tsx +0 -72
  425. package/src/games/popit-fidget/PopitFidgetConstants.ts +0 -71
  426. package/src/games/popit-fidget/PopitFidgetGame.ts +0 -148
  427. package/src/games/popit-fidget/PopitFidgetScene.ts +0 -242
  428. package/src/games/reversi/Reversi.tsx +0 -94
  429. package/src/games/reversi/ReversiConstants.ts +0 -67
  430. package/src/games/reversi/ReversiGame.ts +0 -266
  431. package/src/games/reversi/ReversiRules.ts +0 -176
  432. package/src/games/reversi/ReversiScene.ts +0 -240
  433. package/src/games/search-grid/SearchGrid.tsx +0 -92
  434. package/src/games/search-grid/SearchGridConstants.ts +0 -178
  435. package/src/games/search-grid/SearchGridGame.ts +0 -209
  436. package/src/games/search-grid/SearchGridScene.ts +0 -301
  437. package/src/games/shared/BackdropCard.tsx +0 -54
  438. package/src/games/shared/EngineBackdrop.ts +0 -300
  439. package/src/games/shared/EngineBlasts.ts +0 -136
  440. package/src/games/shared/EngineBlocks.ts +0 -91
  441. package/src/games/shared/EngineControlText.ts +0 -17
  442. package/src/games/shared/EngineDice.ts +0 -250
  443. package/src/games/shared/EngineFootprint.ts +0 -35
  444. package/src/games/shared/EngineFruits.ts +0 -1435
  445. package/src/games/shared/EngineGameLoader.tsx +0 -88
  446. package/src/games/shared/EngineGameScreen.tsx +0 -325
  447. package/src/games/shared/EngineGameWidth.ts +0 -3
  448. package/src/games/shared/EngineGameWidth.web.ts +0 -3
  449. package/src/games/shared/EngineGlyphs.ts +0 -178
  450. package/src/games/shared/EngineHud.ts +0 -815
  451. package/src/games/shared/EngineLoading.ts +0 -477
  452. package/src/games/shared/EngineMeadow.ts +0 -725
  453. package/src/games/shared/EngineMeshCache.ts +0 -15
  454. package/src/games/shared/EngineMeshes.ts +0 -10
  455. package/src/games/shared/EngineRacingChase.ts +0 -21
  456. package/src/games/shared/EngineRacingHandling.ts +0 -48
  457. package/src/games/shared/EngineReadyContext.ts +0 -4
  458. package/src/games/shared/EngineTilt.ts +0 -44
  459. package/src/games/shared/EngineTouchSurface.tsx +0 -103
  460. package/src/games/shared/EngineUtils.ts +0 -52
  461. package/src/games/shared/GameActivity.ts +0 -13
  462. package/src/games/shared/GameLoading.tsx +0 -202
  463. package/src/games/shared/GameLoadingTransition.tsx +0 -61
  464. package/src/games/shared/ProceduralCacheVersion.ts +0 -2
  465. package/src/games/shared/useEngineGame.ts +0 -240
  466. package/src/games/shared/useGameResource.ts +0 -21
  467. package/src/games/shared/useLiveState.ts +0 -58
  468. package/src/games/sliding-numbers/SlidingNumbers.tsx +0 -71
  469. package/src/games/sliding-numbers/SlidingNumbersConstants.ts +0 -65
  470. package/src/games/sliding-numbers/SlidingNumbersGame.ts +0 -192
  471. package/src/games/sliding-numbers/SlidingNumbersRules.ts +0 -79
  472. package/src/games/sliding-numbers/SlidingNumbersScene.ts +0 -193
  473. package/src/games/snake-3d/Snake3D.tsx +0 -76
  474. package/src/games/snake-3d/Snake3DConstants.ts +0 -61
  475. package/src/games/snake-3d/Snake3DGame.ts +0 -192
  476. package/src/games/snake-3d/Snake3DMotion.ts +0 -22
  477. package/src/games/snake-3d/Snake3DRules.ts +0 -116
  478. package/src/games/snake-3d/Snake3DScene.ts +0 -322
  479. package/src/games/snakes-and-ladders/SnakesAndLadders.tsx +0 -87
  480. package/src/games/snakes-and-ladders/SnakesAndLaddersConstants.ts +0 -136
  481. package/src/games/snakes-and-ladders/SnakesAndLaddersGame.ts +0 -310
  482. package/src/games/snakes-and-ladders/SnakesAndLaddersScene.ts +0 -515
  483. package/src/games/space-fighter/SpaceFighter.tsx +0 -74
  484. package/src/games/space-fighter/SpaceFighterConstants.ts +0 -86
  485. package/src/games/space-fighter/SpaceFighterGame.ts +0 -292
  486. package/src/games/space-fighter/SpaceFighterScene.ts +0 -550
  487. package/src/games/spider-solitaire/SpiderSolitaire.tsx +0 -80
  488. package/src/games/spider-solitaire/SpiderSolitaireConstants.ts +0 -107
  489. package/src/games/spider-solitaire/SpiderSolitaireGame.ts +0 -387
  490. package/src/games/spider-solitaire/SpiderSolitaireRules.ts +0 -123
  491. package/src/games/spider-solitaire/SpiderSolitaireScene.ts +0 -352
  492. package/src/games/stack-tower/StackTower.tsx +0 -76
  493. package/src/games/stack-tower/StackTowerConstants.ts +0 -74
  494. package/src/games/stack-tower/StackTowerGame.ts +0 -236
  495. package/src/games/stack-tower/StackTowerScene.ts +0 -186
  496. package/src/games/sudoku/Sudoku.tsx +0 -73
  497. package/src/games/sudoku/SudokuConstants.ts +0 -127
  498. package/src/games/sudoku/SudokuGame.ts +0 -250
  499. package/src/games/sudoku/SudokuRules.ts +0 -125
  500. package/src/games/sudoku/SudokuScene.ts +0 -304
  501. package/src/games/tangram/Tangram.tsx +0 -79
  502. package/src/games/tangram/TangramConstants.ts +0 -64
  503. package/src/games/tangram/TangramGame.ts +0 -356
  504. package/src/games/tangram/TangramRules.ts +0 -409
  505. package/src/games/tangram/TangramScene.ts +0 -203
  506. package/src/games/tank-1990/Tank1990.tsx +0 -78
  507. package/src/games/tank-1990/Tank1990Constants.ts +0 -81
  508. package/src/games/tank-1990/Tank1990Game.ts +0 -331
  509. package/src/games/tank-1990/Tank1990Rules.ts +0 -390
  510. package/src/games/tank-1990/Tank1990Scene.ts +0 -434
  511. package/src/games/tic-tac-toe/TicTacToe.tsx +0 -98
  512. package/src/games/tic-tac-toe/TicTacToeConstants.ts +0 -69
  513. package/src/games/tic-tac-toe/TicTacToeGame.ts +0 -200
  514. package/src/games/tic-tac-toe/TicTacToeRules.ts +0 -103
  515. package/src/games/tic-tac-toe/TicTacToeScene.ts +0 -245
  516. package/src/games/tile-home/TileHome.tsx +0 -92
  517. package/src/games/tile-home/TileHomeConstants.ts +0 -139
  518. package/src/games/tile-home/TileHomeGame.ts +0 -435
  519. package/src/games/tile-home/TileHomeScene.ts +0 -154
  520. package/src/games/treasure-hunt/TreasureHunt.tsx +0 -206
  521. package/src/games/treasure-hunt/TreasureHuntConstants.ts +0 -266
  522. package/src/games/treasure-hunt/TreasureHuntControls.ts +0 -280
  523. package/src/games/treasure-hunt/TreasureHuntGame.ts +0 -402
  524. package/src/games/treasure-hunt/TreasureHuntMeshes.ts +0 -422
  525. package/src/games/treasure-hunt/TreasureHuntModel.ts +0 -506
  526. package/src/games/treasure-hunt/TreasureHuntRules.ts +0 -1210
  527. package/src/games/treasure-hunt/TreasureHuntScene.ts +0 -586
  528. package/src/games/whack-a-mole/WhackAMole.tsx +0 -79
  529. package/src/games/whack-a-mole/WhackAMoleConstants.ts +0 -94
  530. package/src/games/whack-a-mole/WhackAMoleGame.ts +0 -233
  531. package/src/games/whack-a-mole/WhackAMoleScene.ts +0 -349
  532. package/src/games/word-search/WordSearch.tsx +0 -18
  533. package/src/games/word-search/WordSearchWords.ts +0 -1642
  534. package/src/helpers/GamePatternData.ts +0 -120
  535. package/src/helpers/GameSettingsModal.tsx +0 -384
  536. package/src/helpers/GameTheme.tsx +0 -37
  537. package/src/helpers/IconPaths.ts +0 -6
  538. package/src/helpers/index.ts +0 -2
  539. package/src/index.tsx +0 -60
  540. package/src/services/GameAssetLoader.ts +0 -111
  541. package/src/services/GameAssets.ts +0 -149
  542. package/src/services/GameLoaders.ts +0 -93
  543. package/src/services/GamesConstants.ts +0 -193
  544. package/src/services/GamesMetadata.ts +0 -711
  545. package/src/services/GamesService.ts +0 -116
  546. package/src/services/HapticsService.ts +0 -48
  547. package/src/services/ScoringService.ts +0 -19
  548. package/src/services/SfxSources.ts +0 -81
  549. package/src/services/SoundsService.ts +0 -582
  550. package/src/services/ThemeService.ts +0 -281
  551. package/src/services/UtilsService.ts +0 -134
  552. package/src/services/index.ts +0 -6
@@ -1 +1 @@
1
- "use strict";import{effects,extrude,Path,quat,tube}from"@nayan-ui/engine";import{setBackdropTheme,spawnBackdrop}from"../shared/EngineBackdrop.js";import{GLYPH_RADIUS,glyphMesh}from"../shared/EngineGlyphs.js";import{cacheGameAsset,createGameMesh as _0x5df314}from"../shared/EngineMeshes.js";import{placeTiltedBackdrop}from"../shared/EngineTilt.js";import{toColor}from"../shared/EngineUtils.js";import{cellCentre,CLASSIC_BOARD,FIND_TIME,GRID_SIZE,HIGHLIGHT_COLORS,INK_COLOR,SELECT_TIME,SELECTION_COLOR,TILE_COLOR}from"./SearchGridConstants.js";const meshes=new Map,cached=(e,t)=>{let o=meshes.get(e);return!o&&(o=cacheGameAsset("search-grid/SearchGridScene:"+e,t),meshes.set(e,o)),o},BOARD_DEPTH=10,BACKDROP_DEPTH=25,GLYPH_SIZE=.4,panelMesh=(e,t)=>cached("sg-panel:"+e.toFixed(1)+":"+t,()=>_0x5df314(extrude((new Path).addRoundedRect(-e/2,-e/2,e,e,t),{depth:10}),{shine:.2})),barMesh=()=>cached("sg-bar",()=>_0x5df314(tube([[-.5,0,0],[.5,0,0]],{radius:.5,sides:18,smoothness:1,caps:!1}),{shine:.5})),boardColor=e=>toColor("classic"===e.mode?CLASSIC_BOARD:e.BOARD.SURFACE),tileIndex=e=>e.row*GRID_SIZE+e.col;export function buildScene(e,t,o,l){const s=spawnBackdrop(e,t.width,t.height,-25,o);placeTiltedBackdrop(e,s,t,25);const a=e.spawn({mesh:panelMesh(t.boardSize,"classic"===o.mode?12:8),position:[0,0,-5],color:boardColor(o),pickable:!1}),n=[],r=[],i=toColor(INK_COLOR),p=toColor(TILE_COLOR);for(let o=0;o<GRID_SIZE;o++)for(let s=0;s<GRID_SIZE;s++){const[a,h]=cellCentre(t,o,s);n.push(e.spawn({mesh:"roundedBox",position:[a,h,t.tileTop/2],scale:[.88*t.cell,.88*t.cell,t.tileTop],color:p,pickable:!1})),r.push(spawnGlyph(e,t,l[o][s],a,h,i))}return{backdrop:s,panel:a,tiles:n,glyphs:r,selection:spawnPill(e,toColor(SELECTION_COLOR)),ends:{ax:0,ay:0,bx:0,by:0,tax:0,tay:0,tbx:0,tby:0,on:!1},found:[]}}function spawnGlyph(e,t,o,l,s,a){const n=.4*t.cell;return e.spawn({mesh:glyphMesh(o),position:[l,s,t.tileTop+GLYPH_RADIUS*n],scale:n,color:a,pickable:!1})}export function relabel(e,t,o,l){const s=toColor(INK_COLOR);o.glyphs.forEach((a,n)=>{e.despawn(a);const r=Math.floor(n/GRID_SIZE),i=n%GRID_SIZE,[p,h]=cellCentre(t,r,i);o.glyphs[n]=spawnGlyph(e,t,l[r][i],p,h,s)});for(const t of o.found)for(const o of t)e.despawn(o);o.found=[]}export function removeScene(e,t){for(const o of[t.backdrop,t.panel,...t.tiles,...t.glyphs,...t.selection,...t.found.flat()])e.despawn(o)}export function setSceneTheme(e,t,o,l){setBackdropTheme(e,o.backdrop,l),e.set(o.panel,{mesh:panelMesh(t.boardSize,"classic"===l.mode?12:8),color:boardColor(l)})}function spawnPill(e,t){return[e.spawn({mesh:barMesh(),scale:0,color:t,pickable:!1}),e.spawn({mesh:"sphere",scale:0,color:t,pickable:!1}),e.spawn({mesh:"sphere",scale:0,color:t,pickable:!1})]}function drawPill(e,t,o,l,s,a,n){const r=.8*t.cell,i=Math.max(.4,.12*t.tileTop),p=t.tileTop+.15*i,h=Math.hypot(a-l,n-s),[d,f,x]=o;e.set(d,{position:[(l+a)/2,(s+n)/2,p],rotation:quat.z(Math.atan2(n-s,a-l)),scale:[Math.max(h,.001),r,i]}),e.set(f,{position:[l,s,p],scale:[r,r,i]}),e.set(x,{position:[a,n,p],scale:[r,r,i]})}function layPill(e,t,o,l,s){const[a,n]=cellCentre(t,l.row,l.col),[r,i]=cellCentre(t,s.row,s.col);drawPill(e,t,o,a,n,r,i)}export function showSelection(e,t,o,l,s,a){const n=o.ends;[n.tax,n.tay]=cellCentre(t,l.row,l.col),[n.tbx,n.tby]=cellCentre(t,s.row,s.col),n.on=!0,a&&(n.ax=n.tax,n.ay=n.tay,n.bx=n.tbx,n.by=n.tby,drawPill(e,t,o.selection,n.ax,n.ay,n.bx,n.by))}export function followSelection(e,t,o,l){const s=o.ends;if(!s.on)return;if(Math.abs(s.tax-s.ax)+Math.abs(s.tay-s.ay)+Math.abs(s.tbx-s.bx)+Math.abs(s.tby-s.by)<.05)return;const a=1-Math.exp(-l/(SELECT_TIME/3));s.ax+=(s.tax-s.ax)*a,s.ay+=(s.tay-s.ay)*a,s.bx+=(s.tbx-s.bx)*a,s.by+=(s.tby-s.by)*a,drawPill(e,t,o.selection,s.ax,s.ay,s.bx,s.by)}export function hideSelection(e,t){t.ends.on=!1;for(const o of t.selection)e.set(o,{scale:0})}export function markFound(e,t,o,l,s,a){const[n,r,i,p]=toColor(HIGHLIGHT_COLORS[s%HIGHLIGHT_COLORS.length]),h=spawnPill(e,[n,r,i,p??1]);if(layPill(e,t,h,l[0],l[l.length-1]),o.found.push(h),!a)return;const d=[.88*t.cell,.88*t.cell,t.tileTop];e.animate(l.map(e=>o.tiles[tileIndex(e)]),[{scale:[1.15*d[0],1.15*d[1],1.6*d[2]],at:.4},{scale:d}],{duration:FIND_TIME,stagger:.04}),e.animate(l.map(e=>o.glyphs[tileIndex(e)]),[{scale:.4*t.cell*1.2,at:.4},{scale:.4*t.cell}],{duration:FIND_TIME,stagger:.04});const f=l[Math.floor(l.length/2)],[x,b]=cellCentre(t,f.row,f.col);effects.sparkle(e,{position:[x,b,t.tileTop+.3*t.cell],count:14,size:.12*t.cell,speed:4*t.cell,lifetime:.55,gravity:4*-t.cell,colors:[[n,r,i,1],[1,1,1,1]]})}export function celebrate(e,t){effects.confetti(e,{position:[0,0,2*t.cell],count:60,size:.22*t.cell,speed:1.4*t.boardSize,lifetime:1.3,gravity:2.4*-t.boardSize,colors:HIGHLIGHT_COLORS.slice(0,4).map(e=>{const[t,o,l]=toColor(e);return[t,o,l,1]})})}const entryStrips=new WeakMap;export function drawEntryList(e,t,o,l){if(!e.ready)return;const s=t.map((e,t)=>({text:e,color:HIGHLIGHT_COLORS[t%HIGHLIGHT_COLORS.length]})).sort((e,t)=>e.text.localeCompare(t.text)),a=s.map(e=>e.text).join("|")+":"+l.width+":"+l.listTop+":"+l.listWidth;let n=entryStrips.get(e);if(n?.key!==a){e.clearLayer("entries");const t=e.layer("entries"),o=Math.min(4,s.length),r=5,i=(l.listWidth-r*(o-1))/o,p=(l.width-l.listWidth)/2;n={key:a,chips:s.map((s,a)=>{const n=e.world.spawn({mesh:"none",parent:t,position:[p+a%o*(i+r)+i/2,-(l.listTop+24*Math.floor(a/o)+11),0],pickable:!1}),h=e.rectangle(n,0,0,i,21,toColor(s.color));return e.text(n,s.text,0,0,Math.min(12,(i-8)/s.text.length/.65),[1,1,1,1]),{root:n,face:h,strike:e.rectangle(n,0,0,i-12,1,[1,1,1,0],3),color:s.color,text:s.text,found:!1}})},entryStrips.set(e,n)}for(const t of n.chips){const l=o.has(t.text);l!==t.found&&(t.found=l,e.world.set(t.face,{color:toColor(l?"rgba(90,90,90,0.45)":t.color)}),e.world.set(t.strike,{color:[1,1,1,l?.85:0]}),l&&e.world.animate(t.root,[{scale:1.18},{scale:1}],{duration:.3}))}}
1
+ "use strict";import{effects,extrude,Path,quat,tube}from"@nayan-ui/engine";import{setBackdropTheme,spawnBackdrop}from"../shared/EngineBackdrop.js";import{GLYPH_RADIUS,glyphMesh}from"../shared/EngineGlyphs.js";import{cacheGameAsset,createGameMesh as _0x4af58e}from"../shared/EngineMeshes.js";import{placeTiltedBackdrop}from"../shared/EngineTilt.js";import{toColor}from"../shared/EngineUtils.js";import{cellCentre,CLASSIC_BOARD,FIND_TIME,GRID_SIZE,HIGHLIGHT_COLORS,INK_COLOR,SELECT_TIME,SELECTION_COLOR,TILE_COLOR}from"./SearchGridConstants.js";const meshes=new Map,cached=(e,t)=>{let o=meshes.get(e);return!o&&(o=cacheGameAsset("search-grid/SearchGridScene:"+e,t),meshes.set(e,o)),o},BOARD_DEPTH=10,BACKDROP_DEPTH=25,GLYPH_SIZE=.4,panelMesh=(e,t)=>cached("sg-panel:"+e.toFixed(1)+":"+t,()=>_0x4af58e(extrude((new Path).addRoundedRect(-e/2,-e/2,e,e,t),{depth:10}),{shine:.2})),barMesh=()=>cached("sg-bar",()=>_0x4af58e(tube([[-.5,0,0],[.5,0,0]],{radius:.5,sides:18,smoothness:1,caps:!1}),{shine:.5})),boardColor=e=>toColor("classic"===e.mode?CLASSIC_BOARD:e.BOARD.SURFACE),tileIndex=e=>e.row*GRID_SIZE+e.col;export function buildScene(e,t,o,l){const s=spawnBackdrop(e,t.width,t.height,-25,o);placeTiltedBackdrop(e,s,t,25);const a=e.spawn({mesh:panelMesh(t.boardSize,"classic"===o.mode?12:8),position:[0,0,-5],color:boardColor(o),pickable:!1}),n=[],r=[],i=toColor(INK_COLOR),p=toColor(TILE_COLOR);for(let o=0;o<GRID_SIZE;o++)for(let s=0;s<GRID_SIZE;s++){const[a,h]=cellCentre(t,o,s);n.push(e.spawn({mesh:"roundedBox",position:[a,h,t.tileTop/2],scale:[.88*t.cell,.88*t.cell,t.tileTop],color:p,pickable:!1})),r.push(spawnGlyph(e,t,l[o][s],a,h,i))}return{backdrop:s,panel:a,tiles:n,glyphs:r,selection:spawnPill(e,toColor(SELECTION_COLOR)),ends:{ax:0,ay:0,bx:0,by:0,tax:0,tay:0,tbx:0,tby:0,on:!1},found:[]}}function spawnGlyph(e,t,o,l,s,a){const n=.4*t.cell;return e.spawn({mesh:glyphMesh(o),position:[l,s,t.tileTop+GLYPH_RADIUS*n],scale:n,color:a,pickable:!1})}export function relabel(e,t,o,l){const s=toColor(INK_COLOR);o.glyphs.forEach((a,n)=>{e.despawn(a);const r=Math.floor(n/GRID_SIZE),i=n%GRID_SIZE,[p,h]=cellCentre(t,r,i);o.glyphs[n]=spawnGlyph(e,t,l[r][i],p,h,s)});for(const t of o.found)for(const o of t)e.despawn(o);o.found=[]}export function removeScene(e,t){for(const o of[t.backdrop,t.panel,...t.tiles,...t.glyphs,...t.selection,...t.found.flat()])e.despawn(o)}export function setSceneTheme(e,t,o,l){setBackdropTheme(e,o.backdrop,l),e.set(o.panel,{mesh:panelMesh(t.boardSize,"classic"===l.mode?12:8),color:boardColor(l)})}function spawnPill(e,t){return[e.spawn({mesh:barMesh(),scale:0,color:t,pickable:!1}),e.spawn({mesh:"sphere",scale:0,color:t,pickable:!1}),e.spawn({mesh:"sphere",scale:0,color:t,pickable:!1})]}function drawPill(e,t,o,l,s,a,n){const r=.8*t.cell,i=Math.max(.4,.12*t.tileTop),p=t.tileTop+.15*i,h=Math.hypot(a-l,n-s),[d,f,x]=o;e.set(d,{position:[(l+a)/2,(s+n)/2,p],rotation:quat.z(Math.atan2(n-s,a-l)),scale:[Math.max(h,.001),r,i]}),e.set(f,{position:[l,s,p],scale:[r,r,i]}),e.set(x,{position:[a,n,p],scale:[r,r,i]})}function layPill(e,t,o,l,s){const[a,n]=cellCentre(t,l.row,l.col),[r,i]=cellCentre(t,s.row,s.col);drawPill(e,t,o,a,n,r,i)}export function showSelection(e,t,o,l,s,a){const n=o.ends;[n.tax,n.tay]=cellCentre(t,l.row,l.col),[n.tbx,n.tby]=cellCentre(t,s.row,s.col),n.on=!0,a&&(n.ax=n.tax,n.ay=n.tay,n.bx=n.tbx,n.by=n.tby,drawPill(e,t,o.selection,n.ax,n.ay,n.bx,n.by))}export function followSelection(e,t,o,l){const s=o.ends;if(!s.on)return;if(Math.abs(s.tax-s.ax)+Math.abs(s.tay-s.ay)+Math.abs(s.tbx-s.bx)+Math.abs(s.tby-s.by)<.05)return;const a=1-Math.exp(-l/(SELECT_TIME/3));s.ax+=(s.tax-s.ax)*a,s.ay+=(s.tay-s.ay)*a,s.bx+=(s.tbx-s.bx)*a,s.by+=(s.tby-s.by)*a,drawPill(e,t,o.selection,s.ax,s.ay,s.bx,s.by)}export function hideSelection(e,t){t.ends.on=!1;for(const o of t.selection)e.set(o,{scale:0})}export function markFound(e,t,o,l,s,a){const[n,r,i,p]=toColor(HIGHLIGHT_COLORS[s%HIGHLIGHT_COLORS.length]),h=spawnPill(e,[n,r,i,p??1]);if(layPill(e,t,h,l[0],l[l.length-1]),o.found.push(h),!a)return;const d=[.88*t.cell,.88*t.cell,t.tileTop];e.animate(l.map(e=>o.tiles[tileIndex(e)]),[{scale:[1.15*d[0],1.15*d[1],1.6*d[2]],at:.4},{scale:d}],{duration:FIND_TIME,stagger:.04}),e.animate(l.map(e=>o.glyphs[tileIndex(e)]),[{scale:.4*t.cell*1.2,at:.4},{scale:.4*t.cell}],{duration:FIND_TIME,stagger:.04});const f=l[Math.floor(l.length/2)],[x,b]=cellCentre(t,f.row,f.col);effects.sparkle(e,{position:[x,b,t.tileTop+.3*t.cell],count:14,size:.12*t.cell,speed:4*t.cell,lifetime:.55,gravity:4*-t.cell,colors:[[n,r,i,1],[1,1,1,1]]})}export function celebrate(e,t){effects.confetti(e,{position:[0,0,2*t.cell],count:60,size:.22*t.cell,speed:1.4*t.boardSize,lifetime:1.3,gravity:2.4*-t.boardSize,colors:HIGHLIGHT_COLORS.slice(0,4).map(e=>{const[t,o,l]=toColor(e);return[t,o,l,1]})})}const entryStrips=new WeakMap;export function drawEntryList(e,t,o,l){if(!e.ready)return;const s=t.map((e,t)=>({text:e,color:HIGHLIGHT_COLORS[t%HIGHLIGHT_COLORS.length]})).sort((e,t)=>e.text.localeCompare(t.text)),a=s.map(e=>e.text).join("|")+":"+l.width+":"+l.listTop+":"+l.listWidth;let n=entryStrips.get(e);if(n?.key!==a){e.clearLayer("entries");const t=e.layer("entries"),o=Math.min(4,s.length),r=5,i=(l.listWidth-r*(o-1))/o,p=(l.width-l.listWidth)/2;n={key:a,chips:s.map((s,a)=>{const n=e.world.spawn({mesh:"none",parent:t,position:[p+a%o*(i+r)+i/2,-(l.listTop+24*Math.floor(a/o)+11),0],pickable:!1}),h=e.rectangle(n,0,0,i,21,toColor(s.color));return e.text(n,s.text,0,0,Math.min(12,(i-8)/s.text.length/.65),[1,1,1,1]),{root:n,face:h,strike:e.rectangle(n,0,0,i-12,1,[1,1,1,0],3),color:s.color,text:s.text,found:!1}})},entryStrips.set(e,n)}for(const t of n.chips){const l=o.has(t.text);l!==t.found&&(t.found=l,e.world.set(t.face,{color:toColor(l?"rgba(90,90,90,0.45)":t.color)}),e.world.set(t.strike,{color:[1,1,1,l?.85:0]}),l&&e.world.animate(t.root,[{scale:1.18},{scale:1}],{duration:.3}))}}
@@ -1 +1 @@
1
- "use strict";import{c as _0x25c92b}from"react/compiler-runtime";import _0x21a571,{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{GameView,isEngineAvailable,World}from"@nayan-ui/engine";import{useGameTheme}from"../../helpers/GameTheme.js";import{BACKDROP_LIGHT,backdropMesh}from"./EngineBackdrop.js";import{toRgb}from"./EngineUtils.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x540a8d}from"react/jsx-runtime";const CardScene=_0x21a571.memo(e=>{const t=_0x25c92b(28),{width:o,height:r}=e,a=useGameTheme();let s;t[0]!==a?(s=()=>{const e=new World(4),t=e.spawn({mesh:backdropMesh(a),color:[1,1,1,1],pickable:!1});return{world:e,backdrop:t}},t[0]=a,t[1]=s):s=t[1];const n=useGameResource(s,_temp);let l,i;t[2]!==n.backdrop||t[3]!==n.world||t[4]!==a?(l=()=>{n.world.set(n.backdrop,{mesh:backdropMesh(a)})},t[2]=n.backdrop,t[3]=n.world,t[4]=a,t[5]=l):l=t[5],t[6]!==n||t[7]!==a?(i=[n,a],t[6]=n,t[7]=a,t[8]=i):i=t[8],useEffect(l,i);const d=o/2,m=-r/2;let h;t[9]!==d||t[10]!==m?(h=[d,m,100],t[9]=d,t[10]=m,t[11]=h):h=t[11];const p=o/2,u=-r/2;let w;t[12]!==p||t[13]!==u?(w=[p,u,0],t[12]=p,t[13]=u,t[14]=w):w=t[14];const b=r/2;let g;t[15]!==b||t[16]!==h||t[17]!==w?(g={eye:h,target:w,fov:1,ortho:b},t[15]=b,t[16]=h,t[17]=w,t[18]=g):g=t[18];const C=g;let G;t[19]!==a.BACKGROUND?(G=toRgb(a.BACKGROUND),t[19]=a.BACKGROUND,t[20]=G):G=t[20];const f=G;let _;t[21]!==n.world?(_=e=>n.world.update(e),t[21]=n.world,t[22]=_):_=t[22];const k=_;let x;return t[23]!==f||t[24]!==C||t[25]!==k||t[26]!==n.world?(x=_0x540a8d(GameView,{source:n.world,camera:C,light:BACKDROP_LIGHT,background:f,onUpdate:k}),t[23]=f,t[24]=C,t[25]=k,t[26]=n.world,t[27]=x):x=t[27],x});CardScene.displayName="CardScene";export const BackdropCard=_0x21a571.memo(()=>{const e=_0x25c92b(8),t=useGameTheme(),[o,r]=useState(null);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{const{width:t,height:o}=e.nativeEvent.layout;r(e=>e&&e.width===t&&e.height===o?e:{width:t,height:o})},e[0]=a):a=e[0];const s=a;let n,l,i;return e[1]!==t.BACKGROUND?(n=[StyleSheet.absoluteFill,styles.passThrough,{backgroundColor:t.BACKGROUND}],e[1]=t.BACKGROUND,e[2]=n):n=e[2],e[3]!==o?(l=isEngineAvailable&&o&&o.width>0&&o.height>0?_0x540a8d(CardScene,{width:o.width,height:o.height}):null,e[3]=o,e[4]=l):l=e[4],e[5]!==n||e[6]!==l?(i=_0x540a8d(View,{style:n,onLayout:s,children:l}),e[5]=n,e[6]=l,e[7]=i):i=e[7],i});BackdropCard.displayName="BackdropCard";const styles=StyleSheet.create({passThrough:{pointerEvents:"none"}});function _temp(e){return()=>e.world.dispose()}
1
+ "use strict";import{c as _0x364494}from"react/compiler-runtime";import _0x1b925e,{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{GameView,isEngineAvailable,World}from"@nayan-ui/engine";import{useGameTheme}from"../../helpers/GameTheme.js";import{BACKDROP_LIGHT,backdropMesh}from"./EngineBackdrop.js";import{toRgb}from"./EngineUtils.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x449af7}from"react/jsx-runtime";const CardScene=_0x1b925e.memo(e=>{const t=_0x364494(28),{width:o,height:r}=e,a=useGameTheme();let s;t[0]!==a?(s=()=>{const e=new World(4),t=e.spawn({mesh:backdropMesh(a),color:[1,1,1,1],pickable:!1});return{world:e,backdrop:t}},t[0]=a,t[1]=s):s=t[1];const n=useGameResource(s,_temp);let l,i;t[2]!==n.backdrop||t[3]!==n.world||t[4]!==a?(l=()=>{n.world.set(n.backdrop,{mesh:backdropMesh(a)})},t[2]=n.backdrop,t[3]=n.world,t[4]=a,t[5]=l):l=t[5],t[6]!==n||t[7]!==a?(i=[n,a],t[6]=n,t[7]=a,t[8]=i):i=t[8],useEffect(l,i);const m=o/2,d=-r/2;let h;t[9]!==m||t[10]!==d?(h=[m,d,100],t[9]=m,t[10]=d,t[11]=h):h=t[11];const p=o/2,u=-r/2;let w;t[12]!==p||t[13]!==u?(w=[p,u,0],t[12]=p,t[13]=u,t[14]=w):w=t[14];const b=r/2;let f;t[15]!==b||t[16]!==h||t[17]!==w?(f={eye:h,target:w,fov:1,ortho:b},t[15]=b,t[16]=h,t[17]=w,t[18]=f):f=t[18];const g=f;let C;t[19]!==a.BACKGROUND?(C=toRgb(a.BACKGROUND),t[19]=a.BACKGROUND,t[20]=C):C=t[20];const G=C;let _;t[21]!==n.world?(_=e=>n.world.update(e),t[21]=n.world,t[22]=_):_=t[22];const k=_;let x;return t[23]!==G||t[24]!==g||t[25]!==k||t[26]!==n.world?(x=_0x449af7(GameView,{source:n.world,camera:g,light:BACKDROP_LIGHT,background:G,onUpdate:k}),t[23]=G,t[24]=g,t[25]=k,t[26]=n.world,t[27]=x):x=t[27],x});CardScene.displayName="CardScene";export const BackdropCard=_0x1b925e.memo(()=>{const e=_0x364494(8),t=useGameTheme(),[o,r]=useState(null);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{const{width:t,height:o}=e.nativeEvent.layout;r(e=>e&&e.width===t&&e.height===o?e:{width:t,height:o})},e[0]=a):a=e[0];const s=a;let n,l,i;return e[1]!==t.BACKGROUND?(n=[StyleSheet.absoluteFill,styles.passThrough,{backgroundColor:t.BACKGROUND}],e[1]=t.BACKGROUND,e[2]=n):n=e[2],e[3]!==o?(l=isEngineAvailable&&o&&o.width>0&&o.height>0?_0x449af7(CardScene,{width:o.width,height:o.height}):null,e[3]=o,e[4]=l):l=e[4],e[5]!==n||e[6]!==l?(i=_0x449af7(View,{style:n,onLayout:s,children:l}),e[5]=n,e[6]=l,e[7]=i):i=e[7],i});BackdropCard.displayName="BackdropCard";const styles=StyleSheet.create({passThrough:{pointerEvents:"none"}});function _temp(e){return()=>e.world.dispose()}
@@ -1 +1 @@
1
- "use strict";import{gamePattern,PATTERN_GRID_COLOR}from"../../helpers/GamePatternData.js";import{getScreenDimensions}from"../../services/UtilsService.js";import{cacheGameAsset,createGameMesh as _0x2add86}from"./EngineMeshes.js";import{frontLight,toColor}from"./EngineUtils.js";export const BACKDROP_LIGHT=frontLight([0,0,1],1);const GRID_STEP=16,SEGMENTS=40,CORNER_SEGMENTS=6,LAYER_GAP=.05;function gradientAt(t,e,r,n){const s=t.end[0]-t.start[0],o=t.end[1]-t.start[1],i=Math.max(0,Math.min(1,((r-t.start[0])*s+(n-t.start[1])*o)/(s*s+o*o)))*(e.length-1),h=Math.min(e.length-2,Math.floor(i)),a=i-h,l=e[h],d=e[h+1];return[l[0]+(d[0]-l[0])*a,l[1]+(d[1]-l[1])*a,l[2]+(d[2]-l[2])*a,l[3]+(d[3]-l[3])*a]}function contains(t,e,r){switch(t.kind){case"circle":return(e-t.cx)**2+(r-t.cy)**2<=t.r*t.r;case"rrect":return e>=t.x&&e<=t.x+t.w&&r>=t.y&&r<=t.y+t.h;default:return Math.abs(e-t.cx)+Math.abs(r-t.cy)<=t.size/2}}class Compositor{gridColor=toColor(PATTERN_GRID_COLOR);constructor(t,e,r){this.pattern=t,this.opacity=r,this.stops=t.gradients.map(t=>t.colors.map(t=>toColor(t))),this.colors=t.shapes.map(t=>toColor(t.color)),this.bg=toColor(e)}at(t,e,r,n){let s=0,o=0,i=0,h=0;const a=t=>{const e=1-t[3];s=t[0]*t[3]+s*e,o=t[1]*t[3]+o*e,i=t[2]*t[3]+i*e,h=t[3]+h*e};this.pattern.gradients.forEach((r,n)=>a(gradientAt(r,this.stops[n],t,e)));for(let n=0;n<r;n++)contains(this.pattern.shapes[n],t,e)&&a(this.colors[n]);"number"==typeof n?a(this.colors[n]):"grid"===n&&a(this.gridColor);const l=this.opacity;return[s*l+this.bg[0]*(1-h*l),o*l+this.bg[1]*(1-h*l),i*l+this.bg[2]*(1-h*l)]}}class MeshBuilder{vertices=[];indices=[];vertex(t,e,r,[n,s,o]){return this.vertices.push(t,-e,r,0,0,1,n,s,o,0,0),this.vertices.length/11-1}quad(t,e,r,n){this.indices.push(t,e,r,t,r,n)}geometry(){return{vertices:new Float32Array(this.vertices),indices:new Uint32Array(this.indices)}}}function outline(t){if("circle"===t.kind)return Array.from({length:40},(e,r)=>{const n=-r/40*Math.PI*2;return[t.cx+Math.cos(n)*t.r,t.cy+Math.sin(n)*t.r]});if("diamond"===t.kind){const e=t.size/2;return[[t.cx+e,t.cy],[t.cx,t.cy-e],[t.cx-e,t.cy],[t.cx,t.cy+e]]}const e=Math.min(t.r,t.w/2,t.h/2),r=[[t.x+t.w-e,t.y+t.h-e,-Math.PI/2],[t.x+t.w-e,t.y+e,0],[t.x+e,t.y+e,Math.PI/2],[t.x+e,t.y+t.h-e,Math.PI]],n=[];for(const[t,s,o]of r)for(let r=0;r<=6;r++){const i=o+r/6*(Math.PI/2);n.push([t+Math.cos(i)*e,s-Math.sin(i)*e])}return n}function centreOf(t){return"rrect"===t.kind?[t.x+t.w/2,t.y+t.h/2]:[t.cx,t.cy]}function buildGeometry(t,e,r,n=!0){const s=new MeshBuilder,o=new Compositor(t,e,r),{width:i,height:h,shapes:a}=t,l=n?t.grid:[],d=Math.ceil(i/16),u=Math.ceil(h/16),m=s.vertices.length/11;for(let t=0;t<=u;t++){const e=Math.min(h,16*t);for(let t=0;t<=d;t++){const r=Math.min(i,16*t);s.vertex(r,e,0,o.at(r,e,0,null))}}const f=(t,e)=>m+e*(d+1)+t;for(let t=0;t<u;t++)for(let e=0;e<d;e++)s.quad(f(e,t+1),f(e+1,t+1),f(e+1,t),f(e,t));a.forEach((t,e)=>{const r=.05*(e+1),[n,i]=centreOf(t),h=s.vertex(n,i,r,o.at(n,i,e,e)),a=outline(t).map(([t,n])=>s.vertex(t,n,r,o.at(t,n,e,e)));a.forEach((t,e)=>s.indices.push(h,t,a[(e+1)%a.length]))});const g=.05*(a.length+1);for(const t of l){const e=Math.max(t.w,t.h),r=Math.max(1,Math.ceil(e/16)),n=t.h>t.w;let i=null;for(let h=0;h<=r;h++){const r=Math.min(e,16*h),l=n?[t.x,t.y+r,t.x+t.w,t.y+r]:[t.x+r,t.y,t.x+r,t.y+t.h],d=s.vertex(l[0],l[1],g,o.at(l[0],l[1],a.length,"grid")),u=s.vertex(l[2],l[3],g,o.at(l[2],l[3],a.length,"grid"));i&&(n?s.quad(d,u,i[1],i[0]):s.quad(i[1],u,d,i[0])),i=[d,u]}}return s.geometry()}const meshes=new Map;export function backdropMesh(t){const{width:e,height:r}=getScreenDimensions(),n=t.BACKGROUND+":"+t.PATTERN_OPACITY+":"+Math.round(e)+"x"+Math.round(r);let s=meshes.get(n);return!s&&(s=cacheGameAsset("backdrop:"+n,()=>_0x2add86(buildGeometry(gamePattern(e,r),t.BACKGROUND,t.PATTERN_OPACITY),{center:!1})),meshes.set(n,s)),s}const FLOATS=11;function clipGeometry({vertices:t,indices:e},r){const n=[],s=[],o=e=>Array.from(t.subarray(11*e,11*e+11));for(let t=0;t<e.length;t+=3){let i=[o(e[t]),o(e[t+1]),o(e[t+2])];for(let t=0;t<r.length&&i.length>0;t++){const[e,n]=r[t],[s,o]=r[(t+1)%r.length],h=t=>(s-e)*(t[1]-n)-(o-n)*(t[0]-e),a=[];for(let t=0;t<i.length;t++){const e=i[t],r=i[(t+1)%i.length],n=h(e),s=h(r);if(n>=0&&a.push(e),n>=0!=s>=0){const t=n/(n-s);a.push(e.map((e,n)=>e+(r[n]-e)*t))}}i=a}if(i.length<3)continue;const h=n.length/11;for(const t of i)n.push(...t);for(let t=1;t+1<i.length;t++)s.push(h,h+t,h+t+1)}return{vertices:new Float32Array(n),indices:new Uint32Array(s)}}export function cardBackdropMesh(t,e,r,n){const s=getScreenDimensions(),[o,i]=[Math.round(e),Math.round(r)],h="card-nogrid:"+t.BACKGROUND+":"+t.PATTERN_OPACITY+":"+Math.round(s.width)+"x"+Math.round(s.height)+":"+o+"x"+i+":"+n;let a=meshes.get(h);if(!a){const e=Math.min(n,o/2,i/2),r=[],l=[[o-e,-i+e,-Math.PI/2],[o-e,-e,0],[e,-e,Math.PI/2],[e,-i+e,Math.PI]];for(const[t,n,s]of l)for(let o=0;o<=6;o++){const i=s+o/6*(Math.PI/2);r.push([t+Math.cos(i)*e,n+Math.sin(i)*e])}const d=buildGeometry(gamePattern(s.width,s.height),t.BACKGROUND,t.PATTERN_OPACITY,!1);a=_0x2add86(clipGeometry(d,r),{center:!1}),meshes.set(h,a)}return a}export function spawnBackdrop(t,e,r,n,s){return t.spawn({mesh:backdropMesh(s),position:[-e/2,r/2,n],color:[1,1,1,1],pickable:!1})}export function setBackdropTheme(t,e,r){t.set(e,{mesh:backdropMesh(r)})}
1
+ "use strict";import{gamePattern,PATTERN_GRID_COLOR}from"../../helpers/GamePatternData.js";import{getScreenDimensions}from"../../services/UtilsService.js";import{cacheGameAsset,createGameMesh as _0x403689}from"./EngineMeshes.js";import{frontLight,toColor}from"./EngineUtils.js";export const BACKDROP_LIGHT=frontLight([0,0,1],1);const GRID_STEP=16,SEGMENTS=40,CORNER_SEGMENTS=6,LAYER_GAP=.05;function gradientAt(t,e,r,n){const s=t.end[0]-t.start[0],o=t.end[1]-t.start[1],i=Math.max(0,Math.min(1,((r-t.start[0])*s+(n-t.start[1])*o)/(s*s+o*o)))*(e.length-1),h=Math.min(e.length-2,Math.floor(i)),a=i-h,l=e[h],u=e[h+1];return[l[0]+(u[0]-l[0])*a,l[1]+(u[1]-l[1])*a,l[2]+(u[2]-l[2])*a,l[3]+(u[3]-l[3])*a]}function contains(t,e,r){switch(t.kind){case"circle":return(e-t.cx)**2+(r-t.cy)**2<=t.r*t.r;case"rrect":return e>=t.x&&e<=t.x+t.w&&r>=t.y&&r<=t.y+t.h;default:return Math.abs(e-t.cx)+Math.abs(r-t.cy)<=t.size/2}}class Compositor{gridColor=toColor(PATTERN_GRID_COLOR);constructor(t,e,r){this.pattern=t,this.opacity=r,this.stops=t.gradients.map(t=>t.colors.map(t=>toColor(t))),this.colors=t.shapes.map(t=>toColor(t.color)),this.bg=toColor(e)}at(t,e,r,n){let s=0,o=0,i=0,h=0;const a=t=>{const e=1-t[3];s=t[0]*t[3]+s*e,o=t[1]*t[3]+o*e,i=t[2]*t[3]+i*e,h=t[3]+h*e};this.pattern.gradients.forEach((r,n)=>a(gradientAt(r,this.stops[n],t,e)));for(let n=0;n<r;n++)contains(this.pattern.shapes[n],t,e)&&a(this.colors[n]);"number"==typeof n?a(this.colors[n]):"grid"===n&&a(this.gridColor);const l=this.opacity;return[s*l+this.bg[0]*(1-h*l),o*l+this.bg[1]*(1-h*l),i*l+this.bg[2]*(1-h*l)]}}class MeshBuilder{vertices=[];indices=[];vertex(t,e,r,[n,s,o]){return this.vertices.push(t,-e,r,0,0,1,n,s,o,0,0),this.vertices.length/11-1}quad(t,e,r,n){this.indices.push(t,e,r,t,r,n)}geometry(){return{vertices:new Float32Array(this.vertices),indices:new Uint32Array(this.indices)}}}function outline(t){if("circle"===t.kind)return Array.from({length:40},(e,r)=>{const n=-r/40*Math.PI*2;return[t.cx+Math.cos(n)*t.r,t.cy+Math.sin(n)*t.r]});if("diamond"===t.kind){const e=t.size/2;return[[t.cx+e,t.cy],[t.cx,t.cy-e],[t.cx-e,t.cy],[t.cx,t.cy+e]]}const e=Math.min(t.r,t.w/2,t.h/2),r=[[t.x+t.w-e,t.y+t.h-e,-Math.PI/2],[t.x+t.w-e,t.y+e,0],[t.x+e,t.y+e,Math.PI/2],[t.x+e,t.y+t.h-e,Math.PI]],n=[];for(const[t,s,o]of r)for(let r=0;r<=6;r++){const i=o+r/6*(Math.PI/2);n.push([t+Math.cos(i)*e,s-Math.sin(i)*e])}return n}function centreOf(t){return"rrect"===t.kind?[t.x+t.w/2,t.y+t.h/2]:[t.cx,t.cy]}function buildGeometry(t,e,r,n=!0){const s=new MeshBuilder,o=new Compositor(t,e,r),{width:i,height:h,shapes:a}=t,l=n?t.grid:[],u=Math.ceil(i/16),d=Math.ceil(h/16),m=s.vertices.length/11;for(let t=0;t<=d;t++){const e=Math.min(h,16*t);for(let t=0;t<=u;t++){const r=Math.min(i,16*t);s.vertex(r,e,0,o.at(r,e,0,null))}}const f=(t,e)=>m+e*(u+1)+t;for(let t=0;t<d;t++)for(let e=0;e<u;e++)s.quad(f(e,t+1),f(e+1,t+1),f(e+1,t),f(e,t));a.forEach((t,e)=>{const r=.05*(e+1),[n,i]=centreOf(t),h=s.vertex(n,i,r,o.at(n,i,e,e)),a=outline(t).map(([t,n])=>s.vertex(t,n,r,o.at(t,n,e,e)));a.forEach((t,e)=>s.indices.push(h,t,a[(e+1)%a.length]))});const g=.05*(a.length+1);for(const t of l){const e=Math.max(t.w,t.h),r=Math.max(1,Math.ceil(e/16)),n=t.h>t.w;let i=null;for(let h=0;h<=r;h++){const r=Math.min(e,16*h),l=n?[t.x,t.y+r,t.x+t.w,t.y+r]:[t.x+r,t.y,t.x+r,t.y+t.h],u=s.vertex(l[0],l[1],g,o.at(l[0],l[1],a.length,"grid")),d=s.vertex(l[2],l[3],g,o.at(l[2],l[3],a.length,"grid"));i&&(n?s.quad(u,d,i[1],i[0]):s.quad(i[1],d,u,i[0])),i=[u,d]}}return s.geometry()}const meshes=new Map;export function backdropMesh(t){const{width:e,height:r}=getScreenDimensions(),n=t.BACKGROUND+":"+t.PATTERN_OPACITY+":"+Math.round(e)+"x"+Math.round(r);let s=meshes.get(n);return!s&&(s=cacheGameAsset("backdrop:"+n,()=>_0x403689(buildGeometry(gamePattern(e,r),t.BACKGROUND,t.PATTERN_OPACITY),{center:!1})),meshes.set(n,s)),s}const FLOATS=11;function clipGeometry({vertices:t,indices:e},r){const n=[],s=[],o=e=>Array.from(t.subarray(11*e,11*e+11));for(let t=0;t<e.length;t+=3){let i=[o(e[t]),o(e[t+1]),o(e[t+2])];for(let t=0;t<r.length&&i.length>0;t++){const[e,n]=r[t],[s,o]=r[(t+1)%r.length],h=t=>(s-e)*(t[1]-n)-(o-n)*(t[0]-e),a=[];for(let t=0;t<i.length;t++){const e=i[t],r=i[(t+1)%i.length],n=h(e),s=h(r);if(n>=0&&a.push(e),n>=0!=s>=0){const t=n/(n-s);a.push(e.map((e,n)=>e+(r[n]-e)*t))}}i=a}if(i.length<3)continue;const h=n.length/11;for(const t of i)n.push(...t);for(let t=1;t+1<i.length;t++)s.push(h,h+t,h+t+1)}return{vertices:new Float32Array(n),indices:new Uint32Array(s)}}export function cardBackdropMesh(t,e,r,n){const s=getScreenDimensions(),[o,i]=[Math.round(e),Math.round(r)],h="card-nogrid:"+t.BACKGROUND+":"+t.PATTERN_OPACITY+":"+Math.round(s.width)+"x"+Math.round(s.height)+":"+o+"x"+i+":"+n;let a=meshes.get(h);if(!a){const e=Math.min(n,o/2,i/2),r=[],l=[[o-e,-i+e,-Math.PI/2],[o-e,-e,0],[e,-e,Math.PI/2],[e,-i+e,Math.PI]];for(const[t,n,s]of l)for(let o=0;o<=6;o++){const i=s+o/6*(Math.PI/2);r.push([t+Math.cos(i)*e,n+Math.sin(i)*e])}const u=buildGeometry(gamePattern(s.width,s.height),t.BACKGROUND,t.PATTERN_OPACITY,!1);a=_0x403689(clipGeometry(u,r),{center:!1}),meshes.set(h,a)}return a}export function spawnBackdrop(t,e,r,n,s){return t.spawn({mesh:backdropMesh(s),position:[-e/2,r/2,n],color:[1,1,1,1],pickable:!1})}export function setBackdropTheme(t,e,r){t.set(e,{mesh:backdropMesh(r)})}
@@ -1 +1 @@
1
- "use strict";import{effects,extrude,Path}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x3eb8ce}from"./EngineMeshes.js";const WHITE=[1,1,1,1],fade=e=>[e[0],e[1],e[2],0];let disc=null;const discMesh=()=>cacheGameAsset("shared/EngineBlasts:discMesh",()=>disc??=_0x3eb8ce(extrude((new Path).addCircle(0,0,.5),{depth:0})));export function popBurst(e,s){const[t,i,o]=s.color;effects.sparkle(e,{position:s.position,count:s.count??8,size:.2*s.size,speed:6*s.size,lifetime:.45,colors:[s.color,WHITE],flash:!1});const n=e.spawn({mesh:discMesh(),position:[s.position[0],s.position[1],s.glowZ??s.position[2]],scale:.85*s.size,color:[t,i,o,.6],pickable:!1});e.animate(n,{scale:2.8*s.size,color:[t,i,o,0]},{duration:.28}).then(()=>{e.has(n)&&e.despawn(n)})}export function popAndBurst(e,s,t,i){const o=t.delay??0,n=t.duration??effects.POP_TIME;return o>0?e.after(o+.12*n,()=>popBurst(e,i)):popBurst(e,i),effects.pop(e,s,t)}let stickChip=null,catchRing=null;const stickChipMesh=()=>cacheGameAsset("shared/EngineBlasts:stickChipMesh",()=>stickChip??=_0x3eb8ce(extrude((new Path).addRoundedRect(-.5,-.09,1,.18,.07),{depth:.16}),{shine:.25})),catchRingMesh=()=>cacheGameAsset("shared/EngineBlasts:catchRingMesh",()=>catchRing??=_0x3eb8ce(extrude((new Path).addCircle(0,0,.5).addCircle(0,0,.465),{depth:0,fillRule:"evenodd"})));export function stickBlast(e,s,t){const[i,o]=t.scale,[n,a,r,l]=t.rotation,h=[1-2*(a*a+r*r),2*(n*a+l*r),2*(n*r-l*a)],p=[2*(n*r+l*a),2*(a*r-l*n),1-2*(n*n+a*a)],d=(e,s=0)=>[t.position[0]+h[0]*i*e+p[0]*s,t.position[1]+h[1]*i*e+p[1]*s,t.position[2]+h[2]*i*e+p[2]*s],f=popAndBurst(e,s,{scale:t.scale,color:t.color,duration:.32},{position:d(0,.6*o),size:Math.max(1.6*o,.24*i),color:t.color,count:14});stickChip=stickChipMesh(),effects.shatter(e,{position:d(0,.4*o),mesh:stickChip,count:7,size:.16*i,speed:2*i,lifetime:.5,gravity:4*-i,colors:[t.color,effects.pale(t.color,.4,1)],flash:!1,dust:!1});for(const s of[-1,1])effects.sparks(e,{position:d(.32*s,.5*o),count:4,size:.18*o,speed:2.5*i,lifetime:.35,gravity:1.5*-i,direction:[h[0]*s,h[1]*s,h[2]*s],spread:.9,colors:[t.color,WHITE],flash:!1});catchRing=catchRingMesh();const u=effects.pale(t.color,.45,.9),m=e.spawn({mesh:catchRing,position:d(0,.8*o),rotation:t.rotation,scale:1.8*o,color:u,pickable:!1});return e.animate(m,{scale:1.1*i,color:fade(u)},{duration:.32,easing:"easeOut"}).then(()=>{e.has(m)&&e.despawn(m)}),f}export function*warmAssets(){yield discMesh,yield stickChipMesh,yield catchRingMesh}
1
+ "use strict";import{effects,extrude,Path}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x49106f}from"./EngineMeshes.js";const WHITE=[1,1,1,1],fade=e=>[e[0],e[1],e[2],0];let disc=null;const discMesh=()=>cacheGameAsset("shared/EngineBlasts:discMesh",()=>disc??=_0x49106f(extrude((new Path).addCircle(0,0,.5),{depth:0})));export function popBurst(e,s){const[t,i,o]=s.color;effects.sparkle(e,{position:s.position,count:s.count??8,size:.2*s.size,speed:6*s.size,lifetime:.45,colors:[s.color,WHITE],flash:!1});const n=e.spawn({mesh:discMesh(),position:[s.position[0],s.position[1],s.glowZ??s.position[2]],scale:.85*s.size,color:[t,i,o,.6],pickable:!1});e.animate(n,{scale:2.8*s.size,color:[t,i,o,0]},{duration:.28}).then(()=>{e.has(n)&&e.despawn(n)})}export function popAndBurst(e,s,t,i){const o=t.delay??0,n=t.duration??effects.POP_TIME;return o>0?e.after(o+.12*n,()=>popBurst(e,i)):popBurst(e,i),effects.pop(e,s,t)}let stickChip=null,catchRing=null;const stickChipMesh=()=>cacheGameAsset("shared/EngineBlasts:stickChipMesh",()=>stickChip??=_0x49106f(extrude((new Path).addRoundedRect(-.5,-.09,1,.18,.07),{depth:.16}),{shine:.25})),catchRingMesh=()=>cacheGameAsset("shared/EngineBlasts:catchRingMesh",()=>catchRing??=_0x49106f(extrude((new Path).addCircle(0,0,.5).addCircle(0,0,.465),{depth:0,fillRule:"evenodd"})));export function stickBlast(e,s,t){const[i,o]=t.scale,[n,a,r,l]=t.rotation,h=[1-2*(a*a+r*r),2*(n*a+l*r),2*(n*r-l*a)],p=[2*(n*r+l*a),2*(a*r-l*n),1-2*(n*n+a*a)],d=(e,s=0)=>[t.position[0]+h[0]*i*e+p[0]*s,t.position[1]+h[1]*i*e+p[1]*s,t.position[2]+h[2]*i*e+p[2]*s],f=popAndBurst(e,s,{scale:t.scale,color:t.color,duration:.32},{position:d(0,.6*o),size:Math.max(1.6*o,.24*i),color:t.color,count:14});stickChip=stickChipMesh(),effects.shatter(e,{position:d(0,.4*o),mesh:stickChip,count:7,size:.16*i,speed:2*i,lifetime:.5,gravity:4*-i,colors:[t.color,effects.pale(t.color,.4,1)],flash:!1,dust:!1});for(const s of[-1,1])effects.sparks(e,{position:d(.32*s,.5*o),count:4,size:.18*o,speed:2.5*i,lifetime:.35,gravity:1.5*-i,direction:[h[0]*s,h[1]*s,h[2]*s],spread:.9,colors:[t.color,WHITE],flash:!1});catchRing=catchRingMesh();const u=effects.pale(t.color,.45,.9),m=e.spawn({mesh:catchRing,position:d(0,.8*o),rotation:t.rotation,scale:1.8*o,color:u,pickable:!1});return e.animate(m,{scale:1.1*i,color:fade(u)},{duration:.32,easing:"easeOut"}).then(()=>{e.has(m)&&e.despawn(m)}),f}export function*warmAssets(){yield discMesh,yield stickChipMesh,yield catchRingMesh}
@@ -1 +1 @@
1
- "use strict";import{extrude,loft,Path}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x1f3dd3}from"./EngineMeshes.js";const ASPECT_STEP=.25,blocks=new Map;function blockMesh(e,o){return cacheGameAsset("shared/EngineBlocks:blockMesh"+JSON.stringify([e,o]),()=>blockMeshUncached(e,o))}function blockMeshUncached(e,o){const s=e+":"+o;let t=blocks.get(s);if(!t){const a=e/2;t=_0x1f3dd3(loft([{z:-.5,bottom:-.5,top:.5,width:a,square:7},{z:.2,bottom:-.5,top:.5,width:a,square:7},{z:.4,bottom:-.465,top:.465,width:a-.035,square:6.5},{z:.5,bottom:-.39,top:.39,width:a-.11,square:5.5}],{around:40,smoothness:2}),{center:!1,shine:o?.6:0}),blocks.set(s,t)}return t}let shadow=null;const shadowMesh=()=>shadow??=_0x1f3dd3(extrude((new Path).addRoundedRect(-.5,-.5,1,1,.16),{depth:0})),SHADOW_AT=[.08,-.11,-.52],SHADOW_SIZE=1.04,SHADOW=[0,0,0,.3],aspectOf=e=>Math.max(.25,.25*Math.round(e[0]/e[1]/.25));export const raisedBlockScale=e=>[e[0]/aspectOf(e),e[1],e[2]];export function spawnRaisedBlock(e,{position:o,size:s,color:t,parent:a,grow:n=1,gloss:r=!0,shadow:h=!0}){const d=aspectOf(s),i=raisedBlockScale(s),l=e.spawn({mesh:blockMesh(d,r),parent:a,position:o,scale:[i[0]*n,i[1]*n,i[2]*n],color:t,pickable:!1});return h&&e.spawn({mesh:shadowMesh(),parent:l,position:SHADOW_AT,scale:[1.04*d,1.04,1],color:SHADOW,pickable:!1}),l}
1
+ "use strict";import{extrude,loft,Path}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x41dd0a}from"./EngineMeshes.js";const ASPECT_STEP=.25,blocks=new Map;function blockMesh(e,o){return cacheGameAsset("shared/EngineBlocks:blockMesh"+JSON.stringify([e,o]),()=>blockMeshUncached(e,o))}function blockMeshUncached(e,o){const s=e+":"+o;let t=blocks.get(s);if(!t){const a=e/2;t=_0x41dd0a(loft([{z:-.5,bottom:-.5,top:.5,width:a,square:7},{z:.2,bottom:-.5,top:.5,width:a,square:7},{z:.4,bottom:-.465,top:.465,width:a-.035,square:6.5},{z:.5,bottom:-.39,top:.39,width:a-.11,square:5.5}],{around:40,smoothness:2}),{center:!1,shine:o?.6:0}),blocks.set(s,t)}return t}let shadow=null;const shadowMesh=()=>shadow??=_0x41dd0a(extrude((new Path).addRoundedRect(-.5,-.5,1,1,.16),{depth:0})),SHADOW_AT=[.08,-.11,-.52],SHADOW_SIZE=1.04,SHADOW=[0,0,0,.3],aspectOf=e=>Math.max(.25,.25*Math.round(e[0]/e[1]/.25));export const raisedBlockScale=e=>[e[0]/aspectOf(e),e[1],e[2]];export function spawnRaisedBlock(e,{position:o,size:s,color:t,parent:a,grow:n=1,gloss:r=!0,shadow:h=!0}){const d=aspectOf(s),i=raisedBlockScale(s),l=e.spawn({mesh:blockMesh(d,r),parent:a,position:o,scale:[i[0]*n,i[1]*n,i[2]*n],color:t,pickable:!1});return h&&e.spawn({mesh:shadowMesh(),parent:l,position:SHADOW_AT,scale:[1.04*d,1.04,1],color:SHADOW,pickable:!1}),l}
@@ -1 +1 @@
1
- "use strict";import{effects,loft,merge,quat,shapeGeometry}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x138977}from"./EngineMeshes.js";const IVORY=[.98,.965,.925],IVORY_EDGE=[.86,.83,.77],PIP=[.11,.11,.16,1],RED_PIP=[.84,.16,.16,1],FACES=[{n:[0,0,1],a:[1,0,0],b:[0,1,0]},{n:[0,1,0],a:[1,0,0],b:[0,0,1]},{n:[1,0,0],a:[0,1,0],b:[0,0,1]},{n:[-1,0,0],a:[0,1,0],b:[0,0,1]},{n:[0,-1,0],a:[1,0,0],b:[0,0,1]},{n:[0,0,-1],a:[1,0,0],b:[0,1,0]}],C=.24,PIPS=[[[0,0]],[[-C,C],[C,-C]],[[-C,C],[0,0],[C,-C]],[[-C,C],[C,C],[-C,-C],[C,-C]],[[-C,C],[C,C],[0,0],[-C,-C],[C,-C]],[[-C,C],[C,C],[-C,0],[C,0],[-C,-C],[C,-C]]],EDGE=.12;let die=null;export function dieMesh(){return cacheGameAsset("shared/EngineDice:dieMesh",()=>dieMeshUncached())}function dieMeshUncached(){if(die)return die;const t=[0,.25,.5,.7,.85,.95,1].map(t=>.38+.12*t),a=[...t.map(t=>-t).reverse(),...t].map(t=>{const a=Math.max(.02,(t=>{const a=Math.abs(t)-.38;return a<=0?.5:.38+Math.sqrt(Math.max(0,.0144-a*a))})(t));return{z:t,bottom:-a,top:a,width:a,square:9}}),e=[{geometry:loft(a,{around:48,smoothness:1,color:(t,a)=>{const e=Math.max(Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2]))**6;return[IVORY_EDGE[0]+(IVORY[0]-IVORY_EDGE[0])*e,IVORY_EDGE[1]+(IVORY[1]-IVORY_EDGE[1])*e,IVORY_EDGE[2]+(IVORY[2]-IVORY_EDGE[2])*e,1]}})}],o=shapeGeometry("sphere");return FACES.forEach(({n:t,a:a,b:n},s)=>{const i=0===s,h=i?.28:.17;for(const[r,d]of PIPS[s])e.push({geometry:o,position:[0,1,2].map(e=>.488*t[e]+a[e]*r+n[e]*d),scale:[0,1,2].map(a=>t[a]?.035:h),color:i?RED_PIP:PIP})}),die=_0x138977(merge(e),{shine:.45}),die}const axisAngle=(t,a,e,o)=>{const n=Math.hypot(t,a,e)||1;return quat.axisAngle(t/n,a/n,e/n,o)},mul=quat.multiply,FACE_UP=[axisAngle(1,0,0,0),axisAngle(1,0,0,Math.PI/2),axisAngle(0,1,0,-Math.PI/2),axisAngle(0,1,0,Math.PI/2),axisAngle(1,0,0,-Math.PI/2),axisAngle(0,1,0,Math.PI)];export const dieRotation=(t,a,e=0)=>mul(axisAngle(1,0,0,t),mul(axisAngle(0,0,1,e),FACE_UP[a-1]));const HOPS=[{up:.2,down:.44,height:1.7},{up:.555,down:.67,height:.55},{up:.735,down:.8,height:.16}];export function rollDie(t,a){const{die:e,shadow:o,rest:n,size:s,duration:i}=a;t.stopAnimation(e),t.stopAnimation(o);const h=Math.random()*Math.PI*2,r=t=>[Math.cos(h)*s*t,Math.sin(h)*s*t*.6],d=[.35,-.2,.06],l=[],u=[],m=(t,e,o)=>{const[n,s]=r(t),i=1-Math.min(.55,.3*e);var h,d;u.push({position:(h=n,d=s,[a.shadowAt[0]+h,a.shadowAt[1]+d,a.shadowAt[2]]),scale:[a.shadowScale[0]*i,a.shadowScale[1]*i,a.shadowScale[2]],color:[0,0,0,.22*i],at:o})};let p=0;HOPS.forEach((t,a)=>{const e=d[a],o=(p+e)/2,[i,h]=r(o);l.push({position:[n[0]+i,n[1]+h,n[2]+t.height*s],at:t.up}),m(o,t.height,t.up);const[u,C]=r(e);l.push({position:[n[0]+u,n[1]+C,n[2]],at:t.down}),m(e,0,t.down),p=e}),l.push({position:n,at:1}),u.push({position:a.shadowAt,scale:a.shadowScale,color:[0,0,0,.22],at:1}),t.animate(e,l,{duration:i,path:"smooth",easing:"linear"}),t.animate(o,u,{duration:i,easing:"linear"});const C=(Math.round(4*Math.random())-2)*(Math.PI/2)+.3*(Math.random()-.5),M=dieRotation(a.tilt,a.value,C),g=[2.4,2.1,1.6,.9],E=[];let P=M;for(let t=g.length-1;t>=0;t--){const a=[Math.random()-.5,Math.random()-.5,Math.random()-.5];P=mul(axisAngle(a[0],a[1],a[2],-g[t]),P),E.unshift({rotation:P,at:[.12,.3,.5,.64][t]})}E.push({rotation:M,at:HOPS[1].down}),E.push({rotation:M,at:1}),t.animate(e,E,{duration:i,easing:"linear"}),HOPS.slice(0,2).forEach((e,o)=>t.after(e.down*i,()=>{if(a.disposed?.())return;const[e,i]=r(d[o]);effects.dust(t,{position:[n[0]+e,n[1]+i,n[2]-.45*s],count:o?3:6,size:s*(o?.35:.5),speed:2.5*s,lifetime:.4,color:[1,1,1,.45],endSize:1.8})}))}
1
+ "use strict";import{effects,loft,merge,quat,shapeGeometry}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x7c0f5e}from"./EngineMeshes.js";const IVORY=[.98,.965,.925],IVORY_EDGE=[.86,.83,.77],PIP=[.11,.11,.16,1],RED_PIP=[.84,.16,.16,1],FACES=[{n:[0,0,1],a:[1,0,0],b:[0,1,0]},{n:[0,1,0],a:[1,0,0],b:[0,0,1]},{n:[1,0,0],a:[0,1,0],b:[0,0,1]},{n:[-1,0,0],a:[0,1,0],b:[0,0,1]},{n:[0,-1,0],a:[1,0,0],b:[0,0,1]},{n:[0,0,-1],a:[1,0,0],b:[0,1,0]}],C=.24,PIPS=[[[0,0]],[[-C,C],[C,-C]],[[-C,C],[0,0],[C,-C]],[[-C,C],[C,C],[-C,-C],[C,-C]],[[-C,C],[C,C],[0,0],[-C,-C],[C,-C]],[[-C,C],[C,C],[-C,0],[C,0],[-C,-C],[C,-C]]],EDGE=.12;let die=null;export function dieMesh(){return cacheGameAsset("shared/EngineDice:dieMesh",()=>dieMeshUncached())}function dieMeshUncached(){if(die)return die;const t=[0,.25,.5,.7,.85,.95,1].map(t=>.38+.12*t),a=[...t.map(t=>-t).reverse(),...t].map(t=>{const a=Math.max(.02,(t=>{const a=Math.abs(t)-.38;return a<=0?.5:.38+Math.sqrt(Math.max(0,.0144-a*a))})(t));return{z:t,bottom:-a,top:a,width:a,square:9}}),e=[{geometry:loft(a,{around:48,smoothness:1,color:(t,a)=>{const e=Math.max(Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2]))**6;return[IVORY_EDGE[0]+(IVORY[0]-IVORY_EDGE[0])*e,IVORY_EDGE[1]+(IVORY[1]-IVORY_EDGE[1])*e,IVORY_EDGE[2]+(IVORY[2]-IVORY_EDGE[2])*e,1]}})}],o=shapeGeometry("sphere");return FACES.forEach(({n:t,a:a,b:n},s)=>{const i=0===s,h=i?.28:.17;for(const[r,d]of PIPS[s])e.push({geometry:o,position:[0,1,2].map(e=>.488*t[e]+a[e]*r+n[e]*d),scale:[0,1,2].map(a=>t[a]?.035:h),color:i?RED_PIP:PIP})}),die=_0x7c0f5e(merge(e),{shine:.45}),die}const axisAngle=(t,a,e,o)=>{const n=Math.hypot(t,a,e)||1;return quat.axisAngle(t/n,a/n,e/n,o)},mul=quat.multiply,FACE_UP=[axisAngle(1,0,0,0),axisAngle(1,0,0,Math.PI/2),axisAngle(0,1,0,-Math.PI/2),axisAngle(0,1,0,Math.PI/2),axisAngle(1,0,0,-Math.PI/2),axisAngle(0,1,0,Math.PI)];export const dieRotation=(t,a,e=0)=>mul(axisAngle(1,0,0,t),mul(axisAngle(0,0,1,e),FACE_UP[a-1]));const HOPS=[{up:.2,down:.44,height:1.7},{up:.555,down:.67,height:.55},{up:.735,down:.8,height:.16}];export function rollDie(t,a){const{die:e,shadow:o,rest:n,size:s,duration:i}=a;t.stopAnimation(e),t.stopAnimation(o);const h=Math.random()*Math.PI*2,r=t=>[Math.cos(h)*s*t,Math.sin(h)*s*t*.6],d=[.35,-.2,.06],l=[],u=[],m=(t,e,o)=>{const[n,s]=r(t),i=1-Math.min(.55,.3*e);var h,d;u.push({position:(h=n,d=s,[a.shadowAt[0]+h,a.shadowAt[1]+d,a.shadowAt[2]]),scale:[a.shadowScale[0]*i,a.shadowScale[1]*i,a.shadowScale[2]],color:[0,0,0,.22*i],at:o})};let p=0;HOPS.forEach((t,a)=>{const e=d[a],o=(p+e)/2,[i,h]=r(o);l.push({position:[n[0]+i,n[1]+h,n[2]+t.height*s],at:t.up}),m(o,t.height,t.up);const[u,C]=r(e);l.push({position:[n[0]+u,n[1]+C,n[2]],at:t.down}),m(e,0,t.down),p=e}),l.push({position:n,at:1}),u.push({position:a.shadowAt,scale:a.shadowScale,color:[0,0,0,.22],at:1}),t.animate(e,l,{duration:i,path:"smooth",easing:"linear"}),t.animate(o,u,{duration:i,easing:"linear"});const C=(Math.round(4*Math.random())-2)*(Math.PI/2)+.3*(Math.random()-.5),M=dieRotation(a.tilt,a.value,C),g=[2.4,2.1,1.6,.9],E=[];let P=M;for(let t=g.length-1;t>=0;t--){const a=[Math.random()-.5,Math.random()-.5,Math.random()-.5];P=mul(axisAngle(a[0],a[1],a[2],-g[t]),P),E.unshift({rotation:P,at:[.12,.3,.5,.64][t]})}E.push({rotation:M,at:HOPS[1].down}),E.push({rotation:M,at:1}),t.animate(e,E,{duration:i,easing:"linear"}),HOPS.slice(0,2).forEach((e,o)=>t.after(e.down*i,()=>{if(a.disposed?.())return;const[e,i]=r(d[o]);effects.dust(t,{position:[n[0]+e,n[1]+i,n[2]-.45*s],count:o?3:6,size:s*(o?.35:.5),speed:2.5*s,lifetime:.4,color:[1,1,1,.45],endSize:1.8})}))}
@@ -1 +1 @@
1
- "use strict";import{extrude,lathe,merge,Path,recolor,tube}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x5a3f3a}from"./EngineMeshes.js";function boxCenter(e){const t=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let s=0;s<e.vertices.length;s+=11)for(let r=0;r<3;r++)t[r]=Math.min(t[r],e.vertices[s+r]),o[r]=Math.max(o[r],e.vertices[s+r]);return[(t[0]+o[0])/2,(t[1]+o[1])/2,(t[2]+o[2])/2]}const TAU=2*Math.PI,fract=e=>e-Math.floor(e),hash=(e,t)=>fract(43758.5453*Math.sin(127.1*e+311.7*t)),smooth=e=>e*e*(3-2*e),clamp01=e=>Math.max(0,Math.min(1,e)),smoothstep=(e,t,o)=>smooth(clamp01((o-e)/(t-e)));function noise(e,t,o,s){const r=e*o,n=t*s,a=Math.floor(r),h=Math.floor(n),i=smooth(r-a),m=smooth(n-h),l=(e,t)=>hash((e%o+o)%o,t),u=l(a,h)+(l(a+1,h)-l(a,h))*i;return u+(l(a,h+1)+(l(a+1,h+1)-l(a,h+1))*i-u)*m}const mix=(e,t,o)=>[e[0]+(t[0]-e[0])*o,e[1]+(t[1]-e[1])*o,e[2]+(t[2]-e[2])*o],shade=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],turn=(e,t)=>[e[0]*Math.sin(t/2),e[1]*Math.sin(t/2),e[2]*Math.sin(t/2),Math.cos(t/2)];function mul(e,t){const[o,s,r,n]=e,[a,h,i,m]=t;return[n*a+o*m+s*i-r*h,n*h-o*i+s*m+r*a,n*i+o*h-s*a+r*m,n*m-o*a-s*h-r*i]}function upTo(e){const t=[e[2],0,-e[0]],o=Math.hypot(t[0],t[2]);return o<1e-6?e[1]>0?[0,0,0,1]:[1,0,0,0]:turn([t[0]/o,0,t[2]/o],Math.acos(Math.max(-1,Math.min(1,e[1]))))}const yTurn=e=>turn([0,1,0],e);function warp(e,t){const o=e.vertices,s=1e-4,r=(e,t)=>[(e[0]-t[0])/s,(e[1]-t[1])/s,(e[2]-t[2])/s],n=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]];for(let e=0;e<o.length;e+=11){const[a,h,i]=[o[e],o[e+1],o[e+2]],m=t([a,h,i]),[l,u,p]=[r(t([a+s,h,i]),m),r(t([a,h+s,i]),m),r(t([a,h,i+s]),m)],[g,M,f]=[n(u,p),n(p,l),n(l,u)],[x,y,d]=[o[e+3],o[e+4],o[e+5]],w=[0,1,2].map(e=>x*g[e]+y*M[e]+d*f[e]),P=Math.hypot(w[0],w[1],w[2]);o.set(m,e),P>1e-12&&o.set([w[0]/P,w[1]/P,w[2]/P],e+3)}return e}let detail=1;const seg=e=>e<=8?e:Math.max(8,Math.round(e*detail));function profile(e,t,o=48){o=seg(o);const s=[];for(let r=0;r<=o;r++){const n=r/o;s.push([Math.max(0,t(n)),e/2-n*e])}return s}function resample(e,t){t=seg(t);const o=[0];for(let t=1;t<e.length;t++)o.push(o[t-1]+Math.hypot(e[t][0]-e[t-1][0],e[t][1]-e[t-1][1]));const s=o[o.length-1],r=[];let n=0;for(let a=0;a<=t;a++){const h=a/t*s;for(;n<e.length-2&&o[n+1]<h;)n++;const i=(h-o[n])/(o[n+1]-o[n]||1);r.push([e[n][0]+(e[n+1][0]-e[n][0])*i,e[n][1]+(e[n+1][1]-e[n][1])*i])}return r}const rounded=(e,t,o=2,s=64)=>profile(e,e=>t*Math.pow(Math.max(0,1-Math.pow(Math.abs(2*e-1),o)),1/o),s);function radiusAt(e,t){let o=0;for(let s=0;s<e.length-1;s++){const[r,n]=e[s],[a,h]=e[s+1];(t-n)*(t-h)<=0&&n!==h&&(o=Math.max(o,r+(t-n)/(h-n)*(a-r)))}return o}function undimpled(e){let[t,o]=[0,0];return e.forEach((s,r)=>{s[1]>e[t][1]&&(t=r),s[1]<e[o][1]&&(o=r)}),e.slice(t,o+1)}function normalize(e){const t=Math.max(...e.map(e=>e[1])),o=Math.min(...e.map(e=>e[1])),s=2*Math.max(...e.map(e=>e[0])),r=1/Math.max(s,t-o),n=(t+o)/2;return e.map(([e,t])=>[e*r,(t-n)*r])}function onSurface(e,t,o){const s=t*(e.length-1),r=Math.min(e.length-2,Math.floor(s)),n=s-r,[a,h]=e[r],[i,m]=e[r+1],l=a+(i-a)*n,u=h+(m-h)*n,p=Math.hypot(i-a,m-h)||1,[g,M]=[(h-m)/p,(i-a)/p],[f,x]=[Math.cos(o),-Math.sin(o)];return[[l*f,u,l*x],[g*f,M,g*x]]}const LEAF_TOP=[.24,.56,.17],LEAF_UNDER=[.19,.46,.14],VEIN=[.55,.74,.36];function leaf(e,t,{fold:o=.38,teeth:s=14,stalk:r=.16}={}){const n=o=>{const r=[[0,0]],n=2*s;for(let s=1;s<n;s++){const a=s/n,h=s%2?.07:0,i=t*Math.pow(Math.sin(Math.PI*a),.75)*(1-.25*a)*(1+h);r.push([e*a,o*i])}return r.push([e,0]),extrude((new Path).addPolygon(r.map(([e,t])=>[e,-t])),{depth:.006})};return merge([{geometry:n(1),rotation:turn([1,0,0],o),color:LEAF_TOP},{geometry:n(-1),rotation:turn([1,0,0],-o),color:LEAF_UNDER},{geometry:tube([[0,0,0],[.5*e,.004,0],[.96*e,0,0]],{radius:e=>.007*(1-e)+.002,sides:seg(6)}),color:VEIN},{geometry:tube([[-e*r,-.01,0],[0,0,0]],{radius:.008,sides:seg(6)}),color:[.36,.42,.18]}])}function stem(e,t=.024,o=.06){return tube([[0,-.03,0],[.005,.4*e,0],[.5*o,.8*e,0],[o,e,0]],{radius:e=>t*(1.25-.45*e+(e>.9?.5*(e-.9)*10:0)),sides:seg(8),color:e=>mix([.33,.21,.1],[.5,.42,.28],smoothstep(.75,1,e.v)+.15*noise(e.u,e.v,6,10)),capColor:[.62,.55,.4]})}const seed=(e=8)=>lathe([[0,.5],[.22,.32],[.4,.02],[.36,-.28],[.2,-.45],[0,-.5]],{segments:e}),calyx=(e,t,o,s=.012)=>extrude((new Path).addStar(0,0,e,t,o),{depth:s}),FACE_UP=turn([1,0,0],-Math.PI/2),CUT_ACROSS=turn([1,0,0],-Math.PI/2),SKIN_SEGMENTS=72,halfTurn=e=>t=>e({u:.5*t.u,v:t.v}),upperHalf=e=>t=>e({u:t.u,v:.5*t.v}),upperDisplace=e=>(t,o)=>e(t,.5*o);function apple(){const e=normalize(resample(Path.fromSVG("M0 0.1 C 0.12 -0.03 0.42 -0.06 0.5 0.3 C 0.55 0.62 0.36 0.9 0.14 0.93 Q 0.05 0.94 0 0.88").toContours()[0].map(([e,t])=>[e,-t]),64)),t=[.68,.04,.06],o=[.45,.02,.05],s=[.86,.66,.18],r=({u:e,v:r})=>{const n=noise(e,r,90,4);let a=mix(t,o,.7*smoothstep(.35,.9,n));return a=mix(a,s,.35*smoothstep(.55,.8,noise(e,r,7,3))),a=mix(a,[.72,.68,.22],.75*smoothstep(.16,.02,r)+.6*smoothstep(.86,.99,r)),hash(Math.floor(140*e),Math.floor(70*r))>.975&&(a=mix(a,[.95,.85,.55],.55)),a},n=e[0][1],a=e[e.length-1][1],h=lathe(e,{segments:seg(72),color:r}),i=merge([{geometry:h},{geometry:stem(.17,.022,.05),position:[0,n,0]},{geometry:leaf(.32,.075),position:[.03,n+.11,0],rotation:mul(turn([0,1,0],-.5),turn([0,0,1],.55))},{geometry:calyx(.05,.015,5),position:[0,a-.004,0],rotation:turn([1,0,0],Math.PI/2),color:[.3,.2,.1]}]),m=(e,t)=>{const o=Math.hypot(e/.2,t/.24);let s=[.97,.93,.74];return s=mix(s,[.92,.88,.62],smoothstep(1.05,.85,o)),s=mix(s,[.82,.76,.5],.6*smoothstep(.12,0,Math.abs(o-1))),mix(s,[1,.97,.88],.6*smoothstep(.88,1,e))};return withPieces({center:boxCenter(i),whole:_0x5a3f3a(i,{center:!1,shine:.65}),juice:[.98,.94,.75]},()=>{const t=merge([{geometry:lathe(undimpled(e),{segments:seg(72),sweep:Math.PI,color:halfTurn(r),cutColor:m,cutSteps:24,capColor:[.7,.62,.25]})},...[-1,1].map(e=>({geometry:seed(),position:[.06*e,-.02,.004],scale:[.045,.075,.02],rotation:turn([0,0,1],.35*e),color:[.3,.17,.08]}))]),o=_0x5a3f3a(t,{center:!1,shine:.3});return[o,o]})}function citrusFace(e,t,o,s,r){return(n,a)=>{if(n>1-.45*r)return e;if(n>1-r)return t;if(n<.12)return mix(t,o,smoothstep(.08,.12,n));const h=TAU/s,i=Math.abs(fract(a/h)-.5)*h*n,m=smoothstep(.5*h*n-.02,.5*h*n-.006,i),l=noise(a/TAU,n,6*s,9);return mix(shade(o,.92+.16*l),t,.85*m)}}const peel=(e,t)=>(o,s)=>-e*Math.pow(noise(o,s,t,.55*t),2)-.5*e*noise(o,s,2.5*t,1.4*t);function orange(){const e=normalize(rounded(.94,.5,2,64)),t=[1,.47,.03],o=({u:e,v:o})=>{let s=shade(t,.9+.14*noise(e,o,40,22));return s=mix(s,[.82,.55,.12],.6*smoothstep(.05,0,o)),mix(s,[.75,.35,.05],.7*smoothstep(.95,1,o))},s=peel(.006,64),r=e[0][1],n=merge([{geometry:lathe(e,{segments:seg(120),color:o,displace:s})},{geometry:calyx(.06,.025,5,.01),position:[0,r-.002,0],rotation:FACE_UP,color:[.3,.42,.14]},{geometry:tube([[0,r-.01,0],[0,r+.035,0]],{radius:.014,sides:seg(6)}),color:[.42,.4,.2]}]);return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.35}),juice:[1,.6,.1]},()=>{const r=e.slice(0,Math.floor(e.length/2)+1),n=citrusFace(shade(t,.95),[.99,.95,.84],[1,.58,.08],10,.12),a=_0x5a3f3a(merge([{geometry:lathe(r,{segments:seg(120),color:upperHalf(o),displace:upperDisplace(s),capColor:n,capRings:24}),rotation:CUT_ACROSS}]),{center:!1,shine:.25});return[a,a]})}function lemon(){const e=normalize(profile(1,e=>.34*Math.pow(Math.sin(Math.PI*e),.75),64)),t=[1,.86,.12],o=({u:e,v:o})=>{const s=shade(t,.9+.14*noise(e,o,36,20));return mix(s,[.62,.72,.15],.6*(smoothstep(.06,0,o)+smoothstep(.94,1,o)))},s=peel(.005,56),r=turn([0,0,1],Math.PI/2),n=merge([{geometry:lathe(e,{segments:seg(96),color:o,displace:s}),rotation:r}]);return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.4}),juice:[1,.95,.55]},()=>{const r=e.slice(0,Math.floor(e.length/2)+1),n=citrusFace(t,[.99,.97,.86],[1,.93,.5],9,.1),a=_0x5a3f3a(merge([{geometry:lathe(r,{segments:seg(96),color:upperHalf(o),displace:upperDisplace(s),capColor:n,capRings:20}),rotation:CUT_ACROSS}]),{center:!1,shine:.3});return[a,a]})}function pear(){const e=normalize(profile(1,e=>Math.pow(Math.sin(Math.PI*e),.55)*(.18+.37*Math.pow(e,1.35))*(1-.15*Math.exp(30*-e)),64)),t=({u:e,v:t})=>{let o=mix([.62,.74,.2],[.84,.8,.28],noise(e,t,6,4));const s=Math.pow(Math.max(0,Math.cos((e-.2)*TAU)),2)*smoothstep(.3,.8,t);return o=mix(o,[.78,.28,.12],.55*s),o=mix(o,[.55,.42,.18],.6*smoothstep(.12,0,t)),hash(Math.floor(120*e),Math.floor(64*t))>.95&&(o=mix(o,[.5,.38,.18],.65)),o},o=e[0][1],s=e[e.length-1][1],r=merge([{geometry:lathe(e,{segments:seg(72),color:t})},{geometry:stem(.2,.02,.07),position:[0,o,0]},{geometry:calyx(.035,.012,5),position:[0,s-.003,0],rotation:turn([1,0,0],Math.PI/2),color:[.32,.22,.12]}]),n=(e,t)=>{const o=Math.hypot(e/.17,(t+.15)/.17);let s=[.98,.96,.82];return s=mix(s,[.92,.9,.7],smoothstep(1.1,.8,o)),mix(s,[.86,.82,.58],.6*smoothstep(.1,0,Math.abs(o-1)))};return withPieces({center:boxCenter(r),whole:_0x5a3f3a(r,{center:!1,shine:.45}),juice:[.98,.96,.8]},()=>{const o=merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:n})},...[-1,1].map(e=>({geometry:seed(),position:[.05*e,-.16,.004],scale:[.035,.06,.018],rotation:turn([0,0,1],.3*e),color:[.25,.14,.07]}))]),s=_0x5a3f3a(o,{center:!1,shine:.25});return[s,s]})}function strawberry(){const e=normalize(profile(1,e=>.5*Math.pow(Math.sin(Math.PI*Math.min(1,1.02*e)),.45)*(1-.62*Math.pow(e,1.2)),64)),t=({v:e})=>{let t=[.82,.05,.1];return t=mix(t,[.95,.8,.62],.7*smoothstep(.1,.02,e)),mix(t,[.95,.25,.12],.5*smoothstep(.8,1,e))},o=t=>{const o=[];for(let s=0;s<80;s++){const r=.14+.8*s/80,n=fract(.381966*s)*TAU;if(n>t)continue;const[a,h]=onSurface(e,r,n);o.push({geometry:seed(6),position:[a[0]-.003*h[0],a[1]-.003*h[1],a[2]-.003*h[2]],rotation:upTo(h),scale:[.022,.018,.03],color:[.95,.8,.3]})}return o},s=e[0][1],r=[];for(let e=0;e<8;e++){const t=e/8*TAU+.2;r.push({geometry:leaf(.26+.05*Math.sin(2.3*e),.05,{fold:.2,teeth:4,stalk:0}),position:[0,s+.012,0],rotation:mul(turn([0,1,0],t),turn([0,0,1],.08-.1*Math.cos(1.7*e)))})}const n=[...r,{geometry:stem(.12,.018,.02),position:[0,s-.02,0],color:[.55,1.2,.5]}],a=merge([{geometry:lathe(e,{segments:seg(72),color:t})},...o(TAU),...n]),h=(e,t)=>{const o=mix([1,.85,.82],[.88,.12,.16],smoothstep(.35,.85,e));return mix(o,[.98,.75,.72],.4*smoothstep(.12,0,Math.abs(e-.32))*smoothstep(-.4,.2,t))};return withPieces({center:boxCenter(a),whole:_0x5a3f3a(a,{center:!1,shine:.55}),juice:[.95,.15,.2]},()=>{const s=_0x5a3f3a(merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:h})},...o(Math.PI)]),{center:!1,shine:.4});return[s,s]})}function watermelon(){const e=normalize(rounded(1,.36,2.2,64)),t=[.07,.27,.08],o=[.42,.62,.26],s=({u:e,v:s})=>{const r=.9*(noise(e,s,16,10)-.5),n=Math.sin((16*e+r)*TAU);let a=mix(o,t,smoothstep(-.35,.1,n));a=shade(a,.9+.15*noise(e,s,50,30));const h=smoothstep(.16,.05,Math.hypot(2.2*(fract(e-.75+.5)-.5),s-.5));return mix(a,[.82,.76,.38],.85*h)},r=turn([0,0,1],Math.PI/2),n=merge([{geometry:lathe(e,{segments:seg(96),color:s}),rotation:r}]),a=e=>e>.965?t:e>.92?mix([.62,.8,.45],[.85,.93,.7],(.965-e)/.045):e>.86?mix([.97,.97,.85],[.98,.55,.5],smoothstep(.92,.86,e)):mix([.98,.3,.32],[.88,.1,.16],smoothstep(.85,.2,e));return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.35}),juice:[.95,.2,.25]},()=>{const t=e.slice(0,Math.floor(e.length/2)+1),o=t[t.length-1][0],r=[];for(let e=0;e<14;e++){const t=e/14*TAU+e%2*.12,s=o*(.5+e%3*.1);r.push({geometry:seed(),position:[Math.cos(t)*s,-.004,-Math.sin(t)*s],rotation:mul(turn([0,1,0],t+Math.PI/2),turn([1,0,0],Math.PI/2)),scale:[.03,.05,.012],color:[.08,.05,.04]})}const n=merge([{geometry:merge([{geometry:lathe(t,{segments:seg(96),color:upperHalf(s),capColor:a,capRings:24})},...r]),rotation:CUT_ACROSS}]),h=_0x5a3f3a(n,{center:!1,shine:.25});return[h,h]})}function banana(){const e=[];for(let t=0;t<=12;t++){const o=Math.PI*(.12+.76*t/12);e.push([.5*-Math.cos(o),.3*-Math.sin(o),0])}const t=e.map(e=>e[0]),o=e.map(e=>e[1]),[s,r]=[(Math.min(...t)+Math.max(...t))/2,(Math.min(...o)+Math.max(...o))/2],n=.92/(Math.max(...t)-Math.min(...t)),a=e.map(([e,t])=>[(e-s)*n,(t-r)*n+.06,0]),h=e=>1+.06*Math.cos(e*TAU*5),i=a[a.length-1],m=a[a.length-2],l=[i[0]-m[0],i[1]-m[1]],u=Math.hypot(l[0],l[1]),p=[i[0]+l[0]/u*.1,i[1]+l[1]/u*.1+.015,0],g=tube([i,p],{radius:e=>.026-.006*e,shape:e=>1+.12*Math.cos(e*TAU*4),sides:seg(12),color:[.45,.48,.2],capColor:[.3,.25,.12]}),M=(e,t,o)=>tube(e,{radius:e=>{return s=t+(o-t)*e,.014+.09*Math.pow(Math.sin(Math.PI*Math.min(1,.03+.97*s)),.55);var s},shape:h,sides:seg(30),smoothness:6,color:e=>(({u:e,v:t})=>{let o=[1,.84,.16];o=mix(o,[.82,.76,.18],.4*(.5+.5*Math.cos(e*TAU*5))),o=mix(o,[.62,.72,.2],.6*smoothstep(.82,1,t)),o=mix(o,[.18,.12,.06],smoothstep(.05,0,t));const s=noise(e,t,18,26);return s>.78&&(o=mix(o,[.45,.28,.08],.9*smoothstep(.78,.88,s))),o})({u:e.u,v:t+(o-t)*e.v}),capColor:e=>{return(t=e)>.9?[1,.84,.16]:t<.22?[.86,.8,.58]:[.99,.95,.78];var t}}),f=merge([{geometry:M(a,0,1)},{geometry:g}]);return withPieces({center:boxCenter(f),whole:_0x5a3f3a(f,{center:!1,shine:.3}),juice:[1,.95,.72]},()=>{const e=Math.floor(a.length/2),t=M(a.slice(0,e+1),0,e/(a.length-1)),o=merge([{geometry:M(a.slice(e),e/(a.length-1),1)},{geometry:g}]);return[_0x5a3f3a(merge([{geometry:t,rotation:turn([0,1,0],-Math.PI/2)}]),{center:!1,shine:.3}),_0x5a3f3a(merge([{geometry:o,rotation:turn([0,1,0],Math.PI/2)}]),{center:!1,shine:.3})]})}function cherries(){const e=normalize(resample(Path.fromSVG("M0 0.12 C 0.1 0.01 0.46 -0.04 0.5 0.42 C 0.53 0.76 0.3 0.98 0 0.96").toContours()[0].map(([e,t])=>[e,-t]),40)),t=({u:e,v:t})=>{let o=mix([.55,.02,.07],[.26,0,.04],.6*smoothstep(.3,.75,noise(e,t,5,3))+.35*smoothstep(.5,1,t));return o=mix(o,[.78,.12,.12],.4*smoothstep(.2,.05,t)),mix(o,[.2,.02,.03],.7*smoothstep(.92,1,t))},o=e[0][1],s=.42,r=[[-.2,-.2,.02],[.19,-.28,-.04]],n=[.06,.55,0],a=(e,t)=>tube([[e[0],e[1]+o*s-.02,e[2]],[e[0]+.4*t,e[1]+.38,.5*e[2]],[n[0]+.15*t,n[1]-.12,0],n],{radius:e=>.012+.003*e,sides:seg(7),color:e=>mix([.4,.55,.16],[.42,.32,.14],smoothstep(.75,1,e.v)),capColor:[.35,.25,.12]}),h=[{geometry:a(r[0],-.1)},{geometry:a(r[1],.08)},{geometry:leaf(.3,.07),position:n,rotation:mul(turn([0,1,0],.6),turn([0,0,1],.4))}],i=lathe(e,{segments:seg(40),color:t}),m=merge([...r.map(e=>({geometry:i,position:e,scale:s})),...h]),l=(e,t)=>{const o=Math.hypot(e/.42,(t+.02)/.32);return o<1?mix([.93,.84,.66],[.8,.66,.5],o*o):mix([.62,.04,.1],[.42,.01,.06],smoothstep(1,2.2,o))};return withPieces({center:boxCenter(m),whole:_0x5a3f3a(m,{center:!1,shine:.85}),juice:[.6,.03,.1]},()=>{const o=lathe(undimpled(e),{segments:seg(40),sweep:Math.PI,color:halfTurn(t),cutColor:l,cutSteps:20,capColor:[.5,.04,.08]});return[_0x5a3f3a(merge([{geometry:o,position:[0,r[0][1],0],scale:s}]),{center:!1,shine:.7}),_0x5a3f3a(merge([{geometry:o,position:[0,r[1][1],0],scale:s},{geometry:merge(h),position:[-r[1][0],0,0],rotation:yTurn(Math.PI/2)}]),{center:!1,shine:.7})]})}function grapes(){const e=normalize(rounded(1.12,.5,2,16)),t=({u:e,v:t})=>{let o=mix([.3,.07,.27],[.17,.03,.17],smoothstep(.2,.9,noise(e,t,4,3)));return o=mix(o,[.52,.46,.62],.3*smoothstep(.35,.8,noise(e,t,9,6))),mix(o,[.36,.14,.25],.3*smoothstep(.6,.1,t))},o=lathe(e,{segments:seg(24),color:t}),s=lathe(e,{segments:seg(24),sweep:Math.PI,color:halfTurn(t),cutColor:e=>e>.93?[.3,.08,.25]:mix([.86,.9,.62],[.58,.68,.32],e*e),cutSteps:6}),r=[];for(let e=0;e<8;e++){const t=e/7,o=.32-.78*t,s=.26*Math.pow(1-t,.85)*(1-.35*Math.pow(1-t,6));for(const[t,n]of[[s,0],[.45*s,.5]]){const s=t<.03?n?0:1:Math.max(1,Math.floor(TAU*t/(1.85*.085)));for(let a=0;a<s;a++){const h=(a+n+.37*e)/s*TAU,i=hash(e,a+10*n);r.push({at:[Math.cos(h)*t,o+.04*(i-.5),Math.sin(h)*t],tint:shade([1,.95+.1*i,1],.85+.3*hash(a,e+3)),turn:2*i})}}}const n=[.17,.17,.17],a=e=>({geometry:o,position:e.at,scale:n,color:e.tint,rotation:mul(turn([0,0,1],.5*(e.turn-1)),yTurn(3*e.turn))}),h=e=>mix([.42,.35,.16],[.32,.22,.1],noise(e.u,e.v,4,6)),i=tube([[.02,.62,0],[0,.48,0],[.01,.3,0],[0,.1,0]],{radius:e=>.022-.008*e,sides:seg(8),color:h,capColor:[.55,.48,.3]}),m=[0,1,2,3].map(e=>{const t=e/4*TAU+.4;return{geometry:tube([[0,.42-.04*e,0],[.12*Math.cos(t),.36-.05*e,.12*Math.sin(t)],[.2*Math.cos(t),.3-.06*e,.2*Math.sin(t)]],{radius:.009,sides:seg(6),color:h})}}),l=[];for(let e=0;e<160;e++){const t=e/160*TAU,o=.22*(.6+.4*Math.pow(Math.abs(Math.cos(2.5*(t-Math.PI/2))),.7))*(1-.55*Math.exp(-Math.pow((t-Math.PI/2)/.22,2)))*(1+(e%4==0?.06:0));l.push([Math.cos(t)*o,Math.sin(t)*o-.05])}const u=recolor(extrude((new Path).addPolygon(l),{depth:.008}),({position:e})=>{const t=Math.atan2(e[1]+.05,e[0]),o=Math.min(...[0,1,2,3,4].map(e=>Math.abs(Math.sin(t-(Math.PI/2+e*TAU/5)))));return mix([.22,.48,.14],[.55,.72,.3],.8*smoothstep(.08,0,o*Math.hypot(e[0],e[1]+.05)*6))}),p=[];for(let e=0;e<=24;e++)p.push([-.04-.008*e,.56+.05*Math.sin(.8*e),.05*Math.cos(.8*e)]);const g=[{geometry:i},...m,{geometry:u,position:[.17,.56,-.06],rotation:mul(turn([0,1,0],-.4),turn([1,0,0],-.9))},{geometry:tube(p,{radius:.005,sides:seg(5),color:[.45,.6,.2]})}],M=merge([...r.map(a),...g]),f=e=>{const t=[];for(const o of r)Math.abs(o.at[0])<.0595?t.push({geometry:s,position:[0,o.at[1],o.at[2]],scale:n,color:o.tint,rotation:yTurn(e*Math.PI/2)}):Math.sign(o.at[0])===-e&&t.push(a(o));return 1===e?[...t,...g]:t};return withPieces({center:boxCenter(M),whole:_0x5a3f3a(M,{center:!1,shine:.4}),juice:[.75,.85,.45]},()=>[_0x5a3f3a(merge([{geometry:merge(f(1)),rotation:yTurn(-Math.PI/2)}]),{center:!1,shine:.4}),_0x5a3f3a(merge([{geometry:merge(f(-1)),rotation:yTurn(Math.PI/2)}]),{center:!1,shine:.4})])}function kiwi(){const e=normalize(rounded(1,.4,2.4,72)),t=({u:e,v:t})=>{let o=mix([.5,.35,.18],[.36,.24,.11],noise(e,t,12,8));return o=shade(o,.85+.3*hash(Math.floor(200*e),Math.floor(90*t))),mix(o,[.3,.2,.1],.6*(smoothstep(.05,0,t)+smoothstep(.95,1,t)))},o=(e,t)=>-.004*noise(e,t,60,30),s=turn([0,0,1],Math.PI/2),r=(e,t)=>{if(e>.975)return[.42,.3,.14];if(e>.94)return mix([.55,.72,.2],[.4,.58,.12],(e-.94)/.035);const o=noise(t/TAU,e,70,3);if(e<.26)return mix([.97,.96,.78],[.86,.9,.55],.6*smoothstep(.18,.26,e)+.1*o);const s=Math.floor(t/TAU*56),r=hash(s,7),n=Math.abs(fract(t/TAU*56)-.5)/56*TAU*e,a=.34+.06*r;if(Math.hypot(n/.016,(e-a)/.045)<1)return[.06,.05,.03];const h=mix([.62,.86,.22],[.44,.7,.08],smoothstep(.3,.9,e));return mix(h,[.85,.95,.5],.25*o*smoothstep(.95,.4,e))},n=merge([{geometry:lathe(e,{segments:seg(96),color:t,displace:o}),rotation:s}]);return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.05}),juice:[.6,.85,.25]},()=>{const s=e.slice(0,Math.floor(e.length/2)+1),n=_0x5a3f3a(merge([{geometry:lathe(s,{segments:seg(168),color:upperHalf(t),displace:upperDisplace(o),capColor:r,capRings:48}),rotation:CUT_ACROSS}]),{center:!1,shine:.45});return[n,n]})}const mangoShape=([e,t,o])=>[e-.22*t*t+.05*t,t,.8*o];function mango(){const e=normalize(profile(1,e=>.36*Math.sqrt(Math.max(0,1-Math.pow(2*e-1,2)))*(1.08-.2*e),64)),t=({u:e,v:t})=>{const o=Math.max(0,Math.cos(e*TAU))*smoothstep(.85,.15,t)+.4*noise(e,t,5,3)-.15;let s=mix([.42,.6,.16],[.96,.72,.15],.8*smoothstep(.95,.3,t)+.25*noise(e,t,4,3));return s=mix(s,[.98,.5,.12],.8*smoothstep(.1,.5,o)),s=mix(s,[.78,.12,.12],.85*smoothstep(.35,.85,o)),hash(Math.floor(110*e),Math.floor(60*t))>.965&&(s=mix(s,[.98,.9,.55],.5)),s},o=e[0][1],s=mangoShape([0,o,0]),r={geometry:stem(.05,.018,.01),position:[s[0],s[1]-.01,0]},n=merge([{geometry:warp(lathe(e,{segments:seg(72),color:t}),mangoShape)},r]),a=(e,t)=>{const o=Math.hypot(e/.24,t/.34);if(o<1)return mix([.98,.86,.5],[.9,.72,.32],.5*noise(e,t+1,3,40)+.4*o);const s=mix([1,.62,.08],[1,.76,.22],smoothstep(1,2.6,o));return mix(s,[.62,.7,.2],.6*smoothstep(.93,1,e))};return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.5}),juice:[1,.7,.15]},()=>{const o=merge([{geometry:warp(lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:a,cutSteps:32}),mangoShape)},r]),s=_0x5a3f3a(o,{center:!1,shine:.4});return[s,s]})}const peachShape=([e,t,o])=>[e,t,o*(1-.09*Math.exp(-Math.pow(e/.08,2))*smoothstep(0,.3,o)*smoothstep(.48,.15,Math.abs(t+.03)))];function peach(){const e=normalize(resample(Path.fromSVG("M0 0.08 C 0.14 -0.02 0.48 -0.02 0.5 0.42 C 0.52 0.78 0.3 0.96 0.04 0.98 L 0 1.0").toContours()[0].map(([e,t])=>[e,-t]),64)),t=({u:e,v:t})=>{const o=smoothstep(.3,.8,.6*noise(e,t,5,4)+.6*Math.max(0,Math.cos((e-.75)*TAU)));let s=mix([1,.74,.3],[1,.62,.22],noise(e,t,10,6));return s=mix(s,[.92,.3,.2],.85*o),s=mix(s,[.7,.1,.12],o*smoothstep(.6,.9,noise(e,t,48,28))*.45),mix(shade(s,.97+.05*hash(Math.floor(220*e),Math.floor(110*t))),[1,.85,.7],.06)},o=e[0][1],s=[{geometry:stem(.05,.02,.01),position:[0,o-.015,0]},{geometry:leaf(.4,.07,{teeth:18,fold:.3}),position:[.01,o+.02,0],rotation:mul(turn([0,1,0],2.4),turn([0,0,1],.35))}],r=merge([{geometry:warp(lathe(e,{segments:seg(72),color:t}),peachShape)},...s]),n=(e,t)=>{const o=Math.hypot(e/.4,(t+.02)/.34);if(o<1)return mix([.55,.28,.14],[.36,.17,.08],smoothstep(.3,.7,noise(3*e,t+1,7,9)));let s=mix([1,.74,.3],[1,.82,.42],smoothstep(1.2,2.6,o));return s=mix(s,[.88,.3,.16],.85*smoothstep(1.35,1,o)),mix(s,[.85,.3,.18],.7*smoothstep(.94,1,e))};return withPieces({center:boxCenter(r),whole:_0x5a3f3a(r,{center:!1,shine:.12}),juice:[1,.75,.35]},()=>{const o=merge([{geometry:warp(lathe(undimpled(e),{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:n,cutSteps:32,capColor:[.95,.5,.2]}),peachShape)},...s]),r=_0x5a3f3a(o,{center:!1,shine:.25});return[r,r]})}function pineapple(){const e=normalize(resample(rounded(1,.34,2.6,96),110)),t=(e,t)=>{const o=13*e+7*t,s=13*e-7*t;return{fa:fract(o),fb:fract(s),cell:31*Math.floor(o)+Math.floor(s)}},o=({u:e,v:o})=>{const{fa:s,fb:r,cell:n}=t(e,o),a=2*Math.max(Math.abs(s-.5),Math.abs(r-.5)),h=.8*smoothstep(.95,.3,o)+.3*hash(n,3);let i=mix([.42,.42,.12],[.86,.58,.14],h);return i=mix(i,[.64,.42,.14],.8*smoothstep(.45,.15,a)),Math.hypot(s-.62,r-.62)<.1&&(i=[.3,.2,.08]),mix(i,[.2,.18,.06],.85*smoothstep(.75,1,a))},s=(e,o)=>{const{fa:s,fb:r}=t(e,o),n=2*Math.max(Math.abs(s-.5),Math.abs(r-.5));return.018*(Math.sqrt(Math.max(0,1-n*n))-1)*smoothstep(0,.06,o)*smoothstep(1,.94,o)},r=e[0][1],n=e=>1/Math.sqrt(Math.cos(e*TAU)**2+(Math.sin(e*TAU)/.16)**2),a=[];[{n:7,tilt:.45,length:.62},{n:9,tilt:.8,length:.55},{n:11,tilt:1.15,length:.42},{n:9,tilt:1.45,length:.3}].forEach(({n:e,tilt:t,length:o},s)=>{for(let h=0;h<e;h++){const i=(h+.5*s)/e*TAU,m=o*(.85+.3*hash(h,s)),l=[];for(let e=0;e<=5;e++){const o=e/5,s=t+.5*o;l.push([Math.sin(s)*m*o,Math.cos(s)*m*o,0])}a.push({geometry:tube(l,{radius:e=>.045*Math.pow(1-e,.9)+.002,shape:n,sides:seg(10),smoothness:4,color:e=>mix(mix([.24,.42,.22],[.36,.55,.3],e.v),[.6,.55,.3],.7*smoothstep(.8,1,e.v))}),position:[0,r+.01,0],rotation:yTurn(i)})}});const h={geometry:merge(a)},i=merge([{geometry:lathe(e,{segments:seg(130),color:o,displace:s})},h]),m=(e,t)=>{if(e>.95)return[.55,.42,.14];const o=noise(t/TAU,e,90,4);return e>.86?Math.abs(fract(t/TAU*13*2)-.5)<.12&&e>.89?[.55,.35,.12]:[.96,.84,.45]:e<.2?mix([1,.92,.62],[.98,.86,.5],.4*o):shade(mix([1,.78,.18],[1,.84,.3],smoothstep(.8,.3,e)),.9+.15*o)};return withPieces({center:boxCenter(i),whole:_0x5a3f3a(i,{center:!1,shine:.3}),juice:[1,.85,.3]},()=>{const t=Math.floor(e.length/2),r=e.slice(0,t+1),n=e.slice(t),a={segments:seg(130),capColor:m,capRings:30};return[_0x5a3f3a(merge([{geometry:merge([{geometry:lathe(r,{...a,color:e=>o({u:e.u,v:.5*e.v}),displace:(e,t)=>s(e,.5*t)})},h]),rotation:CUT_ACROSS}]),{center:!1,shine:.3}),_0x5a3f3a(merge([{geometry:lathe(n,{...a,color:e=>o({u:e.u,v:.5+.5*e.v}),displace:(e,t)=>s(e,.5+.5*t)}),rotation:turn([1,0,0],Math.PI/2)}]),{center:!1,shine:.3})]})}function pomegranate(){const e=normalize(rounded(.9,.5,2,64)),t=({u:e,v:t})=>{let o=mix([.72,.1,.1],[.5,.04,.07],smoothstep(.3,.8,noise(e,t,6,4)));return o=mix(o,[.88,.5,.32],.55*smoothstep(.6,.85,noise(e+.3,t,5,3))),o=mix(o,[.45,.06,.06],.4*smoothstep(.7,.95,noise(e,t,60,30))),mix(o,[.62,.3,.2],.6*smoothstep(.08,0,t))},o=(e,t)=>-.008*Math.abs(Math.sin(e*TAU*3))*Math.sin(Math.PI*t),s=e[0][1],r=e=>mix([.6,.14,.12],[.42,.22,.12],smoothstep(.6,1,e.v)),n=[{geometry:tube([[0,s-.04,0],[0,s+.06,0]],{radius:e=>.07+.015*e,sides:seg(18),color:r,capColor:[.35,.12,.08]})}];for(let e=0;e<6;e++){const t=e/6*TAU;n.push({geometry:tube([[.07,0,0],[.09,.05,0],[.12,.1,0]],{radius:e=>.025*(1-e)+.002,sides:seg(6),color:r}),position:[0,s+.04,0],rotation:yTurn(t)})}const a=merge([{geometry:lathe(e,{segments:seg(72),color:t,displace:o})},...n]),h=e=>e>.95?[.62,.08,.09]:e>.88?[.98,.82,.68]:[.96,.9,.72];return withPieces({center:boxCenter(a),whole:_0x5a3f3a(a,{center:!1,shine:.45}),juice:[.8,.05,.15]},()=>{const s=e.slice(0,Math.floor(e.length/2)+1),r=s[s.length-1][0],a=lathe(rounded(1.2,.5,2,8),{segments:seg(8),color:[1,1,1]}),i=[],m=.052;for(let e=-1;e<=1;e+=m/r)for(let t=-1;t<=1;t+=m/r){const o=t+.04*(hash(13*t,7*e)-.5),s=e+.04*(hash(11*e,5*t)-.5)+Math.round(t/(m/r))%2*m/r/2,n=Math.hypot(o,s),h=Math.atan2(s,o),l=Math.abs(Math.sin(3*h+.3))*n;if(n>.84||n<.1||l<.05)continue;const u=hash(31*o,17*s);i.push({geometry:a,position:[o*r,-.006,s*r],rotation:mul(yTurn(u*TAU),turn([1,0,0],Math.PI/2+.6*(u-.5))),scale:[.044,.05,.03],color:mix([.85,.06,.14],[.62,.02,.1],u)})}const l=merge([{geometry:merge([{geometry:lathe(s,{segments:seg(72),color:upperHalf(t),displace:upperDisplace(o),capColor:h,capRings:12})},...n,...i]),rotation:CUT_ACROSS}]),u=_0x5a3f3a(l,{center:!1,shine:.55});return[u,u]})}function papaya(){const e=normalize(profile(1,e=>.25*Math.pow(Math.max(0,1-Math.pow(Math.abs(2*e-1),2.2)),1/2.2)*(.7+.42*e),72)),t=(e,t)=>-.006*Math.pow(Math.abs(Math.cos(e*TAU*2.5)),3)*Math.sin(Math.PI*t),o=({u:e,v:t})=>{const o=smoothstep(.35,.8,.7*t+.55*noise(e,t,5,6));let s=mix([.3,.5,.14],[.98,.7,.16],o);return s=mix(s,[.95,.5,.12],o*smoothstep(.55,.85,noise(e,t,8,10))*.5),hash(Math.floor(140*e),Math.floor(90*t))>.97&&(s=mix(s,[.25,.35,.1],.5)),mix(s,[.4,.5,.18],.6*smoothstep(.06,0,t))},s=turn([0,0,1],-Math.PI/2),r=e[0][1],n=merge([{geometry:merge([{geometry:lathe(e,{segments:seg(72),color:o,displace:t})},{geometry:stem(.04,.02,0),position:[0,r-.01,0],color:[1.3,1.6,.9]}]),rotation:s}]),a=e=>Math.max(0,.5*Math.sin(Math.PI*smoothstep(.25,-.42,e))),h=(e,t)=>{const o=a(t);return e>.96?[.5,.6,.15]:e<o?mix([.5,.12,.07],[.95,.42,.22],smoothstep(.75,1,e/o)):mix([1,.5,.26],[1,.62,.34],smoothstep(o,.9,e))};return withPieces({center:boxCenter(n),whole:_0x5a3f3a(n,{center:!1,shine:.4}),juice:[1,.55,.3]},()=>{const r=[];for(let t=0;t<90;t++){const o=.2-.58*hash(t,1),s=a(o)*radiusAt(e,o)*.85;if(s<.025)continue;const n=(2*hash(t,2)-1)*s;r.push({geometry:lathe(rounded(1,.5,2,8),{segments:seg(10)}),position:[n,o,.004+.01*hash(t,3)],scale:.042,color:[.06,.05,.04]})}const n=merge([{geometry:merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(o),displace:(e,o)=>t(.5*e,o),cutColor:h,cutSteps:24})},...r]),rotation:s}]),i=_0x5a3f3a(n,{center:!1,shine:.45});return[i,i]})}const sliced=new WeakSet;function withPieces(e,t){let o;const s=detail;return Object.defineProperty(e,"pieces",{get:()=>(!o&&(o=(()=>{detail=s;try{return t()}finally{detail=1}})(),t=void 0,sliced.add(e)),o),enumerable:!0})}const BUILDERS={apple:apple,orange:orange,lemon:lemon,pear:pear,strawberry:strawberry,watermelon:watermelon,banana:banana,cherries:cherries,grapes:grapes,kiwi:kiwi,mango:mango,peach:peach,pineapple:pineapple,pomegranate:pomegranate,papaya:papaya},built=new Map;export function getFruit(e,t=1){const o=e+"@"+t;let s=built.get(o);if(!s){let r;const n=()=>{detail=t;try{return BUILDERS[e]()}finally{detail=1}},a=cacheGameAsset("fruit:"+o+":whole",()=>(r=n(),{whole:r.whole,center:r.center,juice:r.juice}));let h;s=Object.defineProperty({...a},"pieces",{enumerable:!0,get:()=>(!h&&(h=cacheGameAsset("fruit:"+o+":pieces",()=>(r??=n()).pieces),r=void 0,sliced.add(s)),h)}),built.set(o,s)}return s}export const isFruitBuilt=(e,t=1,o=!1)=>{const s=built.get(e+"@"+t);return void 0!==s&&(!o||sliced.has(s))};export function loadFruits(e,t,o=1){const s=e.filter(e=>!built.has(e+"@"+o));let r=0,n=!1;const a=()=>{if(n)return;const e=s.shift();e&&getFruit(e,o),s.length?r=requestAnimationFrame(a):t()};return r=requestAnimationFrame(a),()=>{n=!0,cancelAnimationFrame(r)}}let fruits;export function getFruits(){if(!fruits){const e={};for(const t of Object.keys(BUILDERS))Object.defineProperty(e,t,{get:()=>getFruit(t),enumerable:!0});fruits=e}return fruits}export function*warmAssets(e,t,o=!1){for(const s of e)yield()=>getFruit(s,t).whole,o&&(yield()=>getFruit(s,t).pieces)}
1
+ "use strict";import{extrude,lathe,merge,Path,recolor,tube}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x3a93b3}from"./EngineMeshes.js";function boxCenter(e){const t=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let s=0;s<e.vertices.length;s+=11)for(let r=0;r<3;r++)t[r]=Math.min(t[r],e.vertices[s+r]),o[r]=Math.max(o[r],e.vertices[s+r]);return[(t[0]+o[0])/2,(t[1]+o[1])/2,(t[2]+o[2])/2]}const TAU=2*Math.PI,fract=e=>e-Math.floor(e),hash=(e,t)=>fract(43758.5453*Math.sin(127.1*e+311.7*t)),smooth=e=>e*e*(3-2*e),clamp01=e=>Math.max(0,Math.min(1,e)),smoothstep=(e,t,o)=>smooth(clamp01((o-e)/(t-e)));function noise(e,t,o,s){const r=e*o,n=t*s,a=Math.floor(r),h=Math.floor(n),i=smooth(r-a),m=smooth(n-h),l=(e,t)=>hash((e%o+o)%o,t),u=l(a,h)+(l(a+1,h)-l(a,h))*i;return u+(l(a,h+1)+(l(a+1,h+1)-l(a,h+1))*i-u)*m}const mix=(e,t,o)=>[e[0]+(t[0]-e[0])*o,e[1]+(t[1]-e[1])*o,e[2]+(t[2]-e[2])*o],shade=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],turn=(e,t)=>[e[0]*Math.sin(t/2),e[1]*Math.sin(t/2),e[2]*Math.sin(t/2),Math.cos(t/2)];function mul(e,t){const[o,s,r,n]=e,[a,h,i,m]=t;return[n*a+o*m+s*i-r*h,n*h-o*i+s*m+r*a,n*i+o*h-s*a+r*m,n*m-o*a-s*h-r*i]}function upTo(e){const t=[e[2],0,-e[0]],o=Math.hypot(t[0],t[2]);return o<1e-6?e[1]>0?[0,0,0,1]:[1,0,0,0]:turn([t[0]/o,0,t[2]/o],Math.acos(Math.max(-1,Math.min(1,e[1]))))}const yTurn=e=>turn([0,1,0],e);function warp(e,t){const o=e.vertices,s=1e-4,r=(e,t)=>[(e[0]-t[0])/s,(e[1]-t[1])/s,(e[2]-t[2])/s],n=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]];for(let e=0;e<o.length;e+=11){const[a,h,i]=[o[e],o[e+1],o[e+2]],m=t([a,h,i]),[l,u,p]=[r(t([a+s,h,i]),m),r(t([a,h+s,i]),m),r(t([a,h,i+s]),m)],[g,M,f]=[n(u,p),n(p,l),n(l,u)],[x,y,d]=[o[e+3],o[e+4],o[e+5]],b=[0,1,2].map(e=>x*g[e]+y*M[e]+d*f[e]),w=Math.hypot(b[0],b[1],b[2]);o.set(m,e),w>1e-12&&o.set([b[0]/w,b[1]/w,b[2]/w],e+3)}return e}let detail=1;const seg=e=>e<=8?e:Math.max(8,Math.round(e*detail));function profile(e,t,o=48){o=seg(o);const s=[];for(let r=0;r<=o;r++){const n=r/o;s.push([Math.max(0,t(n)),e/2-n*e])}return s}function resample(e,t){t=seg(t);const o=[0];for(let t=1;t<e.length;t++)o.push(o[t-1]+Math.hypot(e[t][0]-e[t-1][0],e[t][1]-e[t-1][1]));const s=o[o.length-1],r=[];let n=0;for(let a=0;a<=t;a++){const h=a/t*s;for(;n<e.length-2&&o[n+1]<h;)n++;const i=(h-o[n])/(o[n+1]-o[n]||1);r.push([e[n][0]+(e[n+1][0]-e[n][0])*i,e[n][1]+(e[n+1][1]-e[n][1])*i])}return r}const rounded=(e,t,o=2,s=64)=>profile(e,e=>t*Math.pow(Math.max(0,1-Math.pow(Math.abs(2*e-1),o)),1/o),s);function radiusAt(e,t){let o=0;for(let s=0;s<e.length-1;s++){const[r,n]=e[s],[a,h]=e[s+1];(t-n)*(t-h)<=0&&n!==h&&(o=Math.max(o,r+(t-n)/(h-n)*(a-r)))}return o}function undimpled(e){let[t,o]=[0,0];return e.forEach((s,r)=>{s[1]>e[t][1]&&(t=r),s[1]<e[o][1]&&(o=r)}),e.slice(t,o+1)}function normalize(e){const t=Math.max(...e.map(e=>e[1])),o=Math.min(...e.map(e=>e[1])),s=2*Math.max(...e.map(e=>e[0])),r=1/Math.max(s,t-o),n=(t+o)/2;return e.map(([e,t])=>[e*r,(t-n)*r])}function onSurface(e,t,o){const s=t*(e.length-1),r=Math.min(e.length-2,Math.floor(s)),n=s-r,[a,h]=e[r],[i,m]=e[r+1],l=a+(i-a)*n,u=h+(m-h)*n,p=Math.hypot(i-a,m-h)||1,[g,M]=[(h-m)/p,(i-a)/p],[f,x]=[Math.cos(o),-Math.sin(o)];return[[l*f,u,l*x],[g*f,M,g*x]]}const LEAF_TOP=[.24,.56,.17],LEAF_UNDER=[.19,.46,.14],VEIN=[.55,.74,.36];function leaf(e,t,{fold:o=.38,teeth:s=14,stalk:r=.16}={}){const n=o=>{const r=[[0,0]],n=2*s;for(let s=1;s<n;s++){const a=s/n,h=s%2?.07:0,i=t*Math.pow(Math.sin(Math.PI*a),.75)*(1-.25*a)*(1+h);r.push([e*a,o*i])}return r.push([e,0]),extrude((new Path).addPolygon(r.map(([e,t])=>[e,-t])),{depth:.006})};return merge([{geometry:n(1),rotation:turn([1,0,0],o),color:LEAF_TOP},{geometry:n(-1),rotation:turn([1,0,0],-o),color:LEAF_UNDER},{geometry:tube([[0,0,0],[.5*e,.004,0],[.96*e,0,0]],{radius:e=>.007*(1-e)+.002,sides:seg(6)}),color:VEIN},{geometry:tube([[-e*r,-.01,0],[0,0,0]],{radius:.008,sides:seg(6)}),color:[.36,.42,.18]}])}function stem(e,t=.024,o=.06){return tube([[0,-.03,0],[.005,.4*e,0],[.5*o,.8*e,0],[o,e,0]],{radius:e=>t*(1.25-.45*e+(e>.9?.5*(e-.9)*10:0)),sides:seg(8),color:e=>mix([.33,.21,.1],[.5,.42,.28],smoothstep(.75,1,e.v)+.15*noise(e.u,e.v,6,10)),capColor:[.62,.55,.4]})}const seed=(e=8)=>lathe([[0,.5],[.22,.32],[.4,.02],[.36,-.28],[.2,-.45],[0,-.5]],{segments:e}),calyx=(e,t,o,s=.012)=>extrude((new Path).addStar(0,0,e,t,o),{depth:s}),FACE_UP=turn([1,0,0],-Math.PI/2),CUT_ACROSS=turn([1,0,0],-Math.PI/2),SKIN_SEGMENTS=72,halfTurn=e=>t=>e({u:.5*t.u,v:t.v}),upperHalf=e=>t=>e({u:t.u,v:.5*t.v}),upperDisplace=e=>(t,o)=>e(t,.5*o);function apple(){const e=normalize(resample(Path.fromSVG("M0 0.1 C 0.12 -0.03 0.42 -0.06 0.5 0.3 C 0.55 0.62 0.36 0.9 0.14 0.93 Q 0.05 0.94 0 0.88").toContours()[0].map(([e,t])=>[e,-t]),64)),t=[.68,.04,.06],o=[.45,.02,.05],s=[.86,.66,.18],r=({u:e,v:r})=>{const n=noise(e,r,90,4);let a=mix(t,o,.7*smoothstep(.35,.9,n));return a=mix(a,s,.35*smoothstep(.55,.8,noise(e,r,7,3))),a=mix(a,[.72,.68,.22],.75*smoothstep(.16,.02,r)+.6*smoothstep(.86,.99,r)),hash(Math.floor(140*e),Math.floor(70*r))>.975&&(a=mix(a,[.95,.85,.55],.55)),a},n=e[0][1],a=e[e.length-1][1],h=lathe(e,{segments:seg(72),color:r}),i=merge([{geometry:h},{geometry:stem(.17,.022,.05),position:[0,n,0]},{geometry:leaf(.32,.075),position:[.03,n+.11,0],rotation:mul(turn([0,1,0],-.5),turn([0,0,1],.55))},{geometry:calyx(.05,.015,5),position:[0,a-.004,0],rotation:turn([1,0,0],Math.PI/2),color:[.3,.2,.1]}]),m=(e,t)=>{const o=Math.hypot(e/.2,t/.24);let s=[.97,.93,.74];return s=mix(s,[.92,.88,.62],smoothstep(1.05,.85,o)),s=mix(s,[.82,.76,.5],.6*smoothstep(.12,0,Math.abs(o-1))),mix(s,[1,.97,.88],.6*smoothstep(.88,1,e))};return withPieces({center:boxCenter(i),whole:_0x3a93b3(i,{center:!1,shine:.65}),juice:[.98,.94,.75]},()=>{const t=merge([{geometry:lathe(undimpled(e),{segments:seg(72),sweep:Math.PI,color:halfTurn(r),cutColor:m,cutSteps:24,capColor:[.7,.62,.25]})},...[-1,1].map(e=>({geometry:seed(),position:[.06*e,-.02,.004],scale:[.045,.075,.02],rotation:turn([0,0,1],.35*e),color:[.3,.17,.08]}))]),o=_0x3a93b3(t,{center:!1,shine:.3});return[o,o]})}function citrusFace(e,t,o,s,r){return(n,a)=>{if(n>1-.45*r)return e;if(n>1-r)return t;if(n<.12)return mix(t,o,smoothstep(.08,.12,n));const h=TAU/s,i=Math.abs(fract(a/h)-.5)*h*n,m=smoothstep(.5*h*n-.02,.5*h*n-.006,i),l=noise(a/TAU,n,6*s,9);return mix(shade(o,.92+.16*l),t,.85*m)}}const peel=(e,t)=>(o,s)=>-e*Math.pow(noise(o,s,t,.55*t),2)-.5*e*noise(o,s,2.5*t,1.4*t);function orange(){const e=normalize(rounded(.94,.5,2,64)),t=[1,.47,.03],o=({u:e,v:o})=>{let s=shade(t,.9+.14*noise(e,o,40,22));return s=mix(s,[.82,.55,.12],.6*smoothstep(.05,0,o)),mix(s,[.75,.35,.05],.7*smoothstep(.95,1,o))},s=peel(.006,64),r=e[0][1],n=merge([{geometry:lathe(e,{segments:seg(120),color:o,displace:s})},{geometry:calyx(.06,.025,5,.01),position:[0,r-.002,0],rotation:FACE_UP,color:[.3,.42,.14]},{geometry:tube([[0,r-.01,0],[0,r+.035,0]],{radius:.014,sides:seg(6)}),color:[.42,.4,.2]}]);return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.35}),juice:[1,.6,.1]},()=>{const r=e.slice(0,Math.floor(e.length/2)+1),n=citrusFace(shade(t,.95),[.99,.95,.84],[1,.58,.08],10,.12),a=_0x3a93b3(merge([{geometry:lathe(r,{segments:seg(120),color:upperHalf(o),displace:upperDisplace(s),capColor:n,capRings:24}),rotation:CUT_ACROSS}]),{center:!1,shine:.25});return[a,a]})}function lemon(){const e=normalize(profile(1,e=>.34*Math.pow(Math.sin(Math.PI*e),.75),64)),t=[1,.86,.12],o=({u:e,v:o})=>{const s=shade(t,.9+.14*noise(e,o,36,20));return mix(s,[.62,.72,.15],.6*(smoothstep(.06,0,o)+smoothstep(.94,1,o)))},s=peel(.005,56),r=turn([0,0,1],Math.PI/2),n=merge([{geometry:lathe(e,{segments:seg(96),color:o,displace:s}),rotation:r}]);return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.4}),juice:[1,.95,.55]},()=>{const r=e.slice(0,Math.floor(e.length/2)+1),n=citrusFace(t,[.99,.97,.86],[1,.93,.5],9,.1),a=_0x3a93b3(merge([{geometry:lathe(r,{segments:seg(96),color:upperHalf(o),displace:upperDisplace(s),capColor:n,capRings:20}),rotation:CUT_ACROSS}]),{center:!1,shine:.3});return[a,a]})}function pear(){const e=normalize(profile(1,e=>Math.pow(Math.sin(Math.PI*e),.55)*(.18+.37*Math.pow(e,1.35))*(1-.15*Math.exp(30*-e)),64)),t=({u:e,v:t})=>{let o=mix([.62,.74,.2],[.84,.8,.28],noise(e,t,6,4));const s=Math.pow(Math.max(0,Math.cos((e-.2)*TAU)),2)*smoothstep(.3,.8,t);return o=mix(o,[.78,.28,.12],.55*s),o=mix(o,[.55,.42,.18],.6*smoothstep(.12,0,t)),hash(Math.floor(120*e),Math.floor(64*t))>.95&&(o=mix(o,[.5,.38,.18],.65)),o},o=e[0][1],s=e[e.length-1][1],r=merge([{geometry:lathe(e,{segments:seg(72),color:t})},{geometry:stem(.2,.02,.07),position:[0,o,0]},{geometry:calyx(.035,.012,5),position:[0,s-.003,0],rotation:turn([1,0,0],Math.PI/2),color:[.32,.22,.12]}]),n=(e,t)=>{const o=Math.hypot(e/.17,(t+.15)/.17);let s=[.98,.96,.82];return s=mix(s,[.92,.9,.7],smoothstep(1.1,.8,o)),mix(s,[.86,.82,.58],.6*smoothstep(.1,0,Math.abs(o-1)))};return withPieces({center:boxCenter(r),whole:_0x3a93b3(r,{center:!1,shine:.45}),juice:[.98,.96,.8]},()=>{const o=merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:n})},...[-1,1].map(e=>({geometry:seed(),position:[.05*e,-.16,.004],scale:[.035,.06,.018],rotation:turn([0,0,1],.3*e),color:[.25,.14,.07]}))]),s=_0x3a93b3(o,{center:!1,shine:.25});return[s,s]})}function strawberry(){const e=normalize(profile(1,e=>.5*Math.pow(Math.sin(Math.PI*Math.min(1,1.02*e)),.45)*(1-.62*Math.pow(e,1.2)),64)),t=({v:e})=>{let t=[.82,.05,.1];return t=mix(t,[.95,.8,.62],.7*smoothstep(.1,.02,e)),mix(t,[.95,.25,.12],.5*smoothstep(.8,1,e))},o=t=>{const o=[];for(let s=0;s<80;s++){const r=.14+.8*s/80,n=fract(.381966*s)*TAU;if(n>t)continue;const[a,h]=onSurface(e,r,n);o.push({geometry:seed(6),position:[a[0]-.003*h[0],a[1]-.003*h[1],a[2]-.003*h[2]],rotation:upTo(h),scale:[.022,.018,.03],color:[.95,.8,.3]})}return o},s=e[0][1],r=[];for(let e=0;e<8;e++){const t=e/8*TAU+.2;r.push({geometry:leaf(.26+.05*Math.sin(2.3*e),.05,{fold:.2,teeth:4,stalk:0}),position:[0,s+.012,0],rotation:mul(turn([0,1,0],t),turn([0,0,1],.08-.1*Math.cos(1.7*e)))})}const n=[...r,{geometry:stem(.12,.018,.02),position:[0,s-.02,0],color:[.55,1.2,.5]}],a=merge([{geometry:lathe(e,{segments:seg(72),color:t})},...o(TAU),...n]),h=(e,t)=>{const o=mix([1,.85,.82],[.88,.12,.16],smoothstep(.35,.85,e));return mix(o,[.98,.75,.72],.4*smoothstep(.12,0,Math.abs(e-.32))*smoothstep(-.4,.2,t))};return withPieces({center:boxCenter(a),whole:_0x3a93b3(a,{center:!1,shine:.55}),juice:[.95,.15,.2]},()=>{const s=_0x3a93b3(merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:h})},...o(Math.PI)]),{center:!1,shine:.4});return[s,s]})}function watermelon(){const e=normalize(rounded(1,.36,2.2,64)),t=[.07,.27,.08],o=[.42,.62,.26],s=({u:e,v:s})=>{const r=.9*(noise(e,s,16,10)-.5),n=Math.sin((16*e+r)*TAU);let a=mix(o,t,smoothstep(-.35,.1,n));a=shade(a,.9+.15*noise(e,s,50,30));const h=smoothstep(.16,.05,Math.hypot(2.2*(fract(e-.75+.5)-.5),s-.5));return mix(a,[.82,.76,.38],.85*h)},r=turn([0,0,1],Math.PI/2),n=merge([{geometry:lathe(e,{segments:seg(96),color:s}),rotation:r}]),a=e=>e>.965?t:e>.92?mix([.62,.8,.45],[.85,.93,.7],(.965-e)/.045):e>.86?mix([.97,.97,.85],[.98,.55,.5],smoothstep(.92,.86,e)):mix([.98,.3,.32],[.88,.1,.16],smoothstep(.85,.2,e));return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.35}),juice:[.95,.2,.25]},()=>{const t=e.slice(0,Math.floor(e.length/2)+1),o=t[t.length-1][0],r=[];for(let e=0;e<14;e++){const t=e/14*TAU+e%2*.12,s=o*(.5+e%3*.1);r.push({geometry:seed(),position:[Math.cos(t)*s,-.004,-Math.sin(t)*s],rotation:mul(turn([0,1,0],t+Math.PI/2),turn([1,0,0],Math.PI/2)),scale:[.03,.05,.012],color:[.08,.05,.04]})}const n=merge([{geometry:merge([{geometry:lathe(t,{segments:seg(96),color:upperHalf(s),capColor:a,capRings:24})},...r]),rotation:CUT_ACROSS}]),h=_0x3a93b3(n,{center:!1,shine:.25});return[h,h]})}function banana(){const e=[];for(let t=0;t<=12;t++){const o=Math.PI*(.12+.76*t/12);e.push([.5*-Math.cos(o),.3*-Math.sin(o),0])}const t=e.map(e=>e[0]),o=e.map(e=>e[1]),[s,r]=[(Math.min(...t)+Math.max(...t))/2,(Math.min(...o)+Math.max(...o))/2],n=.92/(Math.max(...t)-Math.min(...t)),a=e.map(([e,t])=>[(e-s)*n,(t-r)*n+.06,0]),h=e=>1+.06*Math.cos(e*TAU*5),i=a[a.length-1],m=a[a.length-2],l=[i[0]-m[0],i[1]-m[1]],u=Math.hypot(l[0],l[1]),p=[i[0]+l[0]/u*.1,i[1]+l[1]/u*.1+.015,0],g=tube([i,p],{radius:e=>.026-.006*e,shape:e=>1+.12*Math.cos(e*TAU*4),sides:seg(12),color:[.45,.48,.2],capColor:[.3,.25,.12]}),M=(e,t,o)=>tube(e,{radius:e=>{return s=t+(o-t)*e,.014+.09*Math.pow(Math.sin(Math.PI*Math.min(1,.03+.97*s)),.55);var s},shape:h,sides:seg(30),smoothness:6,color:e=>(({u:e,v:t})=>{let o=[1,.84,.16];o=mix(o,[.82,.76,.18],.4*(.5+.5*Math.cos(e*TAU*5))),o=mix(o,[.62,.72,.2],.6*smoothstep(.82,1,t)),o=mix(o,[.18,.12,.06],smoothstep(.05,0,t));const s=noise(e,t,18,26);return s>.78&&(o=mix(o,[.45,.28,.08],.9*smoothstep(.78,.88,s))),o})({u:e.u,v:t+(o-t)*e.v}),capColor:e=>{return(t=e)>.9?[1,.84,.16]:t<.22?[.86,.8,.58]:[.99,.95,.78];var t}}),f=merge([{geometry:M(a,0,1)},{geometry:g}]);return withPieces({center:boxCenter(f),whole:_0x3a93b3(f,{center:!1,shine:.3}),juice:[1,.95,.72]},()=>{const e=Math.floor(a.length/2),t=M(a.slice(0,e+1),0,e/(a.length-1)),o=merge([{geometry:M(a.slice(e),e/(a.length-1),1)},{geometry:g}]);return[_0x3a93b3(merge([{geometry:t,rotation:turn([0,1,0],-Math.PI/2)}]),{center:!1,shine:.3}),_0x3a93b3(merge([{geometry:o,rotation:turn([0,1,0],Math.PI/2)}]),{center:!1,shine:.3})]})}function cherries(){const e=normalize(resample(Path.fromSVG("M0 0.12 C 0.1 0.01 0.46 -0.04 0.5 0.42 C 0.53 0.76 0.3 0.98 0 0.96").toContours()[0].map(([e,t])=>[e,-t]),40)),t=({u:e,v:t})=>{let o=mix([.55,.02,.07],[.26,0,.04],.6*smoothstep(.3,.75,noise(e,t,5,3))+.35*smoothstep(.5,1,t));return o=mix(o,[.78,.12,.12],.4*smoothstep(.2,.05,t)),mix(o,[.2,.02,.03],.7*smoothstep(.92,1,t))},o=e[0][1],s=.42,r=[[-.2,-.2,.02],[.19,-.28,-.04]],n=[.06,.55,0],a=(e,t)=>tube([[e[0],e[1]+o*s-.02,e[2]],[e[0]+.4*t,e[1]+.38,.5*e[2]],[n[0]+.15*t,n[1]-.12,0],n],{radius:e=>.012+.003*e,sides:seg(7),color:e=>mix([.4,.55,.16],[.42,.32,.14],smoothstep(.75,1,e.v)),capColor:[.35,.25,.12]}),h=[{geometry:a(r[0],-.1)},{geometry:a(r[1],.08)},{geometry:leaf(.3,.07),position:n,rotation:mul(turn([0,1,0],.6),turn([0,0,1],.4))}],i=lathe(e,{segments:seg(40),color:t}),m=merge([...r.map(e=>({geometry:i,position:e,scale:s})),...h]),l=(e,t)=>{const o=Math.hypot(e/.42,(t+.02)/.32);return o<1?mix([.93,.84,.66],[.8,.66,.5],o*o):mix([.62,.04,.1],[.42,.01,.06],smoothstep(1,2.2,o))};return withPieces({center:boxCenter(m),whole:_0x3a93b3(m,{center:!1,shine:.85}),juice:[.6,.03,.1]},()=>{const o=lathe(undimpled(e),{segments:seg(40),sweep:Math.PI,color:halfTurn(t),cutColor:l,cutSteps:20,capColor:[.5,.04,.08]});return[_0x3a93b3(merge([{geometry:o,position:[0,r[0][1],0],scale:s}]),{center:!1,shine:.7}),_0x3a93b3(merge([{geometry:o,position:[0,r[1][1],0],scale:s},{geometry:merge(h),position:[-r[1][0],0,0],rotation:yTurn(Math.PI/2)}]),{center:!1,shine:.7})]})}function grapes(){const e=normalize(rounded(1.12,.5,2,16)),t=({u:e,v:t})=>{let o=mix([.3,.07,.27],[.17,.03,.17],smoothstep(.2,.9,noise(e,t,4,3)));return o=mix(o,[.52,.46,.62],.3*smoothstep(.35,.8,noise(e,t,9,6))),mix(o,[.36,.14,.25],.3*smoothstep(.6,.1,t))},o=lathe(e,{segments:seg(24),color:t}),s=lathe(e,{segments:seg(24),sweep:Math.PI,color:halfTurn(t),cutColor:e=>e>.93?[.3,.08,.25]:mix([.86,.9,.62],[.58,.68,.32],e*e),cutSteps:6}),r=[];for(let e=0;e<8;e++){const t=e/7,o=.32-.78*t,s=.26*Math.pow(1-t,.85)*(1-.35*Math.pow(1-t,6));for(const[t,n]of[[s,0],[.45*s,.5]]){const s=t<.03?n?0:1:Math.max(1,Math.floor(TAU*t/(1.85*.085)));for(let a=0;a<s;a++){const h=(a+n+.37*e)/s*TAU,i=hash(e,a+10*n);r.push({at:[Math.cos(h)*t,o+.04*(i-.5),Math.sin(h)*t],tint:shade([1,.95+.1*i,1],.85+.3*hash(a,e+3)),turn:2*i})}}}const n=[.17,.17,.17],a=e=>({geometry:o,position:e.at,scale:n,color:e.tint,rotation:mul(turn([0,0,1],.5*(e.turn-1)),yTurn(3*e.turn))}),h=e=>mix([.42,.35,.16],[.32,.22,.1],noise(e.u,e.v,4,6)),i=tube([[.02,.62,0],[0,.48,0],[.01,.3,0],[0,.1,0]],{radius:e=>.022-.008*e,sides:seg(8),color:h,capColor:[.55,.48,.3]}),m=[0,1,2,3].map(e=>{const t=e/4*TAU+.4;return{geometry:tube([[0,.42-.04*e,0],[.12*Math.cos(t),.36-.05*e,.12*Math.sin(t)],[.2*Math.cos(t),.3-.06*e,.2*Math.sin(t)]],{radius:.009,sides:seg(6),color:h})}}),l=[];for(let e=0;e<160;e++){const t=e/160*TAU,o=.22*(.6+.4*Math.pow(Math.abs(Math.cos(2.5*(t-Math.PI/2))),.7))*(1-.55*Math.exp(-Math.pow((t-Math.PI/2)/.22,2)))*(1+(e%4==0?.06:0));l.push([Math.cos(t)*o,Math.sin(t)*o-.05])}const u=recolor(extrude((new Path).addPolygon(l),{depth:.008}),({position:e})=>{const t=Math.atan2(e[1]+.05,e[0]),o=Math.min(...[0,1,2,3,4].map(e=>Math.abs(Math.sin(t-(Math.PI/2+e*TAU/5)))));return mix([.22,.48,.14],[.55,.72,.3],.8*smoothstep(.08,0,o*Math.hypot(e[0],e[1]+.05)*6))}),p=[];for(let e=0;e<=24;e++)p.push([-.04-.008*e,.56+.05*Math.sin(.8*e),.05*Math.cos(.8*e)]);const g=[{geometry:i},...m,{geometry:u,position:[.17,.56,-.06],rotation:mul(turn([0,1,0],-.4),turn([1,0,0],-.9))},{geometry:tube(p,{radius:.005,sides:seg(5),color:[.45,.6,.2]})}],M=merge([...r.map(a),...g]),f=e=>{const t=[];for(const o of r)Math.abs(o.at[0])<.0595?t.push({geometry:s,position:[0,o.at[1],o.at[2]],scale:n,color:o.tint,rotation:yTurn(e*Math.PI/2)}):Math.sign(o.at[0])===-e&&t.push(a(o));return 1===e?[...t,...g]:t};return withPieces({center:boxCenter(M),whole:_0x3a93b3(M,{center:!1,shine:.4}),juice:[.75,.85,.45]},()=>[_0x3a93b3(merge([{geometry:merge(f(1)),rotation:yTurn(-Math.PI/2)}]),{center:!1,shine:.4}),_0x3a93b3(merge([{geometry:merge(f(-1)),rotation:yTurn(Math.PI/2)}]),{center:!1,shine:.4})])}function kiwi(){const e=normalize(rounded(1,.4,2.4,72)),t=({u:e,v:t})=>{let o=mix([.5,.35,.18],[.36,.24,.11],noise(e,t,12,8));return o=shade(o,.85+.3*hash(Math.floor(200*e),Math.floor(90*t))),mix(o,[.3,.2,.1],.6*(smoothstep(.05,0,t)+smoothstep(.95,1,t)))},o=(e,t)=>-.004*noise(e,t,60,30),s=turn([0,0,1],Math.PI/2),r=(e,t)=>{if(e>.975)return[.42,.3,.14];if(e>.94)return mix([.55,.72,.2],[.4,.58,.12],(e-.94)/.035);const o=noise(t/TAU,e,70,3);if(e<.26)return mix([.97,.96,.78],[.86,.9,.55],.6*smoothstep(.18,.26,e)+.1*o);const s=Math.floor(t/TAU*56),r=hash(s,7),n=Math.abs(fract(t/TAU*56)-.5)/56*TAU*e,a=.34+.06*r;if(Math.hypot(n/.016,(e-a)/.045)<1)return[.06,.05,.03];const h=mix([.62,.86,.22],[.44,.7,.08],smoothstep(.3,.9,e));return mix(h,[.85,.95,.5],.25*o*smoothstep(.95,.4,e))},n=merge([{geometry:lathe(e,{segments:seg(96),color:t,displace:o}),rotation:s}]);return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.05}),juice:[.6,.85,.25]},()=>{const s=e.slice(0,Math.floor(e.length/2)+1),n=_0x3a93b3(merge([{geometry:lathe(s,{segments:seg(168),color:upperHalf(t),displace:upperDisplace(o),capColor:r,capRings:48}),rotation:CUT_ACROSS}]),{center:!1,shine:.45});return[n,n]})}const mangoShape=([e,t,o])=>[e-.22*t*t+.05*t,t,.8*o];function mango(){const e=normalize(profile(1,e=>.36*Math.sqrt(Math.max(0,1-Math.pow(2*e-1,2)))*(1.08-.2*e),64)),t=({u:e,v:t})=>{const o=Math.max(0,Math.cos(e*TAU))*smoothstep(.85,.15,t)+.4*noise(e,t,5,3)-.15;let s=mix([.42,.6,.16],[.96,.72,.15],.8*smoothstep(.95,.3,t)+.25*noise(e,t,4,3));return s=mix(s,[.98,.5,.12],.8*smoothstep(.1,.5,o)),s=mix(s,[.78,.12,.12],.85*smoothstep(.35,.85,o)),hash(Math.floor(110*e),Math.floor(60*t))>.965&&(s=mix(s,[.98,.9,.55],.5)),s},o=e[0][1],s=mangoShape([0,o,0]),r={geometry:stem(.05,.018,.01),position:[s[0],s[1]-.01,0]},n=merge([{geometry:warp(lathe(e,{segments:seg(72),color:t}),mangoShape)},r]),a=(e,t)=>{const o=Math.hypot(e/.24,t/.34);if(o<1)return mix([.98,.86,.5],[.9,.72,.32],.5*noise(e,t+1,3,40)+.4*o);const s=mix([1,.62,.08],[1,.76,.22],smoothstep(1,2.6,o));return mix(s,[.62,.7,.2],.6*smoothstep(.93,1,e))};return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.5}),juice:[1,.7,.15]},()=>{const o=merge([{geometry:warp(lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:a,cutSteps:32}),mangoShape)},r]),s=_0x3a93b3(o,{center:!1,shine:.4});return[s,s]})}const peachShape=([e,t,o])=>[e,t,o*(1-.09*Math.exp(-Math.pow(e/.08,2))*smoothstep(0,.3,o)*smoothstep(.48,.15,Math.abs(t+.03)))];function peach(){const e=normalize(resample(Path.fromSVG("M0 0.08 C 0.14 -0.02 0.48 -0.02 0.5 0.42 C 0.52 0.78 0.3 0.96 0.04 0.98 L 0 1.0").toContours()[0].map(([e,t])=>[e,-t]),64)),t=({u:e,v:t})=>{const o=smoothstep(.3,.8,.6*noise(e,t,5,4)+.6*Math.max(0,Math.cos((e-.75)*TAU)));let s=mix([1,.74,.3],[1,.62,.22],noise(e,t,10,6));return s=mix(s,[.92,.3,.2],.85*o),s=mix(s,[.7,.1,.12],o*smoothstep(.6,.9,noise(e,t,48,28))*.45),mix(shade(s,.97+.05*hash(Math.floor(220*e),Math.floor(110*t))),[1,.85,.7],.06)},o=e[0][1],s=[{geometry:stem(.05,.02,.01),position:[0,o-.015,0]},{geometry:leaf(.4,.07,{teeth:18,fold:.3}),position:[.01,o+.02,0],rotation:mul(turn([0,1,0],2.4),turn([0,0,1],.35))}],r=merge([{geometry:warp(lathe(e,{segments:seg(72),color:t}),peachShape)},...s]),n=(e,t)=>{const o=Math.hypot(e/.4,(t+.02)/.34);if(o<1)return mix([.55,.28,.14],[.36,.17,.08],smoothstep(.3,.7,noise(3*e,t+1,7,9)));let s=mix([1,.74,.3],[1,.82,.42],smoothstep(1.2,2.6,o));return s=mix(s,[.88,.3,.16],.85*smoothstep(1.35,1,o)),mix(s,[.85,.3,.18],.7*smoothstep(.94,1,e))};return withPieces({center:boxCenter(r),whole:_0x3a93b3(r,{center:!1,shine:.12}),juice:[1,.75,.35]},()=>{const o=merge([{geometry:warp(lathe(undimpled(e),{segments:seg(72),sweep:Math.PI,color:halfTurn(t),cutColor:n,cutSteps:32,capColor:[.95,.5,.2]}),peachShape)},...s]),r=_0x3a93b3(o,{center:!1,shine:.25});return[r,r]})}function pineapple(){const e=normalize(resample(rounded(1,.34,2.6,96),110)),t=(e,t)=>{const o=13*e+7*t,s=13*e-7*t;return{fa:fract(o),fb:fract(s),cell:31*Math.floor(o)+Math.floor(s)}},o=({u:e,v:o})=>{const{fa:s,fb:r,cell:n}=t(e,o),a=2*Math.max(Math.abs(s-.5),Math.abs(r-.5)),h=.8*smoothstep(.95,.3,o)+.3*hash(n,3);let i=mix([.42,.42,.12],[.86,.58,.14],h);return i=mix(i,[.64,.42,.14],.8*smoothstep(.45,.15,a)),Math.hypot(s-.62,r-.62)<.1&&(i=[.3,.2,.08]),mix(i,[.2,.18,.06],.85*smoothstep(.75,1,a))},s=(e,o)=>{const{fa:s,fb:r}=t(e,o),n=2*Math.max(Math.abs(s-.5),Math.abs(r-.5));return.018*(Math.sqrt(Math.max(0,1-n*n))-1)*smoothstep(0,.06,o)*smoothstep(1,.94,o)},r=e[0][1],n=e=>1/Math.sqrt(Math.cos(e*TAU)**2+(Math.sin(e*TAU)/.16)**2),a=[];[{n:7,tilt:.45,length:.62},{n:9,tilt:.8,length:.55},{n:11,tilt:1.15,length:.42},{n:9,tilt:1.45,length:.3}].forEach(({n:e,tilt:t,length:o},s)=>{for(let h=0;h<e;h++){const i=(h+.5*s)/e*TAU,m=o*(.85+.3*hash(h,s)),l=[];for(let e=0;e<=5;e++){const o=e/5,s=t+.5*o;l.push([Math.sin(s)*m*o,Math.cos(s)*m*o,0])}a.push({geometry:tube(l,{radius:e=>.045*Math.pow(1-e,.9)+.002,shape:n,sides:seg(10),smoothness:4,color:e=>mix(mix([.24,.42,.22],[.36,.55,.3],e.v),[.6,.55,.3],.7*smoothstep(.8,1,e.v))}),position:[0,r+.01,0],rotation:yTurn(i)})}});const h={geometry:merge(a)},i=merge([{geometry:lathe(e,{segments:seg(130),color:o,displace:s})},h]),m=(e,t)=>{if(e>.95)return[.55,.42,.14];const o=noise(t/TAU,e,90,4);return e>.86?Math.abs(fract(t/TAU*13*2)-.5)<.12&&e>.89?[.55,.35,.12]:[.96,.84,.45]:e<.2?mix([1,.92,.62],[.98,.86,.5],.4*o):shade(mix([1,.78,.18],[1,.84,.3],smoothstep(.8,.3,e)),.9+.15*o)};return withPieces({center:boxCenter(i),whole:_0x3a93b3(i,{center:!1,shine:.3}),juice:[1,.85,.3]},()=>{const t=Math.floor(e.length/2),r=e.slice(0,t+1),n=e.slice(t),a={segments:seg(130),capColor:m,capRings:30};return[_0x3a93b3(merge([{geometry:merge([{geometry:lathe(r,{...a,color:e=>o({u:e.u,v:.5*e.v}),displace:(e,t)=>s(e,.5*t)})},h]),rotation:CUT_ACROSS}]),{center:!1,shine:.3}),_0x3a93b3(merge([{geometry:lathe(n,{...a,color:e=>o({u:e.u,v:.5+.5*e.v}),displace:(e,t)=>s(e,.5+.5*t)}),rotation:turn([1,0,0],Math.PI/2)}]),{center:!1,shine:.3})]})}function pomegranate(){const e=normalize(rounded(.9,.5,2,64)),t=({u:e,v:t})=>{let o=mix([.72,.1,.1],[.5,.04,.07],smoothstep(.3,.8,noise(e,t,6,4)));return o=mix(o,[.88,.5,.32],.55*smoothstep(.6,.85,noise(e+.3,t,5,3))),o=mix(o,[.45,.06,.06],.4*smoothstep(.7,.95,noise(e,t,60,30))),mix(o,[.62,.3,.2],.6*smoothstep(.08,0,t))},o=(e,t)=>-.008*Math.abs(Math.sin(e*TAU*3))*Math.sin(Math.PI*t),s=e[0][1],r=e=>mix([.6,.14,.12],[.42,.22,.12],smoothstep(.6,1,e.v)),n=[{geometry:tube([[0,s-.04,0],[0,s+.06,0]],{radius:e=>.07+.015*e,sides:seg(18),color:r,capColor:[.35,.12,.08]})}];for(let e=0;e<6;e++){const t=e/6*TAU;n.push({geometry:tube([[.07,0,0],[.09,.05,0],[.12,.1,0]],{radius:e=>.025*(1-e)+.002,sides:seg(6),color:r}),position:[0,s+.04,0],rotation:yTurn(t)})}const a=merge([{geometry:lathe(e,{segments:seg(72),color:t,displace:o})},...n]),h=e=>e>.95?[.62,.08,.09]:e>.88?[.98,.82,.68]:[.96,.9,.72];return withPieces({center:boxCenter(a),whole:_0x3a93b3(a,{center:!1,shine:.45}),juice:[.8,.05,.15]},()=>{const s=e.slice(0,Math.floor(e.length/2)+1),r=s[s.length-1][0],a=lathe(rounded(1.2,.5,2,8),{segments:seg(8),color:[1,1,1]}),i=[],m=.052;for(let e=-1;e<=1;e+=m/r)for(let t=-1;t<=1;t+=m/r){const o=t+.04*(hash(13*t,7*e)-.5),s=e+.04*(hash(11*e,5*t)-.5)+Math.round(t/(m/r))%2*m/r/2,n=Math.hypot(o,s),h=Math.atan2(s,o),l=Math.abs(Math.sin(3*h+.3))*n;if(n>.84||n<.1||l<.05)continue;const u=hash(31*o,17*s);i.push({geometry:a,position:[o*r,-.006,s*r],rotation:mul(yTurn(u*TAU),turn([1,0,0],Math.PI/2+.6*(u-.5))),scale:[.044,.05,.03],color:mix([.85,.06,.14],[.62,.02,.1],u)})}const l=merge([{geometry:merge([{geometry:lathe(s,{segments:seg(72),color:upperHalf(t),displace:upperDisplace(o),capColor:h,capRings:12})},...n,...i]),rotation:CUT_ACROSS}]),u=_0x3a93b3(l,{center:!1,shine:.55});return[u,u]})}function papaya(){const e=normalize(profile(1,e=>.25*Math.pow(Math.max(0,1-Math.pow(Math.abs(2*e-1),2.2)),1/2.2)*(.7+.42*e),72)),t=(e,t)=>-.006*Math.pow(Math.abs(Math.cos(e*TAU*2.5)),3)*Math.sin(Math.PI*t),o=({u:e,v:t})=>{const o=smoothstep(.35,.8,.7*t+.55*noise(e,t,5,6));let s=mix([.3,.5,.14],[.98,.7,.16],o);return s=mix(s,[.95,.5,.12],o*smoothstep(.55,.85,noise(e,t,8,10))*.5),hash(Math.floor(140*e),Math.floor(90*t))>.97&&(s=mix(s,[.25,.35,.1],.5)),mix(s,[.4,.5,.18],.6*smoothstep(.06,0,t))},s=turn([0,0,1],-Math.PI/2),r=e[0][1],n=merge([{geometry:merge([{geometry:lathe(e,{segments:seg(72),color:o,displace:t})},{geometry:stem(.04,.02,0),position:[0,r-.01,0],color:[1.3,1.6,.9]}]),rotation:s}]),a=e=>Math.max(0,.5*Math.sin(Math.PI*smoothstep(.25,-.42,e))),h=(e,t)=>{const o=a(t);return e>.96?[.5,.6,.15]:e<o?mix([.5,.12,.07],[.95,.42,.22],smoothstep(.75,1,e/o)):mix([1,.5,.26],[1,.62,.34],smoothstep(o,.9,e))};return withPieces({center:boxCenter(n),whole:_0x3a93b3(n,{center:!1,shine:.4}),juice:[1,.55,.3]},()=>{const r=[];for(let t=0;t<90;t++){const o=.2-.58*hash(t,1),s=a(o)*radiusAt(e,o)*.85;if(s<.025)continue;const n=(2*hash(t,2)-1)*s;r.push({geometry:lathe(rounded(1,.5,2,8),{segments:seg(10)}),position:[n,o,.004+.01*hash(t,3)],scale:.042,color:[.06,.05,.04]})}const n=merge([{geometry:merge([{geometry:lathe(e,{segments:seg(72),sweep:Math.PI,color:halfTurn(o),displace:(e,o)=>t(.5*e,o),cutColor:h,cutSteps:24})},...r]),rotation:s}]),i=_0x3a93b3(n,{center:!1,shine:.45});return[i,i]})}const sliced=new WeakSet;function withPieces(e,t){let o;const s=detail;return Object.defineProperty(e,"pieces",{get:()=>(!o&&(o=(()=>{detail=s;try{return t()}finally{detail=1}})(),t=void 0,sliced.add(e)),o),enumerable:!0})}const BUILDERS={apple:apple,orange:orange,lemon:lemon,pear:pear,strawberry:strawberry,watermelon:watermelon,banana:banana,cherries:cherries,grapes:grapes,kiwi:kiwi,mango:mango,peach:peach,pineapple:pineapple,pomegranate:pomegranate,papaya:papaya},built=new Map;export function getFruit(e,t=1){const o=e+"@"+t;let s=built.get(o);if(!s){let r;const n=()=>{detail=t;try{return BUILDERS[e]()}finally{detail=1}},a=cacheGameAsset("fruit:"+o+":whole",()=>(r=n(),{whole:r.whole,center:r.center,juice:r.juice}));let h;s=Object.defineProperty({...a},"pieces",{enumerable:!0,get:()=>(!h&&(h=cacheGameAsset("fruit:"+o+":pieces",()=>(r??=n()).pieces),r=void 0,sliced.add(s)),h)}),built.set(o,s)}return s}export const isFruitBuilt=(e,t=1,o=!1)=>{const s=built.get(e+"@"+t);return void 0!==s&&(!o||sliced.has(s))};export function loadFruits(e,t,o=1){const s=e.filter(e=>!built.has(e+"@"+o));let r=0,n=!1;const a=()=>{if(n)return;const e=s.shift();e&&getFruit(e,o),s.length?r=requestAnimationFrame(a):t()};return r=requestAnimationFrame(a),()=>{n=!0,cancelAnimationFrame(r)}}let fruits;export function getFruits(){if(!fruits){const e={};for(const t of Object.keys(BUILDERS))Object.defineProperty(e,t,{get:()=>getFruit(t),enumerable:!0});fruits=e}return fruits}export function*warmAssets(e,t,o=!1){for(const s of e)yield()=>getFruit(s,t).whole,o&&(yield()=>getFruit(s,t).pieces)}
@@ -1 +1 @@
1
- "use strict";import{createElement,memo,useEffect,useRef,useState}from"react";import{AppState}from"react-native";import{GameThemeProvider}from"../../helpers/GameTheme.js";import{GameAssetLoader}from"../../services/GameAssetLoader.js";import{areGameAssetsReady,gameAssetStages}from"../../services/GameAssets.js";import{DEFAULT_GAME_SETTINGS}from"../../services/UtilsService.js";import{EngineReadyContext}from"./EngineReadyContext.js";import{GameLoading}from"./GameLoading.js";import{GameLoadingTransition}from"./GameLoadingTransition.js";import{jsx as _0x290751,jsxs as _0x501bf1}from"react/jsx-runtime";export function withGameLoading(e,t){let r;const s=memo(function(s){const a={...DEFAULT_GAME_SETTINGS,...s.settings},[n,i]=useState(()=>areGameAssetsReady(e,a.theme)?r:void 0),[o,m]=useState("Getting ready"),[d,u]=useState(!1),l=useRef(null),f=useRef(!1);useEffect(()=>{if(n)return;f.current=!1,u(!1);const s=new GameAssetLoader([...gameAssetStages(e,a.theme),{label:"Ready for playtime",*tasks(){yield()=>{r=t()}}}],m,()=>i(()=>r),e=>{f.current=!0,u(!0)});l.current=s;const o=()=>{"active"!==AppState.currentState||f.current?s.pause():s.start()},d=AppState.addEventListener("change",o);return o(),()=>{s.dispose(),l.current=null,d.remove()}},[n,a.theme]);const g=!n&&a.isVisible?require("../../helpers/GameSettingsModal").GameSettingsModal:null;return _0x501bf1(GameThemeProvider,{theme:a.theme,children:[_0x290751(GameLoadingTransition,{ready:!!n,loader:_0x290751(GameLoading,{gameId:e,theme:a.theme,offset:a.offset,visible:!a.isVisible,label:o,error:d,onRetry:()=>{f.current=!1,u(!1),"active"===AppState.currentState&&l.current?.start()}}),children:n&&_0x290751(EngineReadyContext.Provider,{value:!0,children:createElement(n,s)})}),g&&_0x290751(g,{gameId:e,settings:a,onSettingsChange:s.onSettingsChange})]})});return s.displayName="Loading("+e+")",s}
1
+ "use strict";import{createElement,memo,useEffect,useRef,useState}from"react";import{AppState}from"react-native";import{GameThemeProvider}from"../../helpers/GameTheme.js";import{GameAssetLoader}from"../../services/GameAssetLoader.js";import{areGameAssetsReady,gameAssetStages}from"../../services/GameAssets.js";import{DEFAULT_GAME_SETTINGS}from"../../services/UtilsService.js";import{EngineReadyContext}from"./EngineReadyContext.js";import{GameLoading}from"./GameLoading.js";import{GameLoadingTransition}from"./GameLoadingTransition.js";import{jsx as _0x9c222,jsxs as _0x2f6bc8}from"react/jsx-runtime";export function withGameLoading(e,t){let r;const s=memo(function(s){const a={...DEFAULT_GAME_SETTINGS,...s.settings},[n,i]=useState(()=>areGameAssetsReady(e,a.theme)?r:void 0),[o,m]=useState("Getting ready"),[d,u]=useState(!1),l=useRef(null),f=useRef(!1);useEffect(()=>{if(n)return;f.current=!1,u(!1);const s=new GameAssetLoader([...gameAssetStages(e,a.theme),{label:"Ready for playtime",*tasks(){yield()=>{r=t()}}}],m,()=>i(()=>r),e=>{f.current=!0,u(!0)});l.current=s;const o=()=>{"active"!==AppState.currentState||f.current?s.pause():s.start()},d=AppState.addEventListener("change",o);return o(),()=>{s.dispose(),l.current=null,d.remove()}},[n,a.theme]);const g=!n&&a.isVisible?require("../../helpers/GameSettingsModal").GameSettingsModal:null;return _0x2f6bc8(GameThemeProvider,{theme:a.theme,children:[_0x9c222(GameLoadingTransition,{ready:!!n,loader:_0x9c222(GameLoading,{gameId:e,theme:a.theme,offset:a.offset,visible:!a.isVisible,label:o,error:d,onRetry:()=>{f.current=!1,u(!1),"active"===AppState.currentState&&l.current?.start()}}),children:n&&_0x9c222(EngineReadyContext.Provider,{value:!0,children:createElement(n,s)})}),g&&_0x9c222(g,{gameId:e,settings:a,onSettingsChange:s.onSettingsChange})]})});return s.displayName="Loading("+e+")",s}
@@ -1 +1 @@
1
- "use strict";import{c as _0x5b2eee}from"react/compiler-runtime";import _0x1c4231,{useCallback,useContext,useEffect,useLayoutEffect,useMemo,useRef,useState}from"react";import{AppState,BackHandler,StyleSheet,Text,View}from"react-native";import{audio,GameView,isEngineAvailable,warmUpEngine,World}from"@nayan-ui/engine";import{GameSettingsModal,GameThemeProvider}from"../../helpers/index.js";import{GAMES_METADATA}from"../../services/GamesMetadata.js";import{GAME_SOUNDS,playSound,preloadSounds,stopAllSounds}from"../../services/SoundsService.js";import{resolveGameTheme}from"../../services/ThemeService.js";import{DEFAULT_GAME_SETTINGS}from"../../services/UtilsService.js";import{EngineHud}from"./EngineHud.js";import{EngineReadyContext}from"./EngineReadyContext.js";import{toRgb}from"./EngineUtils.js";import{GamePlayingContext,useGamePlaying}from"./GameActivity.js";import{GameLoading}from"./GameLoading.js";import{GameLoadingTransition}from"./GameLoadingTransition.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x43dc7b,jsxs as _0x468bf5}from"react/jsx-runtime";let soundOwner;const logStats=e=>{};export const EngineGameScreen=({gameId:e,hudCapacity:t,errorMessage:n,feedback:o,choices:s,onAudioChange:a,onActiveChange:r,settings:i=DEFAULT_GAME_SETTINGS,onSettingsChange:l,onShare:u,onShowLeaderboard:d,bannerAd:m,background:g,onUpdate:h,onResize:S,columns:f,playing:p,subtext:E,onStart:b,onStop:v,gameOver:y,children:A,source:G,...x})=>{useGamePlaying(p);const _=resolveGameTheme(i.theme),T=i.offset??0;useEffect(()=>preloadSounds([GAME_SOUNDS.STOP,GAME_SOUNDS.RESET]),[]);const w=useRef({}).current,[C,R]=useState(()=>"background"!==AppState.currentState&&"inactive"!==AppState.currentState);useEffect(()=>{const e=AppState.addEventListener("change",e=>R("active"===e));return()=>e.remove()},[]);const O=C&&!i.isVisible&&!i.paused&&!x.paused&&!n;useEffect(()=>{r?.(O)},[O,r]);const L=O&&i.enableSounds;useEffect(()=>(soundOwner=w,audio.muted=!L,L||stopAllSounds(),a?.(L),()=>{a?.(!1),soundOwner===w&&(stopAllSounds(),audio.muted=!1,soundOwner=void 0)}),[L,a,w]);const P=useGameResource(()=>new EngineHud(_,t),e=>()=>e.dispose()),[j,M]=useState(null),U=useCallback(e=>{const{width:t,height:n}=e.nativeEvent.layout;M(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},[]),D=useRef(S);D.current=S,useEffect(()=>{j&&(D.current?.(j.width,j.height,T),P.layout(j.width,j.height,T))},[P,j,T]),useLayoutEffect(()=>P.setTheme(_),[P,_]),useEffect(()=>P.setChoices(s??[]),[P,s]);const N=useRef(o);N.current=o;const V=useRef(h);V.current=h;const k=useCallback(e=>{if(i.isVisible)return G instanceof World&&G.update(0),void P.update(0);V.current?.(e,P),P.update(e,N.current)},[P,G,i.isVisible]);P.setActions({onStart:()=>{stopAllSounds(),b()},onStop:()=>{stopAllSounds(),v(),playSound(GAME_SOUNDS.STOP,i.enableSounds)},onShare:u,onShowLeaderboard:d});const B=f.map(e=>[e.label,e.value,e.color,e.valueColor,e.lives?.count,e.lives?.max].join("\0")).join("\x01");useEffect(()=>P.setColumns(f),[P,B]),useLayoutEffect(()=>P.setPlaying(p,E),[P,p,E]);const I=useRef(i.enableSounds);I.current=i.enableSounds;const H=useRef(y);H.current=y;const F=y?[y.title,y.message,y.scoreLabel,y.score,y.buttonText,!!y.onShare].join("\0"):null,[K,W]=useState(null);useEffect(()=>{const e=H.current;if(!e)return P.hideGameOver(),void W(null);P.showGameOver({...e,onPlayAgain:()=>{stopAllSounds(),H.current?.onPlayAgain(),playSound(GAME_SOUNDS.RESET,I.current)},onShare:e.onShare?()=>H.current?.onShare?.():void 0}),W(P.gameOverBanner)},[P,F,j,_]);const z=useCallback(e=>{P.setGameOverReserve(e.nativeEvent.layout.height),W(P.gameOverBanner)},[P]),X=null!==y;useEffect(()=>{if(!X)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(H.current?.onPlayAgain(),!0));return()=>e.remove()},[X]);const q=useMemo(()=>toRgb(_.BACKGROUND),[_.BACKGROUND]);return _0x468bf5(View,{pointerEvents:i.paused?"none":"auto",style:[styles.root,{backgroundColor:_.BACKGROUND}],onLayout:U,children:[G?_0x43dc7b(GameView,{...x,paused:x.paused||!!n||i.paused&&p||!C,source:G,background:g??q,onUpdate:k,overlay:P.world,onOverlayTouch:P.touch,onPrimaryAction:()=>P.activatePrimary(),onStats:__DEV__?logStats:void 0}):null,X?null:A,n&&_0x43dc7b(View,{pointerEvents:"none",style:styles.error,children:_0x43dc7b(Text,{accessibilityRole:"alert",style:{color:_.TEXT},children:n})}),X&&m&&K?_0x43dc7b(View,{pointerEvents:"box-none",style:[styles.banner,{top:K.top,width:K.width,left:((j?.width??0)-K.width)/2}],children:_0x43dc7b(View,{onLayout:z,children:m})}):null,_0x43dc7b(GameSettingsModal,{gameId:e,settings:i,onSettingsChange:l})]})};export function engineGame(e,t){const n=_0x1c4231.memo(n=>{const o=_0x5b2eee(22),s=useContext(EngineReadyContext),[a,r]=useState(s),[i,l]=useState(null);let u,d;o[0]!==s?(u=()=>{if(!isEngineAvailable||s)return;let e=!0;return warmUpEngine().then(()=>{e&&r(!0)},t=>{e&&l(t instanceof Error?t.message:String(t))}),()=>{e=!1}},d=[s],o[0]=s,o[1]=u,o[2]=d):(u=o[1],d=o[2]),useEffect(u,d);const m=n.settings??DEFAULT_GAME_SETTINGS,g=isEngineAvailable&&a,h=!m.isVisible,S=!!i||!isEngineAvailable,f=i??(isEngineAvailable?void 0:"This game needs the Nayan engine, which is not available in this build.");let p,E,b,v,y;return o[3]!==m.offset||o[4]!==m.theme||o[5]!==h||o[6]!==S||o[7]!==f?(p=_0x43dc7b(GameLoading,{gameId:e,theme:m.theme,offset:m.offset,visible:h,error:S,message:f}),o[3]=m.offset,o[4]=m.theme,o[5]=h,o[6]=S,o[7]=f,o[8]=p):p=o[8],o[9]!==n||o[10]!==m?(E=_0x43dc7b(t,{...n,settings:m}),o[9]=n,o[10]=m,o[11]=E):E=o[11],o[12]!==n.onPlayingChange||o[13]!==E?(b=_0x43dc7b(GamePlayingContext.Provider,{value:n.onPlayingChange,children:E}),o[12]=n.onPlayingChange,o[13]=E,o[14]=b):b=o[14],o[15]!==g||o[16]!==p||o[17]!==b?(v=_0x43dc7b(View,{style:styles.root,children:_0x43dc7b(GameLoadingTransition,{ready:g,loader:p,children:b})}),o[15]=g,o[16]=p,o[17]=b,o[18]=v):v=o[18],o[19]!==m.theme||o[20]!==v?(y=_0x43dc7b(GameThemeProvider,{theme:m.theme,children:v}),o[19]=m.theme,o[20]=v,o[21]=y):y=o[21],y});return n.displayName=GAMES_METADATA[e].title,n}const styles=StyleSheet.create({root:{flex:1},error:{position:"absolute",top:"45%",alignSelf:"center",padding:24},banner:{position:"absolute",alignItems:"center",overflow:"hidden",borderRadius:10}});
1
+ "use strict";import{c as _0x358fb3}from"react/compiler-runtime";import _0x39041e,{useCallback,useContext,useEffect,useLayoutEffect,useMemo,useRef,useState}from"react";import{AppState,BackHandler,StyleSheet,Text,View}from"react-native";import{audio,GameView,isEngineAvailable,warmUpEngine,World}from"@nayan-ui/engine";import{GameSettingsModal,GameThemeProvider}from"../../helpers/index.js";import{GAMES_METADATA}from"../../services/GamesMetadata.js";import{GAME_SOUNDS,playSound,preloadSounds,stopAllSounds}from"../../services/SoundsService.js";import{resolveGameTheme}from"../../services/ThemeService.js";import{DEFAULT_GAME_SETTINGS}from"../../services/UtilsService.js";import{EngineHud}from"./EngineHud.js";import{EngineReadyContext}from"./EngineReadyContext.js";import{toRgb}from"./EngineUtils.js";import{GamePlayingContext,useGamePlaying}from"./GameActivity.js";import{GameLoading}from"./GameLoading.js";import{GameLoadingTransition}from"./GameLoadingTransition.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x2734ac,jsxs as _0x22b6e7}from"react/jsx-runtime";let soundOwner;const logStats=e=>{};export const EngineGameScreen=({gameId:e,hudCapacity:t,errorMessage:n,feedback:o,choices:a,onAudioChange:s,onActiveChange:r,settings:i=DEFAULT_GAME_SETTINGS,onSettingsChange:l,onShare:u,onShowLeaderboard:d,bannerAd:m,background:g,onUpdate:h,onResize:S,columns:f,playing:p,subtext:E,onStart:v,onStop:y,gameOver:A,children:b,source:G,...x})=>{useGamePlaying(p);const _=resolveGameTheme(i.theme),T=i.offset??0;useEffect(()=>preloadSounds([GAME_SOUNDS.STOP,GAME_SOUNDS.RESET]),[]);const w=useRef({}).current,[C,R]=useState(()=>"background"!==AppState.currentState&&"inactive"!==AppState.currentState);useEffect(()=>{const e=AppState.addEventListener("change",e=>R("active"===e));return()=>e.remove()},[]);const O=C&&!i.isVisible&&!i.paused&&!x.paused&&!n;useEffect(()=>{r?.(O)},[O,r]);const L=O&&i.enableSounds;useEffect(()=>(soundOwner=w,audio.muted=!L,L||stopAllSounds(),s?.(L),()=>{s?.(!1),soundOwner===w&&(stopAllSounds(),audio.muted=!1,soundOwner=void 0)}),[L,s,w]);const P=useGameResource(()=>new EngineHud(_,t),e=>()=>e.dispose()),[j,M]=useState(null),U=useCallback(e=>{const{width:t,height:n}=e.nativeEvent.layout;M(e=>e&&e.width===t&&e.height===n?e:{width:t,height:n})},[]),D=useRef(S);D.current=S,useEffect(()=>{j&&(D.current?.(j.width,j.height,T),P.layout(j.width,j.height,T))},[P,j,T]),useLayoutEffect(()=>P.setTheme(_),[P,_]),useEffect(()=>P.setChoices(a??[]),[P,a]);const N=useRef(o);N.current=o;const V=useRef(h);V.current=h;const k=useCallback(e=>{if(i.isVisible)return G instanceof World&&G.update(0),void P.update(0);V.current?.(e,P),P.update(e,N.current)},[P,G,i.isVisible]);P.setActions({onStart:()=>{stopAllSounds(),v()},onStop:()=>{stopAllSounds(),y(),playSound(GAME_SOUNDS.STOP,i.enableSounds)},onShare:u,onShowLeaderboard:d});const B=f.map(e=>[e.label,e.value,e.color,e.valueColor,e.lives?.count,e.lives?.max].join("\0")).join("\x01");useEffect(()=>P.setColumns(f),[P,B]),useLayoutEffect(()=>P.setPlaying(p,E),[P,p,E]);const I=useRef(i.enableSounds);I.current=i.enableSounds;const H=useRef(A);H.current=A;const F=A?[A.title,A.message,A.scoreLabel,A.score,A.buttonText,!!A.onShare].join("\0"):null,[K,W]=useState(null);useEffect(()=>{const e=H.current;if(!e)return P.hideGameOver(),void W(null);P.showGameOver({...e,onPlayAgain:()=>{stopAllSounds(),H.current?.onPlayAgain(),playSound(GAME_SOUNDS.RESET,I.current)},onShare:e.onShare?()=>H.current?.onShare?.():void 0}),W(P.gameOverBanner)},[P,F,j,_]);const z=useCallback(e=>{P.setGameOverReserve(e.nativeEvent.layout.height),W(P.gameOverBanner)},[P]),X=null!==A;useEffect(()=>{if(!X)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(H.current?.onPlayAgain(),!0));return()=>e.remove()},[X]);const q=useMemo(()=>toRgb(_.BACKGROUND),[_.BACKGROUND]);return _0x22b6e7(View,{pointerEvents:i.paused?"none":"auto",style:[styles.root,{backgroundColor:_.BACKGROUND}],onLayout:U,children:[G?_0x2734ac(GameView,{...x,paused:x.paused||!!n||i.paused&&p||!C,source:G,background:g??q,onUpdate:k,overlay:P.world,onOverlayTouch:P.touch,onPrimaryAction:()=>P.activatePrimary(),onStats:__DEV__?logStats:void 0}):null,X?null:b,n&&_0x2734ac(View,{pointerEvents:"none",style:styles.error,children:_0x2734ac(Text,{accessibilityRole:"alert",style:{color:_.TEXT},children:n})}),X&&m&&K?_0x2734ac(View,{pointerEvents:"box-none",style:[styles.banner,{top:K.top,width:K.width,left:((j?.width??0)-K.width)/2}],children:_0x2734ac(View,{onLayout:z,children:m})}):null,_0x2734ac(GameSettingsModal,{gameId:e,settings:i,onSettingsChange:l})]})};export function engineGame(e,t){const n=_0x39041e.memo(n=>{const o=_0x358fb3(22),a=useContext(EngineReadyContext),[s,r]=useState(a),[i,l]=useState(null);let u,d;o[0]!==a?(u=()=>{if(!isEngineAvailable||a)return;let e=!0;return warmUpEngine().then(()=>{e&&r(!0)},t=>{e&&l(t instanceof Error?t.message:String(t))}),()=>{e=!1}},d=[a],o[0]=a,o[1]=u,o[2]=d):(u=o[1],d=o[2]),useEffect(u,d);const m=n.settings??DEFAULT_GAME_SETTINGS,g=isEngineAvailable&&s,h=!m.isVisible,S=!!i||!isEngineAvailable,f=i??(isEngineAvailable?void 0:"This game needs the Nayan engine, which is not available in this build.");let p,E,v,y,A;return o[3]!==m.offset||o[4]!==m.theme||o[5]!==h||o[6]!==S||o[7]!==f?(p=_0x2734ac(GameLoading,{gameId:e,theme:m.theme,offset:m.offset,visible:h,error:S,message:f}),o[3]=m.offset,o[4]=m.theme,o[5]=h,o[6]=S,o[7]=f,o[8]=p):p=o[8],o[9]!==n||o[10]!==m?(E=_0x2734ac(t,{...n,settings:m}),o[9]=n,o[10]=m,o[11]=E):E=o[11],o[12]!==n.onPlayingChange||o[13]!==E?(v=_0x2734ac(GamePlayingContext.Provider,{value:n.onPlayingChange,children:E}),o[12]=n.onPlayingChange,o[13]=E,o[14]=v):v=o[14],o[15]!==g||o[16]!==p||o[17]!==v?(y=_0x2734ac(View,{style:styles.root,children:_0x2734ac(GameLoadingTransition,{ready:g,loader:p,children:v})}),o[15]=g,o[16]=p,o[17]=v,o[18]=y):y=o[18],o[19]!==m.theme||o[20]!==y?(A=_0x2734ac(GameThemeProvider,{theme:m.theme,children:y}),o[19]=m.theme,o[20]=y,o[21]=A):A=o[21],A});return n.displayName=GAMES_METADATA[e].title,n}const styles=StyleSheet.create({root:{flex:1},error:{position:"absolute",top:"45%",alignSelf:"center",padding:24},banner:{position:"absolute",alignItems:"center",overflow:"hidden",borderRadius:10}});
@@ -1 +1 @@
1
- "use strict";import{merge,shapeGeometry,tube}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x3ac2a4}from"./EngineMeshes.js";export const GLYPH_RADIUS=.1;export const GLYPH_ADVANCE=.72;export const GLYPH_WIDTH=.6;const line=(e,n,s,i)=>({points:[[e,n],[s,i]]}),curve=(...e)=>({points:e}),loop=(e,n,s,i,l=16)=>({closed:!0,points:Array.from({length:l+3},(t,o)=>{const r=Math.PI/2+(o-1)/l*Math.PI*2;return[e+Math.cos(r)*s,n+Math.sin(r)*i]})}),arc=(e,n,s,i,l,t,o=12)=>({points:Array.from({length:o+1},(r,h)=>{const a=(l+(t-l)*h/o)*Math.PI/180;return[e+Math.cos(a)*s,n+Math.sin(a)*i]})}),SIX=[[.5,.9],[.32,.98],[.13,.86],[.05,.52],[.08,.2],[.28,.02],[.5,.11],[.56,.32],[.42,.54],[.2,.55],[.06,.38]],P_BOWL=curve([.06,1],[.38,1],[.54,.88],[.54,.62],[.38,.48],[.06,.48]),STROKES={0:[loop(.3,.5,.26,.47)],1:[line(.1,.76,.34,.97),line(.34,.97,.34,.03)],2:[curve([.05,.76],[.16,.93],[.33,.98],[.5,.89],[.55,.7],[.44,.5],[.05,.03]),line(.05,.03,.57,.03)],3:[curve([.06,.86],[.26,.98],[.48,.91],[.52,.72],[.28,.54]),curve([.28,.54],[.53,.4],[.55,.18],[.34,.02],[.05,.12])],4:[line(.42,.03,.42,.97),line(.42,.97,.03,.32),line(.03,.32,.6,.32)],5:[line(.54,.97,.13,.97),line(.13,.97,.08,.55),curve([.08,.55],[.3,.62],[.52,.5],[.56,.26],[.4,.04],[.18,.03],[.04,.14])],6:[{points:SIX}],7:[line(.03,.97,.58,.97),curve([.58,.97],[.38,.55],[.24,.03])],8:[loop(.3,.75,.21,.22),loop(.3,.27,.26,.26)],9:[{points:SIX.map(([e,n])=>[.6-e,1-n])}],A:[line(.02,0,.3,1),line(.3,1,.58,0),line(.13,.36,.47,.36)],B:[line(.06,0,.06,1),curve([.06,1],[.36,1],[.5,.91],[.5,.68],[.36,.54],[.06,.54]),curve([.06,.54],[.4,.54],[.56,.42],[.56,.13],[.4,0],[.06,0])],C:[arc(.33,.5,.29,.49,48,312)],D:[line(.06,0,.06,1),curve([.06,1],[.3,1],[.5,.86],[.56,.5],[.5,.14],[.3,0],[.06,0])],E:[line(.06,0,.06,1),line(.06,1,.54,1),line(.06,.52,.44,.52),line(.06,0,.54,0)],F:[line(.06,0,.06,1),line(.06,1,.54,1),line(.06,.52,.44,.52)],G:[arc(.32,.5,.28,.49,48,352),line(.6,.43,.36,.43)],H:[line(.06,0,.06,1),line(.54,0,.54,1),line(.06,.52,.54,.52)],I:[line(.3,0,.3,1),line(.12,1,.48,1),line(.12,0,.48,0)],J:[line(.2,1,.54,1),curve([.44,1],[.44,.26],[.37,.06],[.22,0],[.08,.07],[.04,.22])],K:[line(.06,0,.06,1),line(.54,1,.06,.38),line(.25,.58,.56,0)],L:[line(.06,1,.06,0),line(.06,0,.54,0)],M:[line(.02,0,.06,1),line(.06,1,.3,.36),line(.3,.36,.54,1),line(.54,1,.58,0)],N:[line(.06,0,.06,1),line(.06,1,.54,0),line(.54,0,.54,1)],O:[loop(.3,.5,.28,.48)],P:[line(.06,0,.06,1),P_BOWL],Q:[loop(.3,.5,.28,.48),line(.36,.24,.6,-.02)],R:[line(.06,0,.06,1),P_BOWL,line(.28,.48,.56,0)],S:[curve([.54,.86],[.42,.98],[.24,.99],[.08,.88],[.08,.68],[.3,.53],[.52,.38],[.54,.14],[.38,.01],[.18,.01],[.04,.14])],T:[line(.02,1,.58,1),line(.3,1,.3,0)],U:[curve([.06,1],[.06,.3],[.14,.07],[.3,0],[.46,.07],[.54,.3],[.54,1])],V:[line(.02,1,.3,0),line(.3,0,.58,1)],W:[line(0,1,.14,0),line(.14,0,.3,.64),line(.3,.64,.46,0),line(.46,0,.6,1)],X:[line(.04,0,.56,1),line(.04,1,.56,0)],Y:[line(.02,1,.3,.5),line(.58,1,.3,.5),line(.3,.5,.3,0)],Z:[line(.04,1,.56,1),line(.56,1,.04,0),line(.04,0,.56,0)]};export const hasGlyph=e=>e in STROKES;const meshes=new Map;export function glyphMesh(e){return cacheGameAsset("shared/EngineGlyphs:glyphMesh"+JSON.stringify([e]),()=>glyphMeshUncached(e))}function glyphMeshUncached(e){let n=meshes.get(e);if(!n){const s=STROKES[e];if(!s)throw new Error('glyphMesh: no glyph for "'+e+'"');const i=[];for(const{points:e,closed:n}of s){const s=e.map(([e,n])=>[e-.3,n-.5,0]);if(i.push({geometry:tube(s,{radius:.1,sides:8,smoothness:5})}),!n)for(const e of[s[0],s[s.length-1]])i.push({geometry:shapeGeometry("sphere"),position:e,scale:.2})}n=_0x3ac2a4(merge(i),{center:!1,shine:.2}),meshes.set(e,n)}return n}const flatMeshes=new Map;export function flatGlyphMesh(e,n=1){return cacheGameAsset("shared/EngineGlyphs:flatGlyphMesh"+JSON.stringify([e,n]),()=>flatGlyphMeshUncached(e,n))}function flatGlyphMeshUncached(e,n=1){const s=1===n?e:e+"@"+n;let i=flatMeshes.get(s);if(!i){const l=STROKES[e];if(!l)throw new Error('flatGlyphMesh: no glyph for "'+e+'"');const t=[];for(const{points:e,closed:s}of l){const i=e.map(([e,n])=>[e-.3,n-.5,0]);if(t.push({geometry:tube(i,{radius:.1*n,sides:8,smoothness:5})}),!s)for(const e of[i[0],i[i.length-1]])t.push({geometry:shapeGeometry("sphere"),position:e,scale:.2*n})}i=_0x3ac2a4(merge([{geometry:merge(t),scale:[1,1,.05]}]),{center:!1,shine:0}),flatMeshes.set(s,i)}return i}
1
+ "use strict";import{merge,shapeGeometry,tube}from"@nayan-ui/engine";import{cacheGameAsset,createGameMesh as _0x11f484}from"./EngineMeshes.js";export const GLYPH_RADIUS=.1;export const GLYPH_ADVANCE=.72;export const GLYPH_WIDTH=.6;const line=(e,n,s,i)=>({points:[[e,n],[s,i]]}),curve=(...e)=>({points:e}),loop=(e,n,s,i,l=16)=>({closed:!0,points:Array.from({length:l+3},(t,o)=>{const r=Math.PI/2+(o-1)/l*Math.PI*2;return[e+Math.cos(r)*s,n+Math.sin(r)*i]})}),arc=(e,n,s,i,l,t,o=12)=>({points:Array.from({length:o+1},(r,h)=>{const p=(l+(t-l)*h/o)*Math.PI/180;return[e+Math.cos(p)*s,n+Math.sin(p)*i]})}),SIX=[[.5,.9],[.32,.98],[.13,.86],[.05,.52],[.08,.2],[.28,.02],[.5,.11],[.56,.32],[.42,.54],[.2,.55],[.06,.38]],P_BOWL=curve([.06,1],[.38,1],[.54,.88],[.54,.62],[.38,.48],[.06,.48]),STROKES={0:[loop(.3,.5,.26,.47)],1:[line(.1,.76,.34,.97),line(.34,.97,.34,.03)],2:[curve([.05,.76],[.16,.93],[.33,.98],[.5,.89],[.55,.7],[.44,.5],[.05,.03]),line(.05,.03,.57,.03)],3:[curve([.06,.86],[.26,.98],[.48,.91],[.52,.72],[.28,.54]),curve([.28,.54],[.53,.4],[.55,.18],[.34,.02],[.05,.12])],4:[line(.42,.03,.42,.97),line(.42,.97,.03,.32),line(.03,.32,.6,.32)],5:[line(.54,.97,.13,.97),line(.13,.97,.08,.55),curve([.08,.55],[.3,.62],[.52,.5],[.56,.26],[.4,.04],[.18,.03],[.04,.14])],6:[{points:SIX}],7:[line(.03,.97,.58,.97),curve([.58,.97],[.38,.55],[.24,.03])],8:[loop(.3,.75,.21,.22),loop(.3,.27,.26,.26)],9:[{points:SIX.map(([e,n])=>[.6-e,1-n])}],A:[line(.02,0,.3,1),line(.3,1,.58,0),line(.13,.36,.47,.36)],B:[line(.06,0,.06,1),curve([.06,1],[.36,1],[.5,.91],[.5,.68],[.36,.54],[.06,.54]),curve([.06,.54],[.4,.54],[.56,.42],[.56,.13],[.4,0],[.06,0])],C:[arc(.33,.5,.29,.49,48,312)],D:[line(.06,0,.06,1),curve([.06,1],[.3,1],[.5,.86],[.56,.5],[.5,.14],[.3,0],[.06,0])],E:[line(.06,0,.06,1),line(.06,1,.54,1),line(.06,.52,.44,.52),line(.06,0,.54,0)],F:[line(.06,0,.06,1),line(.06,1,.54,1),line(.06,.52,.44,.52)],G:[arc(.32,.5,.28,.49,48,352),line(.6,.43,.36,.43)],H:[line(.06,0,.06,1),line(.54,0,.54,1),line(.06,.52,.54,.52)],I:[line(.3,0,.3,1),line(.12,1,.48,1),line(.12,0,.48,0)],J:[line(.2,1,.54,1),curve([.44,1],[.44,.26],[.37,.06],[.22,0],[.08,.07],[.04,.22])],K:[line(.06,0,.06,1),line(.54,1,.06,.38),line(.25,.58,.56,0)],L:[line(.06,1,.06,0),line(.06,0,.54,0)],M:[line(.02,0,.06,1),line(.06,1,.3,.36),line(.3,.36,.54,1),line(.54,1,.58,0)],N:[line(.06,0,.06,1),line(.06,1,.54,0),line(.54,0,.54,1)],O:[loop(.3,.5,.28,.48)],P:[line(.06,0,.06,1),P_BOWL],Q:[loop(.3,.5,.28,.48),line(.36,.24,.6,-.02)],R:[line(.06,0,.06,1),P_BOWL,line(.28,.48,.56,0)],S:[curve([.54,.86],[.42,.98],[.24,.99],[.08,.88],[.08,.68],[.3,.53],[.52,.38],[.54,.14],[.38,.01],[.18,.01],[.04,.14])],T:[line(.02,1,.58,1),line(.3,1,.3,0)],U:[curve([.06,1],[.06,.3],[.14,.07],[.3,0],[.46,.07],[.54,.3],[.54,1])],V:[line(.02,1,.3,0),line(.3,0,.58,1)],W:[line(0,1,.14,0),line(.14,0,.3,.64),line(.3,.64,.46,0),line(.46,0,.6,1)],X:[line(.04,0,.56,1),line(.04,1,.56,0)],Y:[line(.02,1,.3,.5),line(.58,1,.3,.5),line(.3,.5,.3,0)],Z:[line(.04,1,.56,1),line(.56,1,.04,0),line(.04,0,.56,0)]};export const hasGlyph=e=>e in STROKES;const meshes=new Map;export function glyphMesh(e){return cacheGameAsset("shared/EngineGlyphs:glyphMesh"+JSON.stringify([e]),()=>glyphMeshUncached(e))}function glyphMeshUncached(e){let n=meshes.get(e);if(!n){const s=STROKES[e];if(!s)throw new Error('glyphMesh: no glyph for "'+e+'"');const i=[];for(const{points:e,closed:n}of s){const s=e.map(([e,n])=>[e-.3,n-.5,0]);if(i.push({geometry:tube(s,{radius:.1,sides:8,smoothness:5})}),!n)for(const e of[s[0],s[s.length-1]])i.push({geometry:shapeGeometry("sphere"),position:e,scale:.2})}n=_0x11f484(merge(i),{center:!1,shine:.2}),meshes.set(e,n)}return n}const flatMeshes=new Map;export function flatGlyphMesh(e,n=1){return cacheGameAsset("shared/EngineGlyphs:flatGlyphMesh"+JSON.stringify([e,n]),()=>flatGlyphMeshUncached(e,n))}function flatGlyphMeshUncached(e,n=1){const s=1===n?e:e+"@"+n;let i=flatMeshes.get(s);if(!i){const l=STROKES[e];if(!l)throw new Error('flatGlyphMesh: no glyph for "'+e+'"');const t=[];for(const{points:e,closed:s}of l){const i=e.map(([e,n])=>[e-.3,n-.5,0]);if(t.push({geometry:tube(i,{radius:.1*n,sides:8,smoothness:5})}),!s)for(const e of[i[0],i[i.length-1]])t.push({geometry:shapeGeometry("sphere"),position:e,scale:.2*n})}i=_0x11f484(merge([{geometry:merge(t),scale:[1,1,.05]}]),{center:!1,shine:0}),flatMeshes.set(s,i)}return i}
@@ -1 +1 @@
1
- "use strict";import{extrude,loadFont,measureText,Path,World}from"@nayan-ui/engine";import{PLAY_PATH,SHARE_PATH,TROPHY_PATH}from"../../helpers/IconPaths.js";import{formatTime,getGameDimensions}from"../../services/UtilsService.js";import{cardBackdropMesh}from"./EngineBackdrop.js";import{fitControlSubtitle}from"./EngineControlText.js";import{cacheGameAsset,createGameMesh as _0x597f1b}from"./EngineMeshes.js";import{gameWidthFor,toColor}from"./EngineUtils.js";const CAPACITY=900,BOARD_PAD_V=14,BOARD_RADIUS=18,LABEL_SIZE=12,VALUE_SIZE=24,LABEL_SPACING=1.2,BOARD_HEIGHT=68,ROW_PAD_V=20,ROW_PAD_H=16,ROW_GAP=20,MAIN_HEIGHT=60,ICON_SIZE=56,BUTTON_TEXT=16,BUTTON_SUBTEXT=10,PULSE=1.05,PRESSED=.95,Z_OVER=40,CARD_PAD=20,TROPHY=48,TITLE_SIZE=28,MESSAGE_SIZE=14,SCORE_LABEL_SIZE=13,SCORE_SIZE=44,PROMPT_SIZE=15,PLAY_SIZE=17,SHARE_SIZE=16,RESULT_BUTTON=52,COUNT_DELAY=.2,COUNT_TIME=.9,SHARE_PROMPT="Share your goals with your family and friends and challenge them to beat your score!";export const getScoreBoardTop=(t=0)=>t>0?t+15:15;export const getSceneInputInsets=(t=0)=>({top:getScoreBoardTop(t)+68+10,bottom:95});export const scoreColumn=(t,e="SCORE",s=t=>t.toLocaleString())=>({label:e,value:s(t)});export const timerColumn=(t,e,s=30,o="TIMER")=>{const i=Math.max(0,Math.ceil(t));return{label:o,value:formatTime(i),valueColor:i<=s?e.DANGER:void 0}};export const livesColumn=(t,e,s="LIVES")=>({label:s,value:t+"/"+e,lives:{count:t,max:e}});export const textColumn=(t,e,s)=>({label:t,value:String(e),color:s});const HEART_PATH="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",HEART_SIZE=20,HEART_GAP=2,HEART_ON="#E53935",HEART_OFF="#2B2B2B",meshes=new Map,cached=(t,e)=>{let s=meshes.get(t);return!s&&(s=cacheGameAsset("shared/EngineHud:"+t,e),meshes.set(t,s)),s},panelMesh=(t,e,s)=>{const[o,i]=[Math.round(t),Math.round(e)];return cached("hud-panel:"+o+":"+i+":"+s,()=>_0x597f1b(extrude((new Path).addRoundedRect(-o/2,-i/2,o,i,Math.min(s,o/2,i/2)),{depth:0}),{center:!1}))},ringMesh=(t,e,s,o)=>{const[i,h]=[Math.round(t),Math.round(e)];return cached("hud-ring:"+i+":"+h+":"+s+":"+o,()=>{const t=Math.min(s,i/2,h/2),e=(new Path).addRoundedRect(-i/2,-h/2,i,h,t).addRoundedRect(-i/2+o,-h/2+o,i-2*o,h-2*o,Math.max(0,t-o));return _0x597f1b(extrude(e,{depth:0,fillRule:"evenodd"}),{center:!1})})},iconMesh=(t,e)=>cached("hud-icon:"+t,()=>_0x597f1b(extrude(Path.fromSVG(e),{depth:0}),{fit:1})),trophyMesh=()=>iconMesh("trophy",TROPHY_PATH),shareMesh=()=>iconMesh("share",SHARE_PATH),playMesh=()=>iconMesh("play",PLAY_PATH),heartMesh=()=>iconMesh("heart",HEART_PATH),TROPHY_INK=.875,SHARE_INK=415/512,PLAY_INK=332/512;let fonts=null,fontsLoading=null;const HUD_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,:!?'%/+-\xb7\xd7\xf7\u2026";export function loadHudFonts(){return fontsLoading??=loadFont(require("../../assets/fonts/Inter-SemiBold.ttf"),{depth:0,chars:HUD_CHARS}).then(t=>fonts={semi:t,regular:t}),fontsLoading}function textWidth(t,e,s=0,o="semi"){const i=fonts?.[o];return i?measureText(i,t,{letterSpacing:s/e})*e:0}function wrap(t,e,s,o){const i=[];let h="";for(const n of t.split(/\s+/)){const t=h?h+" "+n:n;h&&textWidth(t,e,0,o)>s?(i.push(h),h=n):h=t}return h&&i.push(h),i}const columnKey=t=>t.value+"\0"+(t.color??"")+"\0"+(t.valueColor??"")+"\0"+(t.lives?t.lives.count+"/"+t.lives.max:"");function spawnText(t,e,s,o,i,h,n,r=0,a="semi",l=!1){return t.spawn({text:s,font:fonts[a],parent:e,position:[o,i,2],scale:h,color:n,letterSpacing:r/h,tabular:l,pickable:!1})}export class EngineHud{size={width:0,height:0,offset:0};columns=[];playing=!1;subtext="Begin playing!";actions={onStart:()=>{},onStop:()=>{}};board=null;controls=null;values=[];buttons=[];pressed=null;over=null;overReserve=0;disposed=!1;feedback=null;waiting=null;layers=new Map;choices=[];choiceRoot=null;choiceButtons=[];choicePage=0;get ready(){return!this.disposed&&!!fonts&&this.size.width>0}get viewport(){return this.size}layer(t){let e=this.layers.get(t);return void 0===e&&(e=this.world.spawn({mesh:"none",position:[0,0,5],pickable:!1}),this.layers.set(t,e)),e}clearLayer(t){const e=this.layers.get(t);void 0!==e&&this.world.despawn(e),this.layers.delete(t)}text(t,e,s,o,i,h){return spawnText(this.world,t,e,s,o,i,h)}rectangle(t,e,s,o,i,h,n=0){return this.world.spawn({mesh:panelMesh(1,1,0),parent:t,position:[e,s,n],scale:[o,i,1],color:h,pickable:!1})}setChoices(t){const e=t.length!==this.choices.length||t.some((t,e)=>{const s=this.choices[e];return t.id!==s?.id||t.label!==s.label||t.selected!==s.selected});this.choices=t,e&&this.buildChoices()}buildChoices(){if(null!==this.choiceRoot&&this.world.despawn(this.choiceRoot),this.choiceRoot=null,this.choiceButtons=[],!this.ready||!this.choices.length)return;const{width:t,height:e}=this.size,s=Math.ceil(this.choices.length/3);this.choicePage=Math.min(this.choicePage,s-1);const o=this.world.spawn({mesh:"none",position:[0,0,6],pickable:!1});this.choiceRoot=o;const i=Math.min(t-24,500),h=(i-24)/5,n=e-getSceneInputInsets().bottom-22,r=(e,s,r,a=!1)=>{const l=(t-i)/2+h/2+s*(h+6),d=this.panel(o,l,n,h,36,12,a?this.theme.SOLID:this.theme.SURFACE);spawnText(this.world,d,e,0,0,Math.min(12,(h-8)/Math.max(1,e.length)/.65),toColor(a?this.theme.ON_SOLID:this.theme.TEXT)),this.choiceButtons.push({id:"choice",x:l-h/2,y:n-18,w:h,h:36,root:d,action:r})};r("<",0,()=>{this.choicePage=(this.choicePage+s-1)%s,this.buildChoices()}),this.choices.slice(3*this.choicePage,3*(this.choicePage+1)).forEach((t,e)=>r(t.label,e+1,()=>this.choices.find(e=>e.id===t.id)?.onPress(),t.selected)),r(">",4,()=>{this.choicePage=(this.choicePage+1)%s,this.buildChoices()})}constructor(t,e=900){this.world=new World(e),this.theme=t,loadHudFonts().then(()=>{this.disposed||(this.buildBoard(),this.buildControls(),this.buildChoices(),this.waiting&&this.buildOver(this.waiting,!0),this.waiting=null)}).catch(t=>{})}setActions(t){const e=!!t.onShare!=!!this.actions.onShare||!!t.onShowLeaderboard!=!!this.actions.onShowLeaderboard;this.actions=t,e&&this.buildControls()}layout(t,e,s){t===this.size.width&&e===this.size.height&&s===this.size.offset||(this.size={width:t,height:e,offset:s},this.layoutFeedback(),this.buildBoard(),this.buildControls(),this.buildChoices(),this.over&&this.buildOver(this.over.card,!1))}setTheme(t){t!==this.theme&&(this.theme=t,this.clearFeedback(),this.buildBoard(),this.buildControls(),this.buildChoices(),this.over&&this.buildOver(this.over.card,!1))}setColumns(t){const e=t.length===this.columns.length&&t.every((t,e)=>t.label===this.columns[e].label);if(this.columns=t,!e||this.values.length!==t.length)return this.buildBoard();t.forEach((t,e)=>{const s=this.values[e],o=columnKey(t);s.key===o||this.disposed||null===this.board||(this.world.despawn(s.entity),s.entity=this.spawnValue(this.board,t,s.x,s.y),s.key=o)})}setPlaying(t,e=this.subtext){t===this.playing&&e===this.subtext||(this.playing=t,this.subtext=e,this.buildControls())}update(t,e){if(this.disposed)return;e&&this.showFeedback(e);const s=this.over;if(s&&s.elapsed<1.1){s.elapsed+=t;const e=Math.min(1,Math.max(0,(s.elapsed-.2)/.9));this.setOverScore(Math.round(s.card.score*(1-(1-e)**3)))}this.world.update(t)}showFeedback(t){if(this.size.width&&fonts){if(!this.over&&!this.waiting&&(t.flash||t.message)){const e=this.feedback??={root:this.world.spawn({mesh:"none",position:[0,0,35],pickable:!1}),flash:null,message:null,text:""};if(t.flash){e.flash??=this.world.spawn({mesh:panelMesh(1,1,0),parent:e.root,pickable:!1});const t=toColor(this.theme.DANGER,.6);this.world.stopAnimation(e.flash),this.world.set(e.flash,{color:t}),this.world.animate(e.flash,{color:[t[0],t[1],t[2],0]},{duration:.4})}if(t.message){e.text!==t.message&&null!==e.message&&(this.world.despawn(e.message),e.message=null);const s=toColor(this.theme.SCORE_HIGHLIGHT);e.text=t.message,e.message??=spawnText(this.world,e.root,e.text,0,0,30,s),this.world.stopAnimation(e.message),this.world.set(e.message,{color:s}),this.world.animate(e.message,{color:[s[0],s[1],s[2],0]},{duration:.9})}this.layoutFeedback()}t.flash=!1,t.message=void 0}}layoutFeedback(){const t=this.feedback;if(!t)return;const{width:e,height:s,offset:o}=this.size;null!==t.flash&&this.world.set(t.flash,{position:[e/2,-s/2,0],scale:[e,s,1]}),null!==t.message&&this.world.set(t.message,{position:[e/2,-(getScoreBoardTop(o)+68+14+15),2]})}clearFeedback(){this.feedback&&!this.disposed&&this.world.despawn(this.feedback.root),this.feedback=null}showGameOver(t){this.clearFeedback();const e=this.over;e&&e.card.title===t.title&&e.card.message===t.message&&e.card.score===t.score&&!!e.card.onShare==!!t.onShare?e.card=t:fonts?this.buildOver(t,!0):this.waiting=t}hideGameOver(){this.waiting=null,this.over&&(this.disposed||this.world.despawn(this.over.root),this.pressed&&this.over.buttons.includes(this.pressed)&&(this.pressed=null),this.over=null)}get gameOverBanner(){return this.over?{top:this.over.bannerTop,width:this.over.bannerWidth}:null}setGameOverReserve(t){Math.abs(t-this.overReserve)<1||(this.overReserve=t,this.over&&this.buildOver(this.over.card,!1))}touch=(t,e,s)=>{if("start"===t){const t=(this.over?this.over.buttons:[...this.buttons,...this.choiceButtons]).find(t=>e>=t.x&&e<=t.x+t.w&&s>=t.y&&s<=t.y+t.h);return t?(this.pressed=t,this.world.animate(t.root,{scale:.95},{duration:.08}),!0):null!==this.over}if("move"===t||!this.pressed)return!0;const o=this.pressed;this.pressed=null;const i=e>=o.x-10&&e<=o.x+o.w+10&&s>=o.y-10&&s<=o.y+o.h+10;return this.release(o),"end"===t&&i&&(o.action?o.action():this.fire(o.id)),!0};dispose(){this.disposed||(this.disposed=!0,this.world.dispose())}release(t){"main"!==t.id||this.playing||t.action?this.world.animate(t.root,{scale:1},{duration:.12}):this.pulse(t.root)}pulse(t){this.world.set(t,{scale:1}),this.world.animate(t,{scale:1.05},{duration:1,repeat:"forever",yoyo:!0})}fire(t){"main"===t?(this.playing&&this.clearFeedback(),(this.playing?this.actions.onStop:this.actions.onStart)()):"share"===t?this.actions.onShare?.():this.actions.onShowLeaderboard?.()}panel(t,e,s,o,i,h,n=this.theme.SURFACE,r=this.theme.BORDER){const a=this.theme,l=this.world.spawn({mesh:"none",...null!==t&&{parent:t},position:[e,-s,0],pickable:!1}),d=a.BORDER_WIDTH??0;return d>0&&this.world.spawn({mesh:ringMesh(o,i,h,d),parent:l,position:[0,0,.5],color:toColor(r),pickable:!1}),this.world.spawn({mesh:panelMesh(o-2*d,i-2*d,h-d),parent:l,position:[0,0,0],color:toColor(n),pickable:!1}),l}setOverScore(t){const e=this.over;if(!e)return;const s=(e.card.formatter??(t=>t.toLocaleString()))(t);s===e.scoreText&&null!==e.scoreEntity||(null!==e.scoreEntity&&this.world.despawn(e.scoreEntity),e.scoreText=s,e.scoreEntity=spawnText(this.world,e.scoreParent,s,0,e.scoreY,44,toColor(this.theme.SCORE_HIGHLIGHT),0,"semi",!0))}buildOver(t,e){const s=this.over&&!e?this.over.elapsed:0;this.hideGameOver();const{width:o,height:i}=this.size;if(this.disposed||!o||!fonts)return;const h=this.theme,n=Math.min(getGameDimensions().width,o-30),r=n-40,a=t.message?wrap(t.message,14,r,"regular"):[],l=t.onShare?wrap(SHARE_PROMPT,15,r+30,"regular"):[],d=110+(a.length?4+20*a.length+16:20)+104+24+(l.length?25*l.length+5+12:0)+52+(this.overReserve>0?12+this.overReserve:0)+20,p=Math.max(10,(i-d)/2),u=o/2,m=this.world.spawn({mesh:"none",position:[0,0,40],pickable:!1}),w=this.world.spawn({mesh:panelMesh(o,i,0),parent:m,position:[o/2,-i/2,0],color:e?toColor(h.OVERLAY,0):toColor(h.OVERLAY),pickable:!1}),g=this.world.spawn({mesh:"none",parent:m,position:[u,-(p+d/2),2],pickable:!1});this.world.spawn({mesh:cardBackdropMesh(h,n,d,16),parent:g,position:[-Math.round(n)/2,Math.round(d)/2,0],color:[1,1,1,1],pickable:!1});const b=t=>d/2-t,f=t=>this.world.spawn({mesh:"none",parent:g,position:[0,b(t),1],pickable:!1});let T=20;const E=f(T+24);if(this.world.spawn({mesh:trophyMesh(),parent:E,position:[0,0,0],scale:42,color:[1,1,1,1],pickable:!1}),T+=56,spawnText(this.world,f(T+17),t.title,0,0,28,toColor(h.TEXT),1),T+=34,a.length){T+=4;for(const t of a)spawnText(this.world,f(T+10),t,0,0,14,toColor(h.TEXT_SUBTLE),0,"regular"),T+=20;T+=16}else T+=20;const S=b(T+52),v=f(T+52),x=Math.max(200,Math.min(r,260)),y=this.panel(v,0,0,x,104,16);spawnText(this.world,y,t.scoreLabel.toUpperCase(),0,28,13,toColor(h.TEXT_SUBTLE),1,"semi"),T+=128;const R=b(T),M=f(T);let A=0;for(const t of l)spawnText(this.world,M,t,0,-(A+12.5),15,toColor(h.TEXT_SUBTLE),0,"regular"),A+=25;l.length&&(A+=17);const C=[],_=A+26,O=-r/2,P=t.onShare?2*(r-10)/5:0,H=t.onShare?r-10-P:r,L=(t,e,s,o,i,h,n,r,a,l,d)=>{const m=this.panel(M,t+e/2,_,e,52,26,s,o),w=Math.min(h,h*(e-44)/Math.max(1,textWidth(i,h,.5,n))),g=textWidth(i,w,.5,n),b=-(g+26)/2+9;this.world.spawn({mesh:a,parent:m,position:[b,0,2],scale:18*l,color:r,pickable:!1}),spawnText(this.world,m,i,b+9+8+g/2,0,w,r,.5,n),C.push({id:"main",x:u+t,y:p+T+_-26,w:e,h:52,root:m,action:d})};if(t.onShare&&L(O,P,h.SURFACE,h.BORDER,"Share",16,"semi",toColor(h.TEXT),shareMesh(),SHARE_INK,()=>this.over?.card.onShare?.()),L(O+(t.onShare?P+10:0),H,h.SOLID,h.SOLID,t.buttonText,17,"semi",toColor(h.ON_SOLID),playMesh(),PLAY_INK,()=>this.over?.card.onPlayAgain()),A+=52,this.over={card:t,root:m,scoreParent:y,scoreY:-10,scoreText:"",scoreEntity:null,elapsed:s,buttons:C,bannerTop:p+T+A+12,bannerWidth:r},this.setOverScore(e?0:t.score),e){this.world.animate(w,{color:toColor(h.OVERLAY)},{duration:.16}),this.world.set(g,{scale:.85}),this.world.animate(g,{scale:1},{spring:"bouncy"}),this.world.set(E,{scale:0}),this.world.animate(E,[{scale:1.18},{scale:1}],{delay:.09,duration:.35,easing:"back"});for(const[t,e,s]of[[v,S,.2],[M,R,.33]])this.world.set(t,{position:[0,e-18,1]}),this.world.animate(t,{position:[0,e,1]},{delay:s,spring:!0})}}buildBoard(){if(this.disposed)return;null!==this.board&&this.world.despawn(this.board),this.board=null,this.values=[];const{width:t,offset:e}=this.size;if(!t||!fonts)return;const s=gameWidthFor(t),o=getScoreBoardTop(e),i=this.panel(null,t/2,o+34,s,68,18);this.board=i;const h=this.columns.length,n=toColor(this.theme.LABEL);this.columns.forEach((t,e)=>{const o=-s/2+s*(e+.5)/h;spawnText(this.world,i,t.label,o,14,12,t.color?toColor(t.color):n,1.2,"semi"),this.values.push({entity:this.spawnValue(i,t,o,-8),key:columnKey(t),x:o,y:-8})})}activatePrimary(){this.ready&&(this.over?this.over.card.onPlayAgain():this.fire("main"))}spawnValue(t,e,s,o){if(!e.lives)return spawnText(this.world,t,e.value,s,o,24,toColor(e.valueColor??e.color??this.theme.TEXT),0,"semi",!0);const{count:i,max:h}=e.lives,n=this.world.spawn({mesh:"none",parent:t,position:[s,o,2],pickable:!1}),r=gameWidthFor(this.size.width)/this.columns.length-12,a=Math.min(20,Math.max(6,(r-2*(h-1))/Math.max(1,h))),l=a+2;for(let t=0;t<h;t++){const e=(t-(h-1)/2)*l;this.world.spawn({mesh:heartMesh(),parent:n,position:[e,0,0],scale:a,color:toColor(t<i?HEART_ON:"#2B2B2B"),pickable:!1})}return n}buildControls(){if(this.disposed)return;null!==this.controls&&this.world.despawn(this.controls),this.controls=null,this.buttons=[],this.pressed=null;const{width:t,height:e}=this.size;if(!t||!fonts)return;const s=Math.min(getGameDimensions().width,t),o=(t-s)/2+16,i=(t+s)/2-16,h=e-5-20-30,n=this.world.spawn({mesh:"none",position:[0,0,10],pickable:!1});this.controls=n;const r=toColor(this.theme.TEXT);let a=o,l=i;const d=(t,e,s,o)=>{const i=this.panel(n,e,h,56,56,28);this.world.spawn({mesh:s,parent:i,position:[0,0,2],scale:24*o,color:r,pickable:!1}),this.buttons.push({id:t,x:e-28,y:h-28,w:56,h:56,root:i})};this.actions.onShowLeaderboard&&(d("leaderboard",o+28,trophyMesh(),.875),a+=76),this.actions.onShare&&(d("share",i-28,shareMesh(),SHARE_INK),l-=76);const p=l-a,u=(a+l)/2,m=this.panel(n,u,h,p,60,30);spawnText(this.world,m,this.playing?"STOP GAME":"START GAME",0,7,16,r,1);const w=fitControlSubtitle(this.playing?"Stop current game":this.subtext,Math.max(0,p-24),t=>textWidth(t,10,.5));spawnText(this.world,m,w,0,-12,10,toColor(this.theme.LABEL),.5,"semi"),this.buttons.push({id:"main",x:a,y:h-30,w:p,h:60,root:m}),this.playing||this.pulse(m)}}export function*warmAssets(){yield trophyMesh,yield shareMesh,yield playMesh,yield heartMesh}
1
+ "use strict";import{extrude,loadFont,measureText,Path,World}from"@nayan-ui/engine";import{PLAY_PATH,SHARE_PATH,TROPHY_PATH}from"../../helpers/IconPaths.js";import{formatTime,getGameDimensions}from"../../services/UtilsService.js";import{cardBackdropMesh}from"./EngineBackdrop.js";import{fitControlSubtitle}from"./EngineControlText.js";import{cacheGameAsset,createGameMesh as _0x36ae8a}from"./EngineMeshes.js";import{gameWidthFor,toColor}from"./EngineUtils.js";const CAPACITY=900,BOARD_PAD_V=14,BOARD_RADIUS=18,LABEL_SIZE=12,VALUE_SIZE=24,LABEL_SPACING=1.2,BOARD_HEIGHT=68,ROW_PAD_V=20,ROW_PAD_H=16,ROW_GAP=20,MAIN_HEIGHT=60,ICON_SIZE=56,BUTTON_TEXT=16,BUTTON_SUBTEXT=10,PULSE=1.05,PRESSED=.95,Z_OVER=40,CARD_PAD=20,TROPHY=48,TITLE_SIZE=28,MESSAGE_SIZE=14,SCORE_LABEL_SIZE=13,SCORE_SIZE=44,PROMPT_SIZE=15,PLAY_SIZE=17,SHARE_SIZE=16,RESULT_BUTTON=52,COUNT_DELAY=.2,COUNT_TIME=.9,SHARE_PROMPT="Share your goals with your family and friends and challenge them to beat your score!";export const getScoreBoardTop=(t=0)=>t>0?t+15:15;export const getSceneInputInsets=(t=0)=>({top:getScoreBoardTop(t)+68+10,bottom:95});export const scoreColumn=(t,e="SCORE",s=t=>t.toLocaleString())=>({label:e,value:s(t)});export const timerColumn=(t,e,s=30,o="TIMER")=>{const i=Math.max(0,Math.ceil(t));return{label:o,value:formatTime(i),valueColor:i<=s?e.DANGER:void 0}};export const livesColumn=(t,e,s="LIVES")=>({label:s,value:t+"/"+e,lives:{count:t,max:e}});export const textColumn=(t,e,s)=>({label:t,value:String(e),color:s});const HEART_PATH="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",HEART_SIZE=20,HEART_GAP=2,HEART_ON="#E53935",HEART_OFF="#2B2B2B",meshes=new Map,cached=(t,e)=>{let s=meshes.get(t);return!s&&(s=cacheGameAsset("shared/EngineHud:"+t,e),meshes.set(t,s)),s},panelMesh=(t,e,s)=>{const[o,i]=[Math.round(t),Math.round(e)];return cached("hud-panel:"+o+":"+i+":"+s,()=>_0x36ae8a(extrude((new Path).addRoundedRect(-o/2,-i/2,o,i,Math.min(s,o/2,i/2)),{depth:0}),{center:!1}))},ringMesh=(t,e,s,o)=>{const[i,h]=[Math.round(t),Math.round(e)];return cached("hud-ring:"+i+":"+h+":"+s+":"+o,()=>{const t=Math.min(s,i/2,h/2),e=(new Path).addRoundedRect(-i/2,-h/2,i,h,t).addRoundedRect(-i/2+o,-h/2+o,i-2*o,h-2*o,Math.max(0,t-o));return _0x36ae8a(extrude(e,{depth:0,fillRule:"evenodd"}),{center:!1})})},iconMesh=(t,e)=>cached("hud-icon:"+t,()=>_0x36ae8a(extrude(Path.fromSVG(e),{depth:0}),{fit:1})),trophyMesh=()=>iconMesh("trophy",TROPHY_PATH),shareMesh=()=>iconMesh("share",SHARE_PATH),playMesh=()=>iconMesh("play",PLAY_PATH),heartMesh=()=>iconMesh("heart",HEART_PATH),TROPHY_INK=.875,SHARE_INK=415/512,PLAY_INK=332/512;let fonts=null,fontsLoading=null;const HUD_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,:!?'%/+-\xb7\xd7\xf7\u2026";export function loadHudFonts(){return fontsLoading??=loadFont(require("../../assets/fonts/Inter-SemiBold.ttf"),{depth:0,chars:HUD_CHARS}).then(t=>fonts={semi:t,regular:t}),fontsLoading}function textWidth(t,e,s=0,o="semi"){const i=fonts?.[o];return i?measureText(i,t,{letterSpacing:s/e})*e:0}function wrap(t,e,s,o){const i=[];let h="";for(const n of t.split(/\s+/)){const t=h?h+" "+n:n;h&&textWidth(t,e,0,o)>s?(i.push(h),h=n):h=t}return h&&i.push(h),i}const columnKey=t=>t.value+"\0"+(t.color??"")+"\0"+(t.valueColor??"")+"\0"+(t.lives?t.lives.count+"/"+t.lives.max:"");function spawnText(t,e,s,o,i,h,n,r=0,a="semi",l=!1){return t.spawn({text:s,font:fonts[a],parent:e,position:[o,i,2],scale:h,color:n,letterSpacing:r/h,tabular:l,pickable:!1})}export class EngineHud{size={width:0,height:0,offset:0};columns=[];playing=!1;subtext="Begin playing!";actions={onStart:()=>{},onStop:()=>{}};board=null;controls=null;values=[];buttons=[];pressed=null;over=null;overReserve=0;disposed=!1;feedback=null;waiting=null;layers=new Map;choices=[];choiceRoot=null;choiceButtons=[];choicePage=0;get ready(){return!this.disposed&&!!fonts&&this.size.width>0}get viewport(){return this.size}layer(t){let e=this.layers.get(t);return void 0===e&&(e=this.world.spawn({mesh:"none",position:[0,0,5],pickable:!1}),this.layers.set(t,e)),e}clearLayer(t){const e=this.layers.get(t);void 0!==e&&this.world.despawn(e),this.layers.delete(t)}text(t,e,s,o,i,h){return spawnText(this.world,t,e,s,o,i,h)}rectangle(t,e,s,o,i,h,n=0){return this.world.spawn({mesh:panelMesh(1,1,0),parent:t,position:[e,s,n],scale:[o,i,1],color:h,pickable:!1})}setChoices(t){const e=t.length!==this.choices.length||t.some((t,e)=>{const s=this.choices[e];return t.id!==s?.id||t.label!==s.label||t.selected!==s.selected});this.choices=t,e&&this.buildChoices()}buildChoices(){if(null!==this.choiceRoot&&this.world.despawn(this.choiceRoot),this.choiceRoot=null,this.choiceButtons=[],!this.ready||!this.choices.length)return;const{width:t,height:e}=this.size,s=Math.ceil(this.choices.length/3);this.choicePage=Math.min(this.choicePage,s-1);const o=this.world.spawn({mesh:"none",position:[0,0,6],pickable:!1});this.choiceRoot=o;const i=Math.min(t-24,500),h=(i-24)/5,n=e-getSceneInputInsets().bottom-22,r=(e,s,r,a=!1)=>{const l=(t-i)/2+h/2+s*(h+6),d=this.panel(o,l,n,h,36,12,a?this.theme.SOLID:this.theme.SURFACE);spawnText(this.world,d,e,0,0,Math.min(12,(h-8)/Math.max(1,e.length)/.65),toColor(a?this.theme.ON_SOLID:this.theme.TEXT)),this.choiceButtons.push({id:"choice",x:l-h/2,y:n-18,w:h,h:36,root:d,action:r})};r("<",0,()=>{this.choicePage=(this.choicePage+s-1)%s,this.buildChoices()}),this.choices.slice(3*this.choicePage,3*(this.choicePage+1)).forEach((t,e)=>r(t.label,e+1,()=>this.choices.find(e=>e.id===t.id)?.onPress(),t.selected)),r(">",4,()=>{this.choicePage=(this.choicePage+1)%s,this.buildChoices()})}constructor(t,e=900){this.world=new World(e),this.theme=t,loadHudFonts().then(()=>{this.disposed||(this.buildBoard(),this.buildControls(),this.buildChoices(),this.waiting&&this.buildOver(this.waiting,!0),this.waiting=null)}).catch(t=>{})}setActions(t){const e=!!t.onShare!=!!this.actions.onShare||!!t.onShowLeaderboard!=!!this.actions.onShowLeaderboard;this.actions=t,e&&this.buildControls()}layout(t,e,s){t===this.size.width&&e===this.size.height&&s===this.size.offset||(this.size={width:t,height:e,offset:s},this.layoutFeedback(),this.buildBoard(),this.buildControls(),this.buildChoices(),this.over&&this.buildOver(this.over.card,!1))}setTheme(t){t!==this.theme&&(this.theme=t,this.clearFeedback(),this.buildBoard(),this.buildControls(),this.buildChoices(),this.over&&this.buildOver(this.over.card,!1))}setColumns(t){const e=t.length===this.columns.length&&t.every((t,e)=>t.label===this.columns[e].label);if(this.columns=t,!e||this.values.length!==t.length)return this.buildBoard();t.forEach((t,e)=>{const s=this.values[e],o=columnKey(t);s.key===o||this.disposed||null===this.board||(this.world.despawn(s.entity),s.entity=this.spawnValue(this.board,t,s.x,s.y),s.key=o)})}setPlaying(t,e=this.subtext){t===this.playing&&e===this.subtext||(this.playing=t,this.subtext=e,this.buildControls())}update(t,e){if(this.disposed)return;e&&this.showFeedback(e);const s=this.over;if(s&&s.elapsed<1.1){s.elapsed+=t;const e=Math.min(1,Math.max(0,(s.elapsed-.2)/.9));this.setOverScore(Math.round(s.card.score*(1-(1-e)**3)))}this.world.update(t)}showFeedback(t){if(this.size.width&&fonts){if(!this.over&&!this.waiting&&(t.flash||t.message)){const e=this.feedback??={root:this.world.spawn({mesh:"none",position:[0,0,35],pickable:!1}),flash:null,message:null,text:""};if(t.flash){e.flash??=this.world.spawn({mesh:panelMesh(1,1,0),parent:e.root,pickable:!1});const t=toColor(this.theme.DANGER,.6);this.world.stopAnimation(e.flash),this.world.set(e.flash,{color:t}),this.world.animate(e.flash,{color:[t[0],t[1],t[2],0]},{duration:.4})}if(t.message){e.text!==t.message&&null!==e.message&&(this.world.despawn(e.message),e.message=null);const s=toColor(this.theme.SCORE_HIGHLIGHT);e.text=t.message,e.message??=spawnText(this.world,e.root,e.text,0,0,30,s),this.world.stopAnimation(e.message),this.world.set(e.message,{color:s}),this.world.animate(e.message,{color:[s[0],s[1],s[2],0]},{duration:.9})}this.layoutFeedback()}t.flash=!1,t.message=void 0}}layoutFeedback(){const t=this.feedback;if(!t)return;const{width:e,height:s,offset:o}=this.size;null!==t.flash&&this.world.set(t.flash,{position:[e/2,-s/2,0],scale:[e,s,1]}),null!==t.message&&this.world.set(t.message,{position:[e/2,-(getScoreBoardTop(o)+68+14+15),2]})}clearFeedback(){this.feedback&&!this.disposed&&this.world.despawn(this.feedback.root),this.feedback=null}showGameOver(t){this.clearFeedback();const e=this.over;e&&e.card.title===t.title&&e.card.message===t.message&&e.card.score===t.score&&!!e.card.onShare==!!t.onShare?e.card=t:fonts?this.buildOver(t,!0):this.waiting=t}hideGameOver(){this.waiting=null,this.over&&(this.disposed||this.world.despawn(this.over.root),this.pressed&&this.over.buttons.includes(this.pressed)&&(this.pressed=null),this.over=null)}get gameOverBanner(){return this.over?{top:this.over.bannerTop,width:this.over.bannerWidth}:null}setGameOverReserve(t){Math.abs(t-this.overReserve)<1||(this.overReserve=t,this.over&&this.buildOver(this.over.card,!1))}touch=(t,e,s)=>{if("start"===t){const t=(this.over?this.over.buttons:[...this.buttons,...this.choiceButtons]).find(t=>e>=t.x&&e<=t.x+t.w&&s>=t.y&&s<=t.y+t.h);return t?(this.pressed=t,this.world.animate(t.root,{scale:.95},{duration:.08}),!0):null!==this.over}if("move"===t||!this.pressed)return!0;const o=this.pressed;this.pressed=null;const i=e>=o.x-10&&e<=o.x+o.w+10&&s>=o.y-10&&s<=o.y+o.h+10;return this.release(o),"end"===t&&i&&(o.action?o.action():this.fire(o.id)),!0};dispose(){this.disposed||(this.disposed=!0,this.world.dispose())}release(t){"main"!==t.id||this.playing||t.action?this.world.animate(t.root,{scale:1},{duration:.12}):this.pulse(t.root)}pulse(t){this.world.set(t,{scale:1}),this.world.animate(t,{scale:1.05},{duration:1,repeat:"forever",yoyo:!0})}fire(t){"main"===t?(this.playing&&this.clearFeedback(),(this.playing?this.actions.onStop:this.actions.onStart)()):"share"===t?this.actions.onShare?.():this.actions.onShowLeaderboard?.()}panel(t,e,s,o,i,h,n=this.theme.SURFACE,r=this.theme.BORDER){const a=this.theme,l=this.world.spawn({mesh:"none",...null!==t&&{parent:t},position:[e,-s,0],pickable:!1}),d=a.BORDER_WIDTH??0;return d>0&&this.world.spawn({mesh:ringMesh(o,i,h,d),parent:l,position:[0,0,.5],color:toColor(r),pickable:!1}),this.world.spawn({mesh:panelMesh(o-2*d,i-2*d,h-d),parent:l,position:[0,0,0],color:toColor(n),pickable:!1}),l}setOverScore(t){const e=this.over;if(!e)return;const s=(e.card.formatter??(t=>t.toLocaleString()))(t);s===e.scoreText&&null!==e.scoreEntity||(null!==e.scoreEntity&&this.world.despawn(e.scoreEntity),e.scoreText=s,e.scoreEntity=spawnText(this.world,e.scoreParent,s,0,e.scoreY,44,toColor(this.theme.SCORE_HIGHLIGHT),0,"semi",!0))}buildOver(t,e){const s=this.over&&!e?this.over.elapsed:0;this.hideGameOver();const{width:o,height:i}=this.size;if(this.disposed||!o||!fonts)return;const h=this.theme,n=Math.min(getGameDimensions().width,o-30),r=n-40,a=t.message?wrap(t.message,14,r,"regular"):[],l=t.onShare?wrap(SHARE_PROMPT,15,r+30,"regular"):[],d=110+(a.length?4+20*a.length+16:20)+104+24+(l.length?25*l.length+5+12:0)+52+(this.overReserve>0?12+this.overReserve:0)+20,p=Math.max(10,(i-d)/2),u=o/2,m=this.world.spawn({mesh:"none",position:[0,0,40],pickable:!1}),w=this.world.spawn({mesh:panelMesh(o,i,0),parent:m,position:[o/2,-i/2,0],color:e?toColor(h.OVERLAY,0):toColor(h.OVERLAY),pickable:!1}),g=this.world.spawn({mesh:"none",parent:m,position:[u,-(p+d/2),2],pickable:!1});this.world.spawn({mesh:cardBackdropMesh(h,n,d,16),parent:g,position:[-Math.round(n)/2,Math.round(d)/2,0],color:[1,1,1,1],pickable:!1});const b=t=>d/2-t,f=t=>this.world.spawn({mesh:"none",parent:g,position:[0,b(t),1],pickable:!1});let T=20;const E=f(T+24);if(this.world.spawn({mesh:trophyMesh(),parent:E,position:[0,0,0],scale:42,color:[1,1,1,1],pickable:!1}),T+=56,spawnText(this.world,f(T+17),t.title,0,0,28,toColor(h.TEXT),1),T+=34,a.length){T+=4;for(const t of a)spawnText(this.world,f(T+10),t,0,0,14,toColor(h.TEXT_SUBTLE),0,"regular"),T+=20;T+=16}else T+=20;const S=b(T+52),v=f(T+52),x=Math.max(200,Math.min(r,260)),y=this.panel(v,0,0,x,104,16);spawnText(this.world,y,t.scoreLabel.toUpperCase(),0,28,13,toColor(h.TEXT_SUBTLE),1,"semi"),T+=128;const R=b(T),M=f(T);let A=0;for(const t of l)spawnText(this.world,M,t,0,-(A+12.5),15,toColor(h.TEXT_SUBTLE),0,"regular"),A+=25;l.length&&(A+=17);const C=[],_=A+26,O=-r/2,P=t.onShare?2*(r-10)/5:0,H=t.onShare?r-10-P:r,L=(t,e,s,o,i,h,n,r,a,l,d)=>{const m=this.panel(M,t+e/2,_,e,52,26,s,o),w=Math.min(h,h*(e-44)/Math.max(1,textWidth(i,h,.5,n))),g=textWidth(i,w,.5,n),b=-(g+26)/2+9;this.world.spawn({mesh:a,parent:m,position:[b,0,2],scale:18*l,color:r,pickable:!1}),spawnText(this.world,m,i,b+9+8+g/2,0,w,r,.5,n),C.push({id:"main",x:u+t,y:p+T+_-26,w:e,h:52,root:m,action:d})};if(t.onShare&&L(O,P,h.SURFACE,h.BORDER,"Share",16,"semi",toColor(h.TEXT),shareMesh(),SHARE_INK,()=>this.over?.card.onShare?.()),L(O+(t.onShare?P+10:0),H,h.SOLID,h.SOLID,t.buttonText,17,"semi",toColor(h.ON_SOLID),playMesh(),PLAY_INK,()=>this.over?.card.onPlayAgain()),A+=52,this.over={card:t,root:m,scoreParent:y,scoreY:-10,scoreText:"",scoreEntity:null,elapsed:s,buttons:C,bannerTop:p+T+A+12,bannerWidth:r},this.setOverScore(e?0:t.score),e){this.world.animate(w,{color:toColor(h.OVERLAY)},{duration:.16}),this.world.set(g,{scale:.85}),this.world.animate(g,{scale:1},{spring:"bouncy"}),this.world.set(E,{scale:0}),this.world.animate(E,[{scale:1.18},{scale:1}],{delay:.09,duration:.35,easing:"back"});for(const[t,e,s]of[[v,S,.2],[M,R,.33]])this.world.set(t,{position:[0,e-18,1]}),this.world.animate(t,{position:[0,e,1]},{delay:s,spring:!0})}}buildBoard(){if(this.disposed)return;null!==this.board&&this.world.despawn(this.board),this.board=null,this.values=[];const{width:t,offset:e}=this.size;if(!t||!fonts)return;const s=gameWidthFor(t),o=getScoreBoardTop(e),i=this.panel(null,t/2,o+34,s,68,18);this.board=i;const h=this.columns.length,n=toColor(this.theme.LABEL);this.columns.forEach((t,e)=>{const o=-s/2+s*(e+.5)/h;spawnText(this.world,i,t.label,o,14,12,t.color?toColor(t.color):n,1.2,"semi"),this.values.push({entity:this.spawnValue(i,t,o,-8),key:columnKey(t),x:o,y:-8})})}activatePrimary(){this.ready&&(this.over?this.over.card.onPlayAgain():this.fire("main"))}spawnValue(t,e,s,o){if(!e.lives)return spawnText(this.world,t,e.value,s,o,24,toColor(e.valueColor??e.color??this.theme.TEXT),0,"semi",!0);const{count:i,max:h}=e.lives,n=this.world.spawn({mesh:"none",parent:t,position:[s,o,2],pickable:!1}),r=gameWidthFor(this.size.width)/this.columns.length-12,a=Math.min(20,Math.max(6,(r-2*(h-1))/Math.max(1,h))),l=a+2;for(let t=0;t<h;t++){const e=(t-(h-1)/2)*l;this.world.spawn({mesh:heartMesh(),parent:n,position:[e,0,0],scale:a,color:toColor(t<i?HEART_ON:"#2B2B2B"),pickable:!1})}return n}buildControls(){if(this.disposed)return;null!==this.controls&&this.world.despawn(this.controls),this.controls=null,this.buttons=[],this.pressed=null;const{width:t,height:e}=this.size;if(!t||!fonts)return;const s=Math.min(getGameDimensions().width,t),o=(t-s)/2+16,i=(t+s)/2-16,h=e-5-20-30,n=this.world.spawn({mesh:"none",position:[0,0,10],pickable:!1});this.controls=n;const r=toColor(this.theme.TEXT);let a=o,l=i;const d=(t,e,s,o)=>{const i=this.panel(n,e,h,56,56,28);this.world.spawn({mesh:s,parent:i,position:[0,0,2],scale:24*o,color:r,pickable:!1}),this.buttons.push({id:t,x:e-28,y:h-28,w:56,h:56,root:i})};this.actions.onShowLeaderboard&&(d("leaderboard",o+28,trophyMesh(),.875),a+=76),this.actions.onShare&&(d("share",i-28,shareMesh(),SHARE_INK),l-=76);const p=l-a,u=(a+l)/2,m=this.panel(n,u,h,p,60,30);spawnText(this.world,m,this.playing?"STOP GAME":"START GAME",0,7,16,r,1);const w=fitControlSubtitle(this.playing?"Stop current game":this.subtext,Math.max(0,p-24),t=>textWidth(t,10,.5));spawnText(this.world,m,w,0,-12,10,toColor(this.theme.LABEL),.5,"semi"),this.buttons.push({id:"main",x:a,y:h-30,w:p,h:60,root:m}),this.playing||this.pulse(m)}}export function*warmAssets(){yield trophyMesh,yield shareMesh,yield playMesh,yield heartMesh}
@@ -1 +1 @@
1
- "use strict";import{lathe,merge,quat,recolor,shapeGeometry,tube}from"@nayan-ui/engine";import{NIGHT_SCENE}from"../../services/ThemeService.js";import{toColor}from"../shared/EngineUtils.js";import{cacheGameAsset,createGameMesh as _0x5ec928}from"./EngineMeshes.js";const FOV=.9;export function makeView(e,t,o={}){const r=o.horizon??.62,s=Math.tan(.45),n=Math.atan(2*(r-.5)*s);return{width:e,height:t,eye:[0,o.eyeHeight??1.6,0],forward:[0,Math.sin(n),-Math.cos(n)],up:[0,Math.cos(n),Math.sin(n)],tanHalf:s,pitch:n,horizon:r,playDepth:o.playDepth??3.6}}export function cameraFor(e){const[t,o,r]=add(e.eye,scale(e.forward,e.playDepth));return{eye:[e.eye[0],e.eye[1],e.eye[2]],target:[t,o,r],fov:.9}}export const pointSize=(e,t=e.playDepth)=>2*t*e.tanHalf/e.height;export function at(e,t,o,r=e.playDepth){const s=pointSize(e,r),n=add(e.eye,scale(e.forward,r));return[n[0]+(t-e.width/2)*s,n[1]+(e.height/2-o)*s*e.up[1],n[2]+(e.height/2-o)*s*e.up[2]]}export function planeVector(e,t,o){const r=pointSize(e);return[t*r,-o*r*e.up[1],-o*r*e.up[2]]}export function facing(e,t=0){return quat.multiply(quat.x(e.pitch),quat.z(t))}export function rayThrough(e,t,o){const r=(t-e.width/2)/(e.height/2)*e.tanHalf,s=(e.height/2-o)/(e.height/2)*e.tanHalf;return normalize(add(add(e.forward,[r,0,0]),scale(e.up,s)))}export const add=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]];export const scale=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];const normalize=e=>scale(e,1/(Math.hypot(e[0],e[1],e[2])||1)),night=e=>"dark"===e.mode,DAY_LIGHT={direction:[.55,.8,.45],ambient:.42,color:[1.08,1.02,.94],shadows:!0,shadowExtent:22},NIGHT_LIGHT={direction:[-.45,.75,.4],ambient:.64,color:[.92,.95,1.06],shadows:!0,shadowExtent:22};export const lightFor=e=>night(e)?NIGHT_LIGHT:DAY_LIGHT;const rgb=e=>{const[t,o,r]=toColor(e);return[t,o,r]},mix=(e,t,o)=>[e[0]+(t[0]-e[0])*o,e[1]+(t[1]-e[1])*o,e[2]+(t[2]-e[2])*o],SKY_DAY={zenith:rgb("#2a73c0"),mid:rgb("#6aaee0"),horizon:rgb("#d8edf6")},SKY_NIGHT={zenith:rgb("#07061a"),mid:rgb(NIGHT_SCENE.SKY[1]),horizon:rgb(NIGHT_SCENE.SKY[3])};export const HAZE=rgb("#c6e0ec");const NIGHT_TINT=[.72,.76,.92,1],DAY_TINT=[1,1,1,1];export const sceneryTint=e=>night(e)?NIGHT_TINT:DAY_TINT;const hash=(e,t)=>{const o=43758.5453*Math.sin(127.1*e+311.7*t);return o-Math.floor(o)},smooth=e=>e*e*(3-2*e);export function noise(e,t){const o=Math.floor(e),r=Math.floor(t),s=smooth(e-o),n=smooth(t-r),a=hash(o,r),h=hash(o+1,r),i=hash(o,r+1);return a+(h-a)*s+(i-a)*n+(a-h-i+hash(o+1,r+1))*s*n}export const fbm=(e,t)=>.55*noise(e,t)+.3*noise(2.1*e,2.1*t)+.15*noise(4.3*e,4.3*t);export function random(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}class Mesh{vertices=[];indices=[];vertex(e,t,o){return this.vertices.push(e[0],e[1],e[2],t[0],t[1],t[2],o[0],o[1],o[2],0,0),this.vertices.length/11-1}grid(e,t,o){const r=this.vertices.length/11;for(let r=0;r<e;r++)for(let e=0;e<t;e++){const{p:t,n:s,c:n}=o(r,e);this.vertex(t,s,n)}const s=(e,o)=>r+e*t+o;for(let o=0;o+1<e;o++)for(let e=0;e+1<t;e++)this.indices.push(s(o,e),s(o,e+1),s(o+1,e+1),s(o,e),s(o+1,e+1),s(o+1,e))}geometry(){return{vertices:new Float32Array(this.vertices),indices:new Uint32Array(this.indices)}}}const meshes=new Map,cached=(e,t)=>{let o=meshes.get(e);return!o&&(o=cacheGameAsset("shared/EngineMeadow:"+e,t),meshes.set(e,o)),o},SKY_RADIUS=420;function skyMesh(e){const t=night(e);return cached("meadow-sky:"+(t?"night":"day"),()=>{const o=lightFor(e),r=normalize(o.direction),s=.6+.4*(.5*r[1]+.5),n=o.ambient*s+(1-o.ambient),a=o.color??[1,1,1],h=t?SKY_NIGHT:SKY_DAY,i=new Mesh;return i.grid(14,24,(e,t)=>{const o=e/13*1.2-.12,s=t/23*2.5-1.25,i=Math.max(0,o)/1.08,l=i<.25?mix(h.horizon,h.mid,smooth(i/.25)):mix(h.mid,h.zenith,smooth((i-.25)/.75));return{p:[Math.sin(s)*Math.cos(o)*420,420*Math.sin(o),-Math.cos(s)*Math.cos(o)*420],n:r,c:[Math.min(1,l[0]/(n*a[0])),Math.min(1,l[1]/(n*a[1])),Math.min(1,l[2]/(n*a[2]))]}}),_0x5ec928(i.geometry(),{center:!1})})}const HILLS={meadow:[{distance:250,height:34,roughness:.012,colors:["#5f8a6e","#4b7560"],haze:.62},{distance:150,height:20,roughness:.02,colors:["#4f8a4a","#3b6e3c"],haze:.4},{distance:85,height:11,roughness:.035,colors:["#4a8f3c","#356f2c"],haze:.2}],desert:[{distance:250,height:40,roughness:.014,colors:["#c7a07e","#a9846a"],haze:.58,mesa:!0},{distance:150,height:26,roughness:.022,colors:["#c9875a","#a5643d"],haze:.36,mesa:!0},{distance:85,height:9,roughness:.04,colors:["#ddb27a","#c4925a"],haze:.16}]};function hillMesh(e,t="meadow"){return cached("meadow-hill:"+t+":"+e,()=>{const o=HILLS[t][e],r=rgb(o.colors[0]),s=rgb(o.colors[1]),n=new Mesh,a=1.3*o.distance;n.grid(3,90,(t,n)=>{const h=n/89*a*2-a,i=fbm(h*o.roughness+7*e,3.1*e),l=o.height*(o.mesa?Math.min(1,.25+3.2*Math.max(0,i-.35)):.35+.65*i),d=0===t?l:1===t?.45*l:-2,m=-o.distance-20*fbm(.01*h,e)+(0===t?0:4*t),g=0===t?r:mix(r,s,t/2);return{p:[h,d,m],n:normalize([0,.55,.85]),c:mix(g,HAZE,o.haze)}});const h=n.geometry();for(let e=0;e<h.indices.length;e+=3){const t=h.indices[e+1];h.indices[e+1]=h.indices[e+2],h.indices[e+2]=t}return _0x5ec928(h,{center:!1})})}function groundMesh(){return cached("meadow-ground",()=>{const e=rgb("#5fae3e"),t=rgb("#3c7f2a"),o=rgb("#9bb24a"),r=new Mesh;return r.grid(46,40,(r,s)=>{const n=-(Math.pow(1.13,r)-1)*(246/243)-.3,a=12+1.25*-n,h=s/39*a*2-a,i=fbm(.08*h,.08*n),l=noise(.5*h,.5*n);let d=mix(t,e,i);d=mix(d,o,1.5*Math.max(0,l-.7));const m=1-Math.exp(-((-n/170)**2));return{p:[h,0,n],n:[0,1,0],c:mix(d,HAZE,.75*m)}}),_0x5ec928(r.geometry(),{center:!1})})}const leafy=(e,t,o)=>({position:r})=>{const s=noise(9*r[0]+o,9*r[1]+7*r[2]);return mix(t,e,Math.min(1,Math.max(0,.25+.6*r[1]+.5*s)))},oakMesh=()=>cached("meadow-oak",()=>{const e=rgb("#6b4423"),t=shapeGeometry("sphere"),o=[[[0,.62,0],.46],[[-.2,.54,.06],.32],[[.22,.56,-.04],.34],[[.04,.82,.03],.32],[[-.12,.74,-.14],.28],[[.14,.72,.16],.28],[[-.24,.68,-.02],.24]].map(([e,t],o)=>({geometry:recolor(shapeGeometry("sphere"),leafy(rgb("#6fbf4a"),rgb("#24602a"),3.7*o)),position:e,scale:t}));return _0x5ec928(merge([{geometry:tube([[0,0,0],[.01,.25,0],[-.02,.5,.01]],{radius:e=>.055-.025*e,color:e})},...o,{geometry:t,position:[0,.01,0],scale:[.14,.03,.14],color:rgb("#5a3a1e")}]),{center:!1,shine:.05})});export const pineMesh=()=>cached("meadow-pine",()=>{const e=[0,1,2,3].map(e=>{const t=.18+.19*e,o=.3-.06*e;return{geometry:recolor(lathe([[o,t],[.55*o,t+.12],[.001,t+.3]],{segments:14}),leafy(rgb("#3f8a45"),rgb("#123d1d"),5.1*e))}});return _0x5ec928(merge([{geometry:tube([[0,0,0],[0,.4,0]],{radius:e=>.045-.02*e,color:rgb("#5a3a22")})},...e]),{center:!1})});export const bushMesh=()=>cached("meadow-bush",()=>_0x5ec928(merge([[[0,.22,0],.5],[[-.24,.16,.05],.36],[[.25,.17,-.03],.38],[[.05,.36,.04],.34]].map(([e,t],o)=>({geometry:recolor(shapeGeometry("sphere"),leafy(rgb("#77c24f"),rgb("#2d6b2a"),2.3*o)),position:e,scale:[t,.8*t,t]}))),{center:!1,shine:.08}));export const rockMesh=()=>cached("meadow-rock",()=>_0x5ec928(merge([{geometry:recolor(shapeGeometry("sphere"),({position:e})=>{const t=.48+.22*noise(6*e[0],6*e[1]+4*e[2]);return[t,.98*t,.92*t]}),scale:[1,.55,.8],position:[0,.18,0]}]),{center:!1,shine:.15}));export const tuftMesh=()=>cached("meadow-tuft",()=>{const e=random(7),t=Array.from({length:7},()=>{const t=e()*Math.PI*2,o=.05+.08*e(),r=.22+.14*e(),s=.08*(e()-.5),n=.08*(e()-.5);return{geometry:recolor(tube([[s,0,n],[s+Math.cos(t)*o*.4,.55*r,n+Math.sin(t)*o*.4],[s+Math.cos(t)*o,r,n+Math.sin(t)*o]],{radius:e=>.014*(1-e),sides:4,smoothness:3}),({position:e})=>mix(rgb("#2f6e22"),rgb("#9ad466"),Math.min(1,e[1]/.3)))}});return _0x5ec928(merge(t),{center:!1})});export const flowerMesh=()=>cached("meadow-flower",()=>{const e=shapeGeometry("sphere"),t=[0,1,2,3,4].map(t=>{const o=t/5*Math.PI*2;return{geometry:e,position:[.05*Math.cos(o),.2,.05*Math.sin(o)],scale:[.06,.025,.06],color:[1,1,1]}});return _0x5ec928(merge([{geometry:tube([[0,0,0],[.01,.2,0]],{radius:.006,sides:4,color:rgb("#3d7a2a")})},...t,{geometry:e,position:[0,.21,0],scale:.04,color:rgb("#ffd23f")}]),{center:!1})});const HOT_AIR_PATTERNS=[["#e8433b","#ffd34d"],["#2f7ae5","#ffffff"],["#7b4fd6","#ff8a3d"]],hotAirBalloonMesh=e=>cached("meadow-hot-air:"+e,()=>{const[t,o]=HOT_AIR_PATTERNS[e].map(rgb),r=lathe([[.08,.28],[.16,.36],[.3,.52],[.36,.66],[.35,.8],[.27,.93],[.12,1],[.001,1.01]],{segments:24,color:({u:e})=>Math.floor(12*e)%2?t:o}),s=[0,1,2,3].map(e=>{const t=e/4*Math.PI*2+Math.PI/4;return{geometry:tube([[.075*Math.cos(t),.28,.075*Math.sin(t)],[.05*Math.cos(t),.12,.05*Math.sin(t)]],{radius:.004,sides:3,color:rgb("#5a4630")})}});return _0x5ec928(merge([{geometry:r},...s,{geometry:shapeGeometry("roundedBox"),position:[0,.08,0],scale:[.11,.08,.11],color:rgb("#8a5a2b")}]),{center:!1,shine:.25})}),FLOWER_COLORS=["#FF6B9D","#FF5A5A","#B784FF","#6FA8FF","#FF9F43","#FFFFFF"].map(e=>toColor(e));export function spawnWorld(e,t,o,r={}){const[s,n]=r.sun??[.8,.2],[a,h]=r.clouds??[.1,.42],i=night(o),l=i?NIGHT_TINT:DAY_TINT,d=e=>[e[0]*l[0],e[1]*l[1],e[2]*l[2],e[3]??1],m=[],g=(t,o,r,s,n)=>m.push(e.spawn({mesh:t,position:o,scale:r,color:s,...n?{rotation:n}:{},pickable:!1})),p=random(42),u=e=>quat.y(e);g(skyMesh(o),t.eye,1,[1,1,1,1]);const f=rayThrough(t,t.width*s,t.height*n),M=add(t.eye,scale(f,380));if(i){g("puff",M,90,[1.3,1.3,1.9,.35]),g("sphere",M,15,[2.1,2.1,2.3]);for(let e=0;e<46;e++){const e=rayThrough(t,p()*t.width,p()*t.height*t.horizon*.82);g("sphere",add(t.eye,scale(e,395)),.7+1.1*p(),[2,2,2.2])}}else g("puff",M,170,[2.2,1.9,1.2,.5]),g("puff",M,70,[2.4,2.2,1.6,.85]),g("sphere",M,22,[2.6,2.35,1.7]);const y=i?[.66,.68,.84,.88]:[1.18,1.18,1.22,.92];for(let o=0;o<7;o++){const r=rayThrough(t,o/6*t.width*1.1-.05*t.width+60*(p()-.5),t.height*(a+p()*(h-a))),s=add(t.eye,scale(r,200+120*p())),n=22+18*p();for(let t=0;t<7;t++){const t=[(p()-.5)*n*2.2,(p()-.3)*n*.5,(p()-.5)*n*.6];m.push(e.spawn({mesh:"puff",position:add(s,t),scale:n*(.8+.7*p()),color:y,velocity:[.12,0,0],pickable:!1}))}}const b=r.biome??"meadow";HILLS[b].forEach((e,t)=>g(hillMesh(t,b),[0,0,0],1,d([1,1,1,1])));const x=r.near??!0,w=x&&(r.groundDetails??!0);x&&g(groundMesh(),[0,0,0],1,d([1,1,1,1]));for(let e=0;w&&e<26;e++){const e=-(26+50*p()),t=(2*p()-1)*(.62*-e+6),o=p()<.45,r=(o?8:6)+5*p();g(o?pineMesh():oakMesh(),[t,0,e],[r*(.85+.3*p()),r,r*(.85+.3*p())],d([1,1,1,1]),u(6.3*p()))}w&&(r.framingTrees??!0)&&(g(oakMesh(),[-4.6,0,-11],[8.5,8,8.5],d([1,1,1,1]),u(.6)),g(pineMesh(),[5.2,0,-14],[8,12,8],d([1,1,1,1]),u(1.9)));for(let e=0;w&&e<16;e++){const e=-(7+24*p()),t=(2*p()-1)*(.55*-e+2),o=1+1.4*p();g(bushMesh(),[t,0,e],[1.2*o,o,1.2*o],d([.9+.2*p(),1,.9,1]),u(6.3*p()))}for(let e=0;w&&e<7;e++){const e=-(6+20*p()),t=(2*p()-1)*(.5*-e+1.5),o=.35+.8*p();g(rockMesh(),[t,0,e],o,d([1,1,1,1]),u(6.3*p()))}for(let o=0;o<(r.hotAirBalloons??0);o++){const r=rayThrough(t,t.width*(.15+.7*p()),t.height*(a+.05+p()*(h-a))),s=add(t.eye,scale(r,70+60*p())),n=9+4*p();m.push(e.spawn({mesh:hotAirBalloonMesh(o%HOT_AIR_PATTERNS.length),position:s,scale:n,rotation:u(6.3*p()),color:d([1,1,1,1]),velocity:[.25+.2*p(),0,0],bob:{amplitude:[0,.06*n,0],speed:.6+.3*p(),phase:6.3*p()},pickable:!1}))}if(!w||!(r.foreground??!0))return m;for(let e=0;e<150;e++){const e=-(4.4+16*Math.pow(p(),1.6)),t=(2*p()-1)*(.52*-e+.8),o=.9+.9*p();g(tuftMesh(),[t,0,e],o,d([1,1,1,1]),u(6.3*p()))}for(let e=0;e<55;e++){const e=-(4.6+14*Math.pow(p(),1.4)),t=(2*p()-1)*(.5*-e+.6),o=FLOWER_COLORS[Math.floor(p()*FLOWER_COLORS.length)];g(flowerMesh(),[t,0,e],.9+.6*p(),d(o),u(6.3*p()))}return m}export const backgroundFor=e=>night(e)?SKY_NIGHT.horizon:SKY_DAY.horizon;export function*warmAssets(e,t=["meadow","desert"]){yield()=>skyMesh(e);for(const e of t)for(let t=0;t<HILLS[e].length;t++)yield()=>hillMesh(t,e);for(const e of[groundMesh,oakMesh,pineMesh,bushMesh,rockMesh,tuftMesh,flowerMesh])yield e;for(let e=0;e<HOT_AIR_PATTERNS.length;e++)yield()=>hotAirBalloonMesh(e)}
1
+ "use strict";import{lathe,merge,quat,recolor,shapeGeometry,tube}from"@nayan-ui/engine";import{NIGHT_SCENE}from"../../services/ThemeService.js";import{toColor}from"../shared/EngineUtils.js";import{cacheGameAsset,createGameMesh as _0x166d34}from"./EngineMeshes.js";const FOV=.9;export function makeView(e,t,o={}){const r=o.horizon??.62,s=Math.tan(.45),n=Math.atan(2*(r-.5)*s);return{width:e,height:t,eye:[0,o.eyeHeight??1.6,0],forward:[0,Math.sin(n),-Math.cos(n)],up:[0,Math.cos(n),Math.sin(n)],tanHalf:s,pitch:n,horizon:r,playDepth:o.playDepth??3.6}}export function cameraFor(e){const[t,o,r]=add(e.eye,scale(e.forward,e.playDepth));return{eye:[e.eye[0],e.eye[1],e.eye[2]],target:[t,o,r],fov:.9}}export const pointSize=(e,t=e.playDepth)=>2*t*e.tanHalf/e.height;export function at(e,t,o,r=e.playDepth){const s=pointSize(e,r),n=add(e.eye,scale(e.forward,r));return[n[0]+(t-e.width/2)*s,n[1]+(e.height/2-o)*s*e.up[1],n[2]+(e.height/2-o)*s*e.up[2]]}export function planeVector(e,t,o){const r=pointSize(e);return[t*r,-o*r*e.up[1],-o*r*e.up[2]]}export function facing(e,t=0){return quat.multiply(quat.x(e.pitch),quat.z(t))}export function rayThrough(e,t,o){const r=(t-e.width/2)/(e.height/2)*e.tanHalf,s=(e.height/2-o)/(e.height/2)*e.tanHalf;return normalize(add(add(e.forward,[r,0,0]),scale(e.up,s)))}export const add=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]];export const scale=(e,t)=>[e[0]*t,e[1]*t,e[2]*t];const normalize=e=>scale(e,1/(Math.hypot(e[0],e[1],e[2])||1)),night=e=>"dark"===e.mode,DAY_LIGHT={direction:[.55,.8,.45],ambient:.42,color:[1.08,1.02,.94],shadows:!0,shadowExtent:22},NIGHT_LIGHT={direction:[-.45,.75,.4],ambient:.64,color:[.92,.95,1.06],shadows:!0,shadowExtent:22};export const lightFor=e=>night(e)?NIGHT_LIGHT:DAY_LIGHT;const rgb=e=>{const[t,o,r]=toColor(e);return[t,o,r]},mix=(e,t,o)=>[e[0]+(t[0]-e[0])*o,e[1]+(t[1]-e[1])*o,e[2]+(t[2]-e[2])*o],SKY_DAY={zenith:rgb("#2a73c0"),mid:rgb("#6aaee0"),horizon:rgb("#d8edf6")},SKY_NIGHT={zenith:rgb("#07061a"),mid:rgb(NIGHT_SCENE.SKY[1]),horizon:rgb(NIGHT_SCENE.SKY[3])};export const HAZE=rgb("#c6e0ec");const NIGHT_TINT=[.72,.76,.92,1],DAY_TINT=[1,1,1,1];export const sceneryTint=e=>night(e)?NIGHT_TINT:DAY_TINT;const hash=(e,t)=>{const o=43758.5453*Math.sin(127.1*e+311.7*t);return o-Math.floor(o)},smooth=e=>e*e*(3-2*e);export function noise(e,t){const o=Math.floor(e),r=Math.floor(t),s=smooth(e-o),n=smooth(t-r),a=hash(o,r),h=hash(o+1,r),i=hash(o,r+1);return a+(h-a)*s+(i-a)*n+(a-h-i+hash(o+1,r+1))*s*n}export const fbm=(e,t)=>.55*noise(e,t)+.3*noise(2.1*e,2.1*t)+.15*noise(4.3*e,4.3*t);export function random(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}class Mesh{vertices=[];indices=[];vertex(e,t,o){return this.vertices.push(e[0],e[1],e[2],t[0],t[1],t[2],o[0],o[1],o[2],0,0),this.vertices.length/11-1}grid(e,t,o){const r=this.vertices.length/11;for(let r=0;r<e;r++)for(let e=0;e<t;e++){const{p:t,n:s,c:n}=o(r,e);this.vertex(t,s,n)}const s=(e,o)=>r+e*t+o;for(let o=0;o+1<e;o++)for(let e=0;e+1<t;e++)this.indices.push(s(o,e),s(o,e+1),s(o+1,e+1),s(o,e),s(o+1,e+1),s(o+1,e))}geometry(){return{vertices:new Float32Array(this.vertices),indices:new Uint32Array(this.indices)}}}const meshes=new Map,cached=(e,t)=>{let o=meshes.get(e);return!o&&(o=cacheGameAsset("shared/EngineMeadow:"+e,t),meshes.set(e,o)),o},SKY_RADIUS=420;function skyMesh(e){const t=night(e);return cached("meadow-sky:"+(t?"night":"day"),()=>{const o=lightFor(e),r=normalize(o.direction),s=.6+.4*(.5*r[1]+.5),n=o.ambient*s+(1-o.ambient),a=o.color??[1,1,1],h=t?SKY_NIGHT:SKY_DAY,i=new Mesh;return i.grid(14,24,(e,t)=>{const o=e/13*1.2-.12,s=t/23*2.5-1.25,i=Math.max(0,o)/1.08,d=i<.25?mix(h.horizon,h.mid,smooth(i/.25)):mix(h.mid,h.zenith,smooth((i-.25)/.75));return{p:[Math.sin(s)*Math.cos(o)*420,420*Math.sin(o),-Math.cos(s)*Math.cos(o)*420],n:r,c:[Math.min(1,d[0]/(n*a[0])),Math.min(1,d[1]/(n*a[1])),Math.min(1,d[2]/(n*a[2]))]}}),_0x166d34(i.geometry(),{center:!1})})}const HILLS={meadow:[{distance:250,height:34,roughness:.012,colors:["#5f8a6e","#4b7560"],haze:.62},{distance:150,height:20,roughness:.02,colors:["#4f8a4a","#3b6e3c"],haze:.4},{distance:85,height:11,roughness:.035,colors:["#4a8f3c","#356f2c"],haze:.2}],desert:[{distance:250,height:40,roughness:.014,colors:["#c7a07e","#a9846a"],haze:.58,mesa:!0},{distance:150,height:26,roughness:.022,colors:["#c9875a","#a5643d"],haze:.36,mesa:!0},{distance:85,height:9,roughness:.04,colors:["#ddb27a","#c4925a"],haze:.16}]};function hillMesh(e,t="meadow"){return cached("meadow-hill:"+t+":"+e,()=>{const o=HILLS[t][e],r=rgb(o.colors[0]),s=rgb(o.colors[1]),n=new Mesh,a=1.3*o.distance;n.grid(3,90,(t,n)=>{const h=n/89*a*2-a,i=fbm(h*o.roughness+7*e,3.1*e),d=o.height*(o.mesa?Math.min(1,.25+3.2*Math.max(0,i-.35)):.35+.65*i),l=0===t?d:1===t?.45*d:-2,m=-o.distance-20*fbm(.01*h,e)+(0===t?0:4*t),g=0===t?r:mix(r,s,t/2);return{p:[h,l,m],n:normalize([0,.55,.85]),c:mix(g,HAZE,o.haze)}});const h=n.geometry();for(let e=0;e<h.indices.length;e+=3){const t=h.indices[e+1];h.indices[e+1]=h.indices[e+2],h.indices[e+2]=t}return _0x166d34(h,{center:!1})})}function groundMesh(){return cached("meadow-ground",()=>{const e=rgb("#5fae3e"),t=rgb("#3c7f2a"),o=rgb("#9bb24a"),r=new Mesh;return r.grid(46,40,(r,s)=>{const n=-(Math.pow(1.13,r)-1)*(246/243)-.3,a=12+1.25*-n,h=s/39*a*2-a,i=fbm(.08*h,.08*n),d=noise(.5*h,.5*n);let l=mix(t,e,i);l=mix(l,o,1.5*Math.max(0,d-.7));const m=1-Math.exp(-((-n/170)**2));return{p:[h,0,n],n:[0,1,0],c:mix(l,HAZE,.75*m)}}),_0x166d34(r.geometry(),{center:!1})})}const leafy=(e,t,o)=>({position:r})=>{const s=noise(9*r[0]+o,9*r[1]+7*r[2]);return mix(t,e,Math.min(1,Math.max(0,.25+.6*r[1]+.5*s)))},oakMesh=()=>cached("meadow-oak",()=>{const e=rgb("#6b4423"),t=shapeGeometry("sphere"),o=[[[0,.62,0],.46],[[-.2,.54,.06],.32],[[.22,.56,-.04],.34],[[.04,.82,.03],.32],[[-.12,.74,-.14],.28],[[.14,.72,.16],.28],[[-.24,.68,-.02],.24]].map(([e,t],o)=>({geometry:recolor(shapeGeometry("sphere"),leafy(rgb("#6fbf4a"),rgb("#24602a"),3.7*o)),position:e,scale:t}));return _0x166d34(merge([{geometry:tube([[0,0,0],[.01,.25,0],[-.02,.5,.01]],{radius:e=>.055-.025*e,color:e})},...o,{geometry:t,position:[0,.01,0],scale:[.14,.03,.14],color:rgb("#5a3a1e")}]),{center:!1,shine:.05})});export const pineMesh=()=>cached("meadow-pine",()=>{const e=[0,1,2,3].map(e=>{const t=.18+.19*e,o=.3-.06*e;return{geometry:recolor(lathe([[o,t],[.55*o,t+.12],[.001,t+.3]],{segments:14}),leafy(rgb("#3f8a45"),rgb("#123d1d"),5.1*e))}});return _0x166d34(merge([{geometry:tube([[0,0,0],[0,.4,0]],{radius:e=>.045-.02*e,color:rgb("#5a3a22")})},...e]),{center:!1})});export const bushMesh=()=>cached("meadow-bush",()=>_0x166d34(merge([[[0,.22,0],.5],[[-.24,.16,.05],.36],[[.25,.17,-.03],.38],[[.05,.36,.04],.34]].map(([e,t],o)=>({geometry:recolor(shapeGeometry("sphere"),leafy(rgb("#77c24f"),rgb("#2d6b2a"),2.3*o)),position:e,scale:[t,.8*t,t]}))),{center:!1,shine:.08}));export const rockMesh=()=>cached("meadow-rock",()=>_0x166d34(merge([{geometry:recolor(shapeGeometry("sphere"),({position:e})=>{const t=.48+.22*noise(6*e[0],6*e[1]+4*e[2]);return[t,.98*t,.92*t]}),scale:[1,.55,.8],position:[0,.18,0]}]),{center:!1,shine:.15}));export const tuftMesh=()=>cached("meadow-tuft",()=>{const e=random(7),t=Array.from({length:7},()=>{const t=e()*Math.PI*2,o=.05+.08*e(),r=.22+.14*e(),s=.08*(e()-.5),n=.08*(e()-.5);return{geometry:recolor(tube([[s,0,n],[s+Math.cos(t)*o*.4,.55*r,n+Math.sin(t)*o*.4],[s+Math.cos(t)*o,r,n+Math.sin(t)*o]],{radius:e=>.014*(1-e),sides:4,smoothness:3}),({position:e})=>mix(rgb("#2f6e22"),rgb("#9ad466"),Math.min(1,e[1]/.3)))}});return _0x166d34(merge(t),{center:!1})});export const flowerMesh=()=>cached("meadow-flower",()=>{const e=shapeGeometry("sphere"),t=[0,1,2,3,4].map(t=>{const o=t/5*Math.PI*2;return{geometry:e,position:[.05*Math.cos(o),.2,.05*Math.sin(o)],scale:[.06,.025,.06],color:[1,1,1]}});return _0x166d34(merge([{geometry:tube([[0,0,0],[.01,.2,0]],{radius:.006,sides:4,color:rgb("#3d7a2a")})},...t,{geometry:e,position:[0,.21,0],scale:.04,color:rgb("#ffd23f")}]),{center:!1})});const HOT_AIR_PATTERNS=[["#e8433b","#ffd34d"],["#2f7ae5","#ffffff"],["#7b4fd6","#ff8a3d"]],hotAirBalloonMesh=e=>cached("meadow-hot-air:"+e,()=>{const[t,o]=HOT_AIR_PATTERNS[e].map(rgb),r=lathe([[.08,.28],[.16,.36],[.3,.52],[.36,.66],[.35,.8],[.27,.93],[.12,1],[.001,1.01]],{segments:24,color:({u:e})=>Math.floor(12*e)%2?t:o}),s=[0,1,2,3].map(e=>{const t=e/4*Math.PI*2+Math.PI/4;return{geometry:tube([[.075*Math.cos(t),.28,.075*Math.sin(t)],[.05*Math.cos(t),.12,.05*Math.sin(t)]],{radius:.004,sides:3,color:rgb("#5a4630")})}});return _0x166d34(merge([{geometry:r},...s,{geometry:shapeGeometry("roundedBox"),position:[0,.08,0],scale:[.11,.08,.11],color:rgb("#8a5a2b")}]),{center:!1,shine:.25})}),FLOWER_COLORS=["#FF6B9D","#FF5A5A","#B784FF","#6FA8FF","#FF9F43","#FFFFFF"].map(e=>toColor(e));export function spawnWorld(e,t,o,r={}){const[s,n]=r.sun??[.8,.2],[a,h]=r.clouds??[.1,.42],i=night(o),d=i?NIGHT_TINT:DAY_TINT,l=e=>[e[0]*d[0],e[1]*d[1],e[2]*d[2],e[3]??1],m=[],g=(t,o,r,s,n)=>m.push(e.spawn({mesh:t,position:o,scale:r,color:s,...n?{rotation:n}:{},pickable:!1})),p=random(42),u=e=>quat.y(e);g(skyMesh(o),t.eye,1,[1,1,1,1]);const f=rayThrough(t,t.width*s,t.height*n),M=add(t.eye,scale(f,380));if(i){g("puff",M,90,[1.3,1.3,1.9,.35]),g("sphere",M,15,[2.1,2.1,2.3]);for(let e=0;e<46;e++){const e=rayThrough(t,p()*t.width,p()*t.height*t.horizon*.82);g("sphere",add(t.eye,scale(e,395)),.7+1.1*p(),[2,2,2.2])}}else g("puff",M,170,[2.2,1.9,1.2,.5]),g("puff",M,70,[2.4,2.2,1.6,.85]),g("sphere",M,22,[2.6,2.35,1.7]);const y=i?[.66,.68,.84,.88]:[1.18,1.18,1.22,.92];for(let o=0;o<7;o++){const r=rayThrough(t,o/6*t.width*1.1-.05*t.width+60*(p()-.5),t.height*(a+p()*(h-a))),s=add(t.eye,scale(r,200+120*p())),n=22+18*p();for(let t=0;t<7;t++){const t=[(p()-.5)*n*2.2,(p()-.3)*n*.5,(p()-.5)*n*.6];m.push(e.spawn({mesh:"puff",position:add(s,t),scale:n*(.8+.7*p()),color:y,velocity:[.12,0,0],pickable:!1}))}}const b=r.biome??"meadow";HILLS[b].forEach((e,t)=>g(hillMesh(t,b),[0,0,0],1,l([1,1,1,1])));const x=r.near??!0,w=x&&(r.groundDetails??!0);x&&g(groundMesh(),[0,0,0],1,l([1,1,1,1]));for(let e=0;w&&e<26;e++){const e=-(26+50*p()),t=(2*p()-1)*(.62*-e+6),o=p()<.45,r=(o?8:6)+5*p();g(o?pineMesh():oakMesh(),[t,0,e],[r*(.85+.3*p()),r,r*(.85+.3*p())],l([1,1,1,1]),u(6.3*p()))}w&&(r.framingTrees??!0)&&(g(oakMesh(),[-4.6,0,-11],[8.5,8,8.5],l([1,1,1,1]),u(.6)),g(pineMesh(),[5.2,0,-14],[8,12,8],l([1,1,1,1]),u(1.9)));for(let e=0;w&&e<16;e++){const e=-(7+24*p()),t=(2*p()-1)*(.55*-e+2),o=1+1.4*p();g(bushMesh(),[t,0,e],[1.2*o,o,1.2*o],l([.9+.2*p(),1,.9,1]),u(6.3*p()))}for(let e=0;w&&e<7;e++){const e=-(6+20*p()),t=(2*p()-1)*(.5*-e+1.5),o=.35+.8*p();g(rockMesh(),[t,0,e],o,l([1,1,1,1]),u(6.3*p()))}for(let o=0;o<(r.hotAirBalloons??0);o++){const r=rayThrough(t,t.width*(.15+.7*p()),t.height*(a+.05+p()*(h-a))),s=add(t.eye,scale(r,70+60*p())),n=9+4*p();m.push(e.spawn({mesh:hotAirBalloonMesh(o%HOT_AIR_PATTERNS.length),position:s,scale:n,rotation:u(6.3*p()),color:l([1,1,1,1]),velocity:[.25+.2*p(),0,0],bob:{amplitude:[0,.06*n,0],speed:.6+.3*p(),phase:6.3*p()},pickable:!1}))}if(!w||!(r.foreground??!0))return m;for(let e=0;e<150;e++){const e=-(4.4+16*Math.pow(p(),1.6)),t=(2*p()-1)*(.52*-e+.8),o=.9+.9*p();g(tuftMesh(),[t,0,e],o,l([1,1,1,1]),u(6.3*p()))}for(let e=0;e<55;e++){const e=-(4.6+14*Math.pow(p(),1.4)),t=(2*p()-1)*(.5*-e+.6),o=FLOWER_COLORS[Math.floor(p()*FLOWER_COLORS.length)];g(flowerMesh(),[t,0,e],.9+.6*p(),l(o),u(6.3*p()))}return m}export const backgroundFor=e=>night(e)?SKY_NIGHT.horizon:SKY_DAY.horizon;export function*warmAssets(e,t=["meadow","desert"]){yield()=>skyMesh(e);for(const e of t)for(let t=0;t<HILLS[e].length;t++)yield()=>hillMesh(t,e);for(const e of[groundMesh,oakMesh,pineMesh,bushMesh,rockMesh,tuftMesh,flowerMesh])yield e;for(let e=0;e<HOT_AIR_PATTERNS.length;e++)yield()=>hotAirBalloonMesh(e)}
@@ -1 +1 @@
1
- "use strict";import{c as _0x5d5708}from"react/compiler-runtime";import{memo,useCallback,useEffect,useRef}from"react";import{Platform,StyleSheet,View}from"react-native";import{jsx as _0x2dd5e6}from"react/jsx-runtime";export const EngineTouchSurface=memo(function(e){const t=_0x5d5708(32),{enabled:n,insets:o,onStart:r,onMove:i,onEnd:a,onCancel:s}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const m=useRef(u);let l;t[1]!==s?(l=()=>{m.current.clear(),s()},t[1]=s,t[2]=l):l=t[2];const d=l;let f,p,v,h,S,b;t[3]!==d||t[4]!==n?(f=()=>{!n&&d()},p=[n,d],t[3]=d,t[4]=n,t[5]=f,t[6]=p):(f=t[5],p=t[6]),useEffect(f,p),t[7]!==d?(v=()=>()=>d(),h=[d],t[7]=d,t[8]=v,t[9]=h):(v=t[8],h=t[9]),useEffect(v,h),t[10]!==d?(S=()=>{if("web"!==Platform.OS)return;const e=()=>{document.hidden&&d()};return window.addEventListener("blur",d),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("blur",d),document.removeEventListener("visibilitychange",e)}},b=[d],t[10]=d,t[11]=S,t[12]=b):(S=t[11],b=t[12]),useEffect(S,b);const g=_temp;let E;t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==r?(E=(e,t)=>{if(!n&&"end"!==t)return;const o="move"===t?e.nativeEvent.touches:e.nativeEvent.changedTouches;for(const n of o){const o={identifier:n.identifier,pageX:n.pageX,pageY:n.pageY,timeStamp:e.timeStamp};"start"===t?r(o):"move"===t?i(o):a(o)}},t[13]=n,t[14]=a,t[15]=i,t[16]=r,t[17]=E):E=t[17];const w=E,P=n?"auto":"none";let _,y,T,x;return t[18]===Symbol.for("react.memo_cache_sentinel")?(_="web"===Platform.OS?{touchAction:"none"}:null,t[18]=_):_=t[18],t[19]!==o?(y=[styles.surface,o,_],t[19]=o,t[20]=y):y=t[20],t[21]!==d||t[22]!==n||t[23]!==w||t[24]!==a||t[25]!==i||t[26]!==r?(T="web"===Platform.OS?{onPointerDown:e=>{const t=e;n&&0===t.button&&(!1!==t.isTrusted&&t.currentTarget.setPointerCapture(t.pointerId),m.current.add(t.pointerId),r(g(t)))},onPointerMove:e=>{n&&i(g(e))},onPointerUp:e=>{const t=e;m.current.delete(t.pointerId),a(g(t))},onPointerCancel:d,onLostPointerCapture:e=>{m.current.has(e.pointerId)&&d()}}:{onTouchStart:e=>w(e,"start"),onTouchMove:e=>w(e,"move"),onTouchEnd:e=>w(e,"end"),onTouchCancel:d},t[21]=d,t[22]=n,t[23]=w,t[24]=a,t[25]=i,t[26]=r,t[27]=T):T=t[27],t[28]!==P||t[29]!==y||t[30]!==T?(x=_0x2dd5e6(View,{collapsable:!1,pointerEvents:P,style:y,...T}),t[28]=P,t[29]=y,t[30]=T,t[31]=x):x=t[31],x});const styles=StyleSheet.create({surface:{position:"absolute",top:0,right:0,bottom:0,left:0}});function _temp(e){return{identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,timeStamp:e.timeStamp}}
1
+ "use strict";import{c as _0x1f023c}from"react/compiler-runtime";import{memo,useCallback,useEffect,useRef}from"react";import{Platform,StyleSheet,View}from"react-native";import{jsx as _0x25c479}from"react/jsx-runtime";export const EngineTouchSurface=memo(function(e){const t=_0x1f023c(32),{enabled:n,insets:o,onStart:r,onMove:i,onEnd:a,onCancel:s}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const m=useRef(u);let l;t[1]!==s?(l=()=>{m.current.clear(),s()},t[1]=s,t[2]=l):l=t[2];const f=l;let p,d,v,h,S,b;t[3]!==f||t[4]!==n?(p=()=>{!n&&f()},d=[n,f],t[3]=f,t[4]=n,t[5]=p,t[6]=d):(p=t[5],d=t[6]),useEffect(p,d),t[7]!==f?(v=()=>()=>f(),h=[f],t[7]=f,t[8]=v,t[9]=h):(v=t[8],h=t[9]),useEffect(v,h),t[10]!==f?(S=()=>{if("web"!==Platform.OS)return;const e=()=>{document.hidden&&f()};return window.addEventListener("blur",f),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("blur",f),document.removeEventListener("visibilitychange",e)}},b=[f],t[10]=f,t[11]=S,t[12]=b):(S=t[11],b=t[12]),useEffect(S,b);const g=_temp;let E;t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==r?(E=(e,t)=>{if(!n&&"end"!==t)return;const o="move"===t?e.nativeEvent.touches:e.nativeEvent.changedTouches;for(const n of o){const o={identifier:n.identifier,pageX:n.pageX,pageY:n.pageY,timeStamp:e.timeStamp};"start"===t?r(o):"move"===t?i(o):a(o)}},t[13]=n,t[14]=a,t[15]=i,t[16]=r,t[17]=E):E=t[17];const w=E,P=n?"auto":"none";let _,y,T,x;return t[18]===Symbol.for("react.memo_cache_sentinel")?(_="web"===Platform.OS?{touchAction:"none"}:null,t[18]=_):_=t[18],t[19]!==o?(y=[styles.surface,o,_],t[19]=o,t[20]=y):y=t[20],t[21]!==f||t[22]!==n||t[23]!==w||t[24]!==a||t[25]!==i||t[26]!==r?(T="web"===Platform.OS?{onPointerDown:e=>{const t=e;n&&0===t.button&&(!1!==t.isTrusted&&t.currentTarget.setPointerCapture(t.pointerId),m.current.add(t.pointerId),r(g(t)))},onPointerMove:e=>{n&&i(g(e))},onPointerUp:e=>{const t=e;m.current.delete(t.pointerId),a(g(t))},onPointerCancel:f,onLostPointerCapture:e=>{m.current.has(e.pointerId)&&f()}}:{onTouchStart:e=>w(e,"start"),onTouchMove:e=>w(e,"move"),onTouchEnd:e=>w(e,"end"),onTouchCancel:f},t[21]=f,t[22]=n,t[23]=w,t[24]=a,t[25]=i,t[26]=r,t[27]=T):T=t[27],t[28]!==P||t[29]!==y||t[30]!==T?(x=_0x25c479(View,{collapsable:!1,pointerEvents:P,style:y,...T}),t[28]=P,t[29]=y,t[30]=T,t[31]=x):x=t[31],x});const styles=StyleSheet.create({surface:{position:"absolute",top:0,right:0,bottom:0,left:0}});function _temp(e){return{identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,timeStamp:e.timeStamp}}
@@ -1 +1 @@
1
- "use strict";import{c as _0x565801}from"react/compiler-runtime";import{createContext,useContext,useLayoutEffect}from"react";export const GamePlayingContext=createContext(void 0);export function useGamePlaying(t){const e=_0x565801(4),o=useContext(GamePlayingContext);let n,a;e[0]!==o||e[1]!==t?(n=()=>(o?.(t),()=>o?.(!1)),a=[o,t],e[0]=o,e[1]=t,e[2]=n,e[3]=a):(n=e[2],a=e[3]),useLayoutEffect(n,a)}
1
+ "use strict";import{c as _0x4caf7d}from"react/compiler-runtime";import{createContext,useContext,useLayoutEffect}from"react";export const GamePlayingContext=createContext(void 0);export function useGamePlaying(t){const e=_0x4caf7d(4),o=useContext(GamePlayingContext);let a,n;e[0]!==o||e[1]!==t?(a=()=>(o?.(t),()=>o?.(!1)),n=[o,t],e[0]=o,e[1]=t,e[2]=a,e[3]=n):(a=e[2],n=e[3]),useLayoutEffect(a,n)}
@@ -1 +1 @@
1
- "use strict";import{c as _0x479791}from"react/compiler-runtime";import{memo,useCallback,useEffect,useRef,useState}from"react";import{AccessibilityInfo,ActivityIndicator,Pressable,StyleSheet,Text,View}from"react-native";import{GameView,isEngineAvailable,warmUpEngine}from"@nayan-ui/engine";import{GAMES_METADATA}from"../../services/GamesMetadata.js";import{resolveGameTheme}from"../../services/ThemeService.js";import{loadHudFonts}from"./EngineHud.js";import{EngineLoading,LOADING_LIGHT,loadingLook,loadingPlacement}from"./EngineLoading.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x32574c,Fragment as _0x2860de,jsxs as _0x44370d}from"react/jsx-runtime";const LoadingView=memo(function({gameId:e,theme:t,font:o,width:i,height:s,offset:r=0,label:l="Getting ready",error:n=!1,message:a,onRetry:d,visible:m=!0,reducedMotion:u,onFailure:g}){const h=useGameResource(()=>new EngineLoading(e,t,o),e=>()=>e.dispose());useEffect(()=>h.layout(i,s,r),[h,i,s,r]),useEffect(()=>h.setStatus({label:l,error:n,message:a,retry:!!d,reducedMotion:u}),[h,l,n,a,d,u]);const y=useCallback(e=>h.update(e),[h]),f=useRef(d);f.current=d;const b=useCallback((e,t)=>{const o=h.retryBounds;n&&e>=o.left&&e<=o.left+o.width&&t>=o.top&&t<=o.top+o.height&&f.current?.()},[h,n]),{retryBounds:p}=loadingPlacement(i,s,r);return _0x44370d(_0x2860de,{children:[_0x32574c(GameView,{source:h.world,camera:h.camera,light:LOADING_LIGHT,background:h.clearColor,onUpdate:y,paused:!m,onTap:b,onError:g,style:StyleSheet.absoluteFill}),m&&n&&d&&_0x32574c(Pressable,{accessibilityRole:"button",accessibilityLabel:"Try again",onPress:d,style:{position:"absolute",...p}})]})});export const GameLoading=memo(function(e){const t=_0x479791(43),{gameId:o,theme:i,label:s,error:r,message:l,onRetry:n,offset:a,visible:d}=e,m=void 0===s?"Getting ready":s,u=void 0!==r&&r,g=void 0===a?0:a,h=void 0===d||d;let y;t[0]!==i?(y=resolveGameTheme(i),t[0]=i,t[1]=y):y=t[1];const f=y;let b;t[2]!==o||t[3]!==i?(b=loadingLook(o,i),t[2]=o,t[3]=i,t[4]=b):b=t[4];const p=b,_=GAMES_METADATA[o].title,[x,w]=useState(null),[S,T]=useState(null),[E,v]=useState(!1),[L,A]=useState(!0);let G,I,R,k,C;t[5]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{let e=!0;AccessibilityInfo.isReduceMotionEnabled().then(t=>{e&&A(t)},_temp);const t=AccessibilityInfo.addEventListener("reduceMotionChanged",A);return()=>{e=!1,t.remove()}},I=[],t[5]=G,t[6]=I):(G=t[5],I=t[6]),useEffect(G,I),t[7]!==E||t[8]!==S||t[9]!==h?(k=()=>{if(S||!h||!isEngineAvailable||E)return;let e=!0;return warmUpEngine().then(loadHudFonts).then(t=>{e&&T(t.semi)},()=>{e&&v(!0)}),()=>{e=!1}},R=[S,h,E],t[7]=E,t[8]=S,t[9]=h,t[10]=R,t[11]=k):(R=t[10],k=t[11]),useEffect(k,R),t[12]===Symbol.for("react.memo_cache_sentinel")?(C=e=>{const{width:t,height:o}=e.nativeEvent.layout;w(e=>e?.width===t&&e.height===o?e:{width:t,height:o})},t[12]=C):C=t[12];const V=C;let M;t[13]===Symbol.for("react.memo_cache_sentinel")?(M=()=>v(!0),t[13]=M):M=t[13];const j=M,D=!!S&&!!x&&x.width>0&&x.height>0&&!E;let P;t[14]!==p.colours.sky?(P=[styles.root,{backgroundColor:p.colours.sky}],t[14]=p.colours.sky,t[15]=P):P=t[15];const z=!u,F=u?"alert":"progressbar",H=!u;let U;t[16]!==H?(U={busy:H},t[16]=H,t[17]=U):U=t[17];const O=_+". "+(u?l??"Unable to prepare this game":m);let B,N;return t[18]!==f||t[19]!==u||t[20]!==S||t[21]!==o||t[22]!==m||t[23]!==p.colours.accent||t[24]!==p.colours.horizon||t[25]!==p.colours.second||t[26]!==l||t[27]!==g||t[28]!==n||t[29]!==D||t[30]!==L||t[31]!==x||t[32]!==i||t[33]!==_||t[34]!==h?(B=D?_0x32574c(LoadingView,{gameId:o,theme:i,font:S,width:x.width,height:x.height,label:m,error:u,message:l,onRetry:n,offset:g,visible:h,reducedMotion:L,onFailure:j},o+":"+i):h&&_0x44370d(View,{style:[styles.fallback,{paddingTop:g}],children:[_0x44370d(View,{testID:"game-loading-art",accessible:!1,style:styles.art,children:[_0x32574c(View,{style:[styles.tile,{backgroundColor:p.colours.second,left:8,top:26,transform:[{rotate:"-16deg"}]}]}),_0x32574c(View,{style:[styles.tile,{backgroundColor:p.colours.horizon,right:8,top:26,transform:[{rotate:"16deg"}]}]}),_0x32574c(View,{style:[styles.tile,{backgroundColor:p.colours.accent,left:45,top:8}]})]}),_0x32574c(Text,{style:[styles.title,{color:f.TEXT}],children:_}),!u&&_0x32574c(ActivityIndicator,{animating:!L,hidesWhenStopped:!1,color:p.colours.accent,style:styles.spinner}),_0x32574c(Text,{accessibilityLiveRegion:"polite",accessibilityRole:u?"alert":"progressbar",style:[styles.label,{color:f.TEXT_SUBTLE}],children:u?l??"Unable to prepare this game.":m+"\u2026"}),u&&n&&_0x32574c(Pressable,{accessibilityRole:"button",onPress:n,style:[styles.retry,{backgroundColor:f.SOLID}],children:_0x32574c(Text,{style:{color:f.ON_SOLID},children:"Try again"})})]}),t[18]=f,t[19]=u,t[20]=S,t[21]=o,t[22]=m,t[23]=p.colours.accent,t[24]=p.colours.horizon,t[25]=p.colours.second,t[26]=l,t[27]=g,t[28]=n,t[29]=D,t[30]=L,t[31]=x,t[32]=i,t[33]=_,t[34]=h,t[35]=B):B=t[35],t[36]!==P||t[37]!==z||t[38]!==F||t[39]!==U||t[40]!==O||t[41]!==B?(N=_0x32574c(View,{testID:"game-loading",style:P,onLayout:V,accessible:z,accessibilityLiveRegion:"polite",accessibilityRole:F,accessibilityState:U,accessibilityLabel:O,children:B}),t[36]=P,t[37]=z,t[38]=F,t[39]=U,t[40]=O,t[41]=B,t[42]=N):N=t[42],N});const styles=StyleSheet.create({root:{flex:1},fallback:{flex:1,justifyContent:"center",alignItems:"center",padding:24},art:{width:144,height:104,marginBottom:24},tile:{position:"absolute",width:54,height:54,borderRadius:14,borderWidth:2,borderColor:"#ffffff55"},spinner:{marginTop:20},title:{fontSize:24,fontWeight:"600",textAlign:"center"},label:{fontSize:16,marginTop:12,textAlign:"center"},retry:{marginTop:20,paddingHorizontal:20,paddingVertical:12,borderRadius:12}});function _temp(){}
1
+ "use strict";import{c as _0x13d662}from"react/compiler-runtime";import{memo,useCallback,useEffect,useRef,useState}from"react";import{AccessibilityInfo,ActivityIndicator,Pressable,StyleSheet,Text,View}from"react-native";import{GameView,isEngineAvailable,warmUpEngine}from"@nayan-ui/engine";import{GAMES_METADATA}from"../../services/GamesMetadata.js";import{resolveGameTheme}from"../../services/ThemeService.js";import{loadHudFonts}from"./EngineHud.js";import{EngineLoading,LOADING_LIGHT,loadingLook,loadingPlacement}from"./EngineLoading.js";import{useGameResource}from"./useGameResource.js";import{jsx as _0x39b783,Fragment as _0x2d8f7b,jsxs as _0x26f4ff}from"react/jsx-runtime";const LoadingView=memo(function({gameId:e,theme:t,font:o,width:i,height:s,offset:r=0,label:l="Getting ready",error:n=!1,message:a,onRetry:d,visible:m=!0,reducedMotion:u,onFailure:g}){const b=useGameResource(()=>new EngineLoading(e,t,o),e=>()=>e.dispose());useEffect(()=>b.layout(i,s,r),[b,i,s,r]),useEffect(()=>b.setStatus({label:l,error:n,message:a,retry:!!d,reducedMotion:u}),[b,l,n,a,d,u]);const f=useCallback(e=>b.update(e),[b]),h=useRef(d);h.current=d;const y=useCallback((e,t)=>{const o=b.retryBounds;n&&e>=o.left&&e<=o.left+o.width&&t>=o.top&&t<=o.top+o.height&&h.current?.()},[b,n]),{retryBounds:p}=loadingPlacement(i,s,r);return _0x26f4ff(_0x2d8f7b,{children:[_0x39b783(GameView,{source:b.world,camera:b.camera,light:LOADING_LIGHT,background:b.clearColor,onUpdate:f,paused:!m,onTap:y,onError:g,style:StyleSheet.absoluteFill}),m&&n&&d&&_0x39b783(Pressable,{accessibilityRole:"button",accessibilityLabel:"Try again",onPress:d,style:{position:"absolute",...p}})]})});export const GameLoading=memo(function(e){const t=_0x13d662(43),{gameId:o,theme:i,label:s,error:r,message:l,onRetry:n,offset:a,visible:d}=e,m=void 0===s?"Getting ready":s,u=void 0!==r&&r,g=void 0===a?0:a,b=void 0===d||d;let f;t[0]!==i?(f=resolveGameTheme(i),t[0]=i,t[1]=f):f=t[1];const h=f;let y;t[2]!==o||t[3]!==i?(y=loadingLook(o,i),t[2]=o,t[3]=i,t[4]=y):y=t[4];const p=y,_=GAMES_METADATA[o].title,[x,w]=useState(null),[S,T]=useState(null),[E,v]=useState(!1),[L,A]=useState(!0);let G,I,R,k,C;t[5]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{let e=!0;AccessibilityInfo.isReduceMotionEnabled().then(t=>{e&&A(t)},_temp);const t=AccessibilityInfo.addEventListener("reduceMotionChanged",A);return()=>{e=!1,t.remove()}},I=[],t[5]=G,t[6]=I):(G=t[5],I=t[6]),useEffect(G,I),t[7]!==E||t[8]!==S||t[9]!==b?(k=()=>{if(S||!b||!isEngineAvailable||E)return;let e=!0;return warmUpEngine().then(loadHudFonts).then(t=>{e&&T(t.semi)},()=>{e&&v(!0)}),()=>{e=!1}},R=[S,b,E],t[7]=E,t[8]=S,t[9]=b,t[10]=R,t[11]=k):(R=t[10],k=t[11]),useEffect(k,R),t[12]===Symbol.for("react.memo_cache_sentinel")?(C=e=>{const{width:t,height:o}=e.nativeEvent.layout;w(e=>e?.width===t&&e.height===o?e:{width:t,height:o})},t[12]=C):C=t[12];const V=C;let M;t[13]===Symbol.for("react.memo_cache_sentinel")?(M=()=>v(!0),t[13]=M):M=t[13];const j=M,D=!!S&&!!x&&x.width>0&&x.height>0&&!E;let P;t[14]!==p.colours.sky?(P=[styles.root,{backgroundColor:p.colours.sky}],t[14]=p.colours.sky,t[15]=P):P=t[15];const z=!u,F=u?"alert":"progressbar",H=!u;let U;t[16]!==H?(U={busy:H},t[16]=H,t[17]=U):U=t[17];const O=_+". "+(u?l??"Unable to prepare this game":m);let B,N;return t[18]!==h||t[19]!==u||t[20]!==S||t[21]!==o||t[22]!==m||t[23]!==p.colours.accent||t[24]!==p.colours.horizon||t[25]!==p.colours.second||t[26]!==l||t[27]!==g||t[28]!==n||t[29]!==D||t[30]!==L||t[31]!==x||t[32]!==i||t[33]!==_||t[34]!==b?(B=D?_0x39b783(LoadingView,{gameId:o,theme:i,font:S,width:x.width,height:x.height,label:m,error:u,message:l,onRetry:n,offset:g,visible:b,reducedMotion:L,onFailure:j},o+":"+i):b&&_0x26f4ff(View,{style:[styles.fallback,{paddingTop:g}],children:[_0x26f4ff(View,{testID:"game-loading-art",accessible:!1,style:styles.art,children:[_0x39b783(View,{style:[styles.tile,{backgroundColor:p.colours.second,left:8,top:26,transform:[{rotate:"-16deg"}]}]}),_0x39b783(View,{style:[styles.tile,{backgroundColor:p.colours.horizon,right:8,top:26,transform:[{rotate:"16deg"}]}]}),_0x39b783(View,{style:[styles.tile,{backgroundColor:p.colours.accent,left:45,top:8}]})]}),_0x39b783(Text,{style:[styles.title,{color:h.TEXT}],children:_}),!u&&_0x39b783(ActivityIndicator,{animating:!L,hidesWhenStopped:!1,color:p.colours.accent,style:styles.spinner}),_0x39b783(Text,{accessibilityLiveRegion:"polite",accessibilityRole:u?"alert":"progressbar",style:[styles.label,{color:h.TEXT_SUBTLE}],children:u?l??"Unable to prepare this game.":m+"\u2026"}),u&&n&&_0x39b783(Pressable,{accessibilityRole:"button",onPress:n,style:[styles.retry,{backgroundColor:h.SOLID}],children:_0x39b783(Text,{style:{color:h.ON_SOLID},children:"Try again"})})]}),t[18]=h,t[19]=u,t[20]=S,t[21]=o,t[22]=m,t[23]=p.colours.accent,t[24]=p.colours.horizon,t[25]=p.colours.second,t[26]=l,t[27]=g,t[28]=n,t[29]=D,t[30]=L,t[31]=x,t[32]=i,t[33]=_,t[34]=b,t[35]=B):B=t[35],t[36]!==P||t[37]!==z||t[38]!==F||t[39]!==U||t[40]!==O||t[41]!==B?(N=_0x39b783(View,{testID:"game-loading",style:P,onLayout:V,accessible:z,accessibilityLiveRegion:"polite",accessibilityRole:F,accessibilityState:U,accessibilityLabel:O,children:B}),t[36]=P,t[37]=z,t[38]=F,t[39]=U,t[40]=O,t[41]=B,t[42]=N):N=t[42],N});const styles=StyleSheet.create({root:{flex:1},fallback:{flex:1,justifyContent:"center",alignItems:"center",padding:24},art:{width:144,height:104,marginBottom:24},tile:{position:"absolute",width:54,height:54,borderRadius:14,borderWidth:2,borderColor:"#ffffff55"},spinner:{marginTop:20},title:{fontSize:24,fontWeight:"600",textAlign:"center"},label:{fontSize:16,marginTop:12,textAlign:"center"},retry:{marginTop:20,paddingHorizontal:20,paddingVertical:12,borderRadius:12}});function _temp(){}
@@ -1 +1 @@
1
- "use strict";import{memo,useEffect,useRef,useState}from"react";import{AccessibilityInfo,Animated,Platform,StyleSheet,View}from"react-native";import{jsx as _0xaad5c9,jsxs as _0x348c1a}from"react/jsx-runtime";export const GameLoadingTransition=memo(function({ready:e,loader:t,children:i}){const[a,n]=useState(!e),r=useRef(new Animated.Value(1)).current;return useEffect(()=>{if(!e)return r.setValue(1),void n(!0);if(!a)return;let t,i=!0,s=0;return AccessibilityInfo.isReduceMotionEnabled().catch(()=>!1).then(e=>{i&&(s=requestAnimationFrame(()=>{s=requestAnimationFrame(()=>{i&&(t=Animated.timing(r,{toValue:0,duration:e?0:160,useNativeDriver:"web"!==Platform.OS}),t.start(({finished:e})=>{i&&e&&n(!1)}))})}))}),()=>{i=!1,cancelAnimationFrame(s),t?.stop()}},[e,a,r]),_0x348c1a(View,{style:styles.root,children:[e&&i,(a||!e)&&_0xaad5c9(Animated.View,{pointerEvents:e?"none":"auto",accessibilityElementsHidden:e,importantForAccessibility:e?"no-hide-descendants":"auto",style:[StyleSheet.absoluteFill,{opacity:e?r:1}],children:t})]})});const styles=StyleSheet.create({root:{flex:1}});
1
+ "use strict";import{memo,useEffect,useRef,useState}from"react";import{AccessibilityInfo,Animated,Platform,StyleSheet,View}from"react-native";import{jsx as _0x4a3a00,jsxs as _0x4b5f0e}from"react/jsx-runtime";export const GameLoadingTransition=memo(function({ready:e,loader:t,children:i}){const[n,a]=useState(!e),r=useRef(new Animated.Value(1)).current;return useEffect(()=>{if(!e)return r.setValue(1),void a(!0);if(!n)return;let t,i=!0,s=0;return AccessibilityInfo.isReduceMotionEnabled().catch(()=>!1).then(e=>{i&&(s=requestAnimationFrame(()=>{s=requestAnimationFrame(()=>{i&&(t=Animated.timing(r,{toValue:0,duration:e?0:160,useNativeDriver:"web"!==Platform.OS}),t.start(({finished:e})=>{i&&e&&a(!1)}))})}))}),()=>{i=!1,cancelAnimationFrame(s),t?.stop()}},[e,n,r]),_0x4b5f0e(View,{style:styles.root,children:[e&&i,(n||!e)&&_0x4a3a00(Animated.View,{pointerEvents:e?"none":"auto",accessibilityElementsHidden:e,importantForAccessibility:e?"no-hide-descendants":"auto",style:[StyleSheet.absoluteFill,{opacity:e?r:1}],children:t})]})});const styles=StyleSheet.create({root:{flex:1}});
@@ -1 +1 @@
1
- "use strict";import{HapticType}from"../../services/HapticsService.js";import{GAME_SOUNDS}from"../../services/SoundsService.js";import{GAME_IDS,isTablet}from"../../services/UtilsService.js";import{engineGame,EngineGameScreen}from"../shared/EngineGameScreen.js";import{timerColumn}from"../shared/EngineHud.js";import{useEngineGame}from"../shared/useEngineGame.js";import{useLiveState}from"../shared/useLiveState.js";import{GAME_DURATION,getLayout,LIGHT}from"./SlidingNumbersConstants.js";import{createGame,dispose,drag,newBoard,setLayout,setTheme,start,stop,tick}from"./SlidingNumbersGame.js";import{jsx as _0x4441e2}from"react/jsx-runtime";const SOUNDS=GAME_SOUNDS.SLIDING_NUMBERS;export const SlidingNumbers=engineGame(GAME_IDS.SLIDING_NUMBERS,e=>{const[t,s]=useLiveState(GAME_DURATION),{game:r,theme:i,status:o,screen:a,gameOver:m}=useEngineGame(e,{gameId:GAME_IDS.SLIDING_NUMBERS,create:createGame,start:start,reset:stop,replay:newBoard,dispose:dispose,tick:tick,setTheme:setTheme,resize:(e,t,s,r)=>{const i=getLayout(t,s,r,isTablet);return setLayout(e,i),i.size+2*i.pad},drag:drag,sounds:SOUNDS,onStart:e=>e(SOUNDS.START),wire:(e,t)=>{e.onTime=s,e.onEvent=e=>{"blocked"===e?t(SOUNDS.BLOCKED,HapticType.WARNING):"move"===e?t(SOUNDS.MOVE,HapticType.LIGHT):"win"===e?t(SOUNDS.WIN):"lose"===e&&t(SOUNDS.GAME_OVER)}}});return _0x4441e2(EngineGameScreen,{...a,light:LIGHT,columns:[timerColumn(t,i)],subtext:"Slide tiles to solve!",gameOver:m({title:"win"===o?"SOLVED!":"TIME UP!",message:"win"===o?"Puzzle completed!":"You ran out of time!",scoreLabel:"Score",score:r.score,buttonText:"win"===o?"Play Again!":"Try Again!"})})});
1
+ "use strict";import{HapticType}from"../../services/HapticsService.js";import{GAME_SOUNDS}from"../../services/SoundsService.js";import{GAME_IDS,isTablet}from"../../services/UtilsService.js";import{engineGame,EngineGameScreen}from"../shared/EngineGameScreen.js";import{timerColumn}from"../shared/EngineHud.js";import{useEngineGame}from"../shared/useEngineGame.js";import{useLiveState}from"../shared/useLiveState.js";import{GAME_DURATION,getLayout,LIGHT}from"./SlidingNumbersConstants.js";import{createGame,dispose,drag,newBoard,setLayout,setTheme,start,stop,tick}from"./SlidingNumbersGame.js";import{jsx as _0x11f3b1}from"react/jsx-runtime";const SOUNDS=GAME_SOUNDS.SLIDING_NUMBERS;export const SlidingNumbers=engineGame(GAME_IDS.SLIDING_NUMBERS,e=>{const[t,s]=useLiveState(GAME_DURATION),{game:r,theme:i,status:o,screen:a,gameOver:m}=useEngineGame(e,{gameId:GAME_IDS.SLIDING_NUMBERS,create:createGame,start:start,reset:stop,replay:newBoard,dispose:dispose,tick:tick,setTheme:setTheme,resize:(e,t,s,r)=>{const i=getLayout(t,s,r,isTablet);return setLayout(e,i),i.size+2*i.pad},drag:drag,sounds:SOUNDS,onStart:e=>e(SOUNDS.START),wire:(e,t)=>{e.onTime=s,e.onEvent=e=>{"blocked"===e?t(SOUNDS.BLOCKED,HapticType.WARNING):"move"===e?t(SOUNDS.MOVE,HapticType.LIGHT):"win"===e?t(SOUNDS.WIN):"lose"===e&&t(SOUNDS.GAME_OVER)}}});return _0x11f3b1(EngineGameScreen,{...a,light:LIGHT,columns:[timerColumn(t,i)],subtext:"Slide tiles to solve!",gameOver:m({title:"win"===o?"SOLVED!":"TIME UP!",message:"win"===o?"Puzzle completed!":"You ran out of time!",scoreLabel:"Score",score:r.score,buttonText:"win"===o?"Play Again!":"Try Again!"})})});