@zylem/game-lib 0.4.0 → 0.5.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 (484) hide show
  1. package/dist/.vite/manifest.json +52 -13
  2. package/dist/examples/00-readme-example.d.ts +2 -0
  3. package/dist/examples/00-readme-example.d.ts.map +1 -0
  4. package/dist/examples/01-basic.d.ts +2 -0
  5. package/dist/examples/01-basic.d.ts.map +1 -0
  6. package/dist/examples/01.1-basic-ball.d.ts +9 -0
  7. package/dist/examples/01.1-basic-ball.d.ts.map +1 -0
  8. package/dist/examples/01.2-ricochet-test.d.ts +2 -0
  9. package/dist/examples/01.2-ricochet-test.d.ts.map +1 -0
  10. package/dist/examples/01.3-rect.d.ts +2 -0
  11. package/dist/examples/01.3-rect.d.ts.map +1 -0
  12. package/dist/examples/02-input.d.ts +2 -0
  13. package/dist/examples/02-input.d.ts.map +1 -0
  14. package/dist/examples/03-stage-test/03-stage-test.d.ts +2 -0
  15. package/dist/examples/03-stage-test/03-stage-test.d.ts.map +1 -0
  16. package/dist/examples/03-stage-test/stage0.d.ts +2 -0
  17. package/dist/examples/03-stage-test/stage0.d.ts.map +1 -0
  18. package/dist/examples/03-stage-test/stage1.d.ts +2 -0
  19. package/dist/examples/03-stage-test/stage1.d.ts.map +1 -0
  20. package/dist/examples/03-stage-test/stage2.d.ts +2 -0
  21. package/dist/examples/03-stage-test/stage2.d.ts.map +1 -0
  22. package/dist/examples/03-stage-test/stage3.d.ts +2 -0
  23. package/dist/examples/03-stage-test/stage3.d.ts.map +1 -0
  24. package/dist/examples/03.1-stage-variable.d.ts +2 -0
  25. package/dist/examples/03.1-stage-variable.d.ts.map +1 -0
  26. package/dist/examples/04-vessel-test.d.ts +18 -0
  27. package/dist/examples/04-vessel-test.d.ts.map +1 -0
  28. package/dist/examples/05-camera-test.d.ts +2 -0
  29. package/dist/examples/05-camera-test.d.ts.map +1 -0
  30. package/dist/examples/06-entity-test.d.ts +2 -0
  31. package/dist/examples/06-entity-test.d.ts.map +1 -0
  32. package/dist/examples/07-behaviors.d.ts +2 -0
  33. package/dist/examples/07-behaviors.d.ts.map +1 -0
  34. package/dist/examples/07.01-behavior-context.d.ts +2 -0
  35. package/dist/examples/07.01-behavior-context.d.ts.map +1 -0
  36. package/dist/examples/08-pong.d.ts +2 -0
  37. package/dist/examples/08-pong.d.ts.map +1 -0
  38. package/dist/examples/08.01-breakout.d.ts +2 -0
  39. package/dist/examples/08.01-breakout.d.ts.map +1 -0
  40. package/dist/examples/09-space-invaders.d.ts +2 -0
  41. package/dist/examples/09-space-invaders.d.ts.map +1 -0
  42. package/dist/examples/10-asteroids.d.ts +2 -0
  43. package/dist/examples/10-asteroids.d.ts.map +1 -0
  44. package/dist/examples/11-2d-platformer.d.ts +2 -0
  45. package/dist/examples/11-2d-platformer.d.ts.map +1 -0
  46. package/dist/examples/12-3d-platformer.d.ts +2 -0
  47. package/dist/examples/12-3d-platformer.d.ts.map +1 -0
  48. package/dist/examples/13-fps.d.ts +2 -0
  49. package/dist/examples/13-fps.d.ts.map +1 -0
  50. package/dist/examples/14-strategy.d.ts +2 -0
  51. package/dist/examples/14-strategy.d.ts.map +1 -0
  52. package/dist/examples/15-zylem-planet-demo.d.ts +2 -0
  53. package/dist/examples/15-zylem-planet-demo.d.ts.map +1 -0
  54. package/dist/examples/16-timbotron.d.ts +2 -0
  55. package/dist/examples/16-timbotron.d.ts.map +1 -0
  56. package/dist/examples/17-stress-test.d.ts +2 -0
  57. package/dist/examples/17-stress-test.d.ts.map +1 -0
  58. package/dist/examples/architecture-test.d.ts +2 -0
  59. package/dist/examples/architecture-test.d.ts.map +1 -0
  60. package/dist/examples/utils.d.ts +10 -0
  61. package/dist/examples/utils.d.ts.map +1 -0
  62. package/dist/lib/core/base-node.js +0 -1
  63. package/dist/lib/core/entity-asset-loader.js +1 -4
  64. package/dist/lib/core/preset-shader.js +1 -5
  65. package/dist/lib/core/vessel.js +0 -1
  66. package/dist/lib/entities/actor.js +0 -3
  67. package/dist/lib/entities/delegates/debug.js +1 -2
  68. package/dist/lib/entities/entity-factory.js +24 -0
  69. package/dist/lib/entities/entity.js +1 -0
  70. package/dist/lib/entities/sprite.js +46 -39
  71. package/dist/lib/game/game-config.js +0 -1
  72. package/dist/lib/game/game-default.js +1 -2
  73. package/dist/lib/game/game-retro-resolutions.js +0 -1
  74. package/dist/lib/game/game.js +45 -23
  75. package/dist/lib/game/zylem-game.js +1 -2
  76. package/dist/lib/stage/stage-default.js +18 -28
  77. package/dist/lib/stage/stage-factory.js +22 -0
  78. package/dist/lib/stage/stage-manager.js +49 -0
  79. package/dist/lib/stage/stage.js +29 -22
  80. package/dist/lib/stage/zylem-stage.js +0 -1
  81. package/dist/main.js +12 -12
  82. package/dist/node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js +34 -0
  83. package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/pack.js +520 -0
  84. package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/unpack.js +672 -0
  85. package/dist/src/api/actions.d.ts.map +1 -0
  86. package/dist/src/api/behaviors.d.ts.map +1 -0
  87. package/dist/src/api/camera.d.ts.map +1 -0
  88. package/dist/src/api/core.d.ts.map +1 -0
  89. package/dist/src/api/entities.d.ts.map +1 -0
  90. package/dist/{api → src/api}/main.d.ts +1 -1
  91. package/dist/src/api/main.d.ts.map +1 -0
  92. package/dist/src/api/stage.d.ts +5 -0
  93. package/dist/src/api/stage.d.ts.map +1 -0
  94. package/dist/src/lib/actions/behaviors/actions.d.ts.map +1 -0
  95. package/dist/src/lib/actions/behaviors/behavior.d.ts.map +1 -0
  96. package/dist/src/lib/actions/behaviors/boundaries/boundary.d.ts.map +1 -0
  97. package/dist/src/lib/actions/behaviors/character-controller.d.ts.map +1 -0
  98. package/dist/src/lib/actions/behaviors/debug/debug-collision.d.ts.map +1 -0
  99. package/dist/src/lib/actions/behaviors/debug/debug-update.d.ts.map +1 -0
  100. package/dist/src/lib/actions/behaviors/debug/debug.d.ts.map +1 -0
  101. package/dist/src/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +1 -0
  102. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +1 -0
  103. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +1 -0
  104. package/dist/src/lib/actions/behaviors/ricochet/ricochet.d.ts.map +1 -0
  105. package/dist/src/lib/actions/behaviors/zylem-behavior.d.ts.map +1 -0
  106. package/dist/src/lib/actions/capabilities/moveable.d.ts.map +1 -0
  107. package/dist/src/lib/actions/capabilities/rotatable.d.ts.map +1 -0
  108. package/dist/src/lib/actions/capabilities/transformable.d.ts.map +1 -0
  109. package/dist/src/lib/actions/global-change.d.ts.map +1 -0
  110. package/dist/src/lib/camera/camera.d.ts.map +1 -0
  111. package/dist/src/lib/camera/fixed-2d.d.ts.map +1 -0
  112. package/dist/src/lib/camera/perspective.d.ts.map +1 -0
  113. package/dist/{lib → src/lib}/camera/third-person.d.ts +0 -8
  114. package/dist/src/lib/camera/third-person.d.ts.map +1 -0
  115. package/dist/src/lib/camera/zylem-camera.d.ts.map +1 -0
  116. package/dist/{lib → src/lib}/collision/collision-builder.d.ts +0 -5
  117. package/dist/src/lib/collision/collision-builder.d.ts.map +1 -0
  118. package/dist/src/lib/collision/collision-delegate.d.ts +6 -0
  119. package/dist/src/lib/collision/collision-delegate.d.ts.map +1 -0
  120. package/dist/src/lib/collision/collision-group.d.ts.map +1 -0
  121. package/dist/src/lib/collision/collision-mask.d.ts.map +1 -0
  122. package/dist/{lib → src/lib}/collision/collision.d.ts +0 -9
  123. package/dist/src/lib/collision/collision.d.ts.map +1 -0
  124. package/dist/src/lib/collision/utils.d.ts.map +1 -0
  125. package/dist/src/lib/collision/world.d.ts.map +1 -0
  126. package/dist/src/lib/core/asset-manager.d.ts.map +1 -0
  127. package/dist/src/lib/core/base-node-life-cycle.d.ts +54 -0
  128. package/dist/src/lib/core/base-node-life-cycle.d.ts.map +1 -0
  129. package/dist/{lib → src/lib}/core/base-node.d.ts +9 -10
  130. package/dist/src/lib/core/base-node.d.ts.map +1 -0
  131. package/dist/src/lib/core/blueprints.d.ts +22 -0
  132. package/dist/src/lib/core/blueprints.d.ts.map +1 -0
  133. package/dist/src/lib/core/entity-asset-loader.d.ts +16 -0
  134. package/dist/src/lib/core/entity-asset-loader.d.ts.map +1 -0
  135. package/dist/src/lib/core/errors.d.ts.map +1 -0
  136. package/dist/src/lib/core/flags.d.ts.map +1 -0
  137. package/dist/src/lib/core/index.d.ts.map +1 -0
  138. package/dist/src/lib/core/interfaces.d.ts +25 -0
  139. package/dist/src/lib/core/interfaces.d.ts.map +1 -0
  140. package/dist/src/lib/core/lazy-loader.d.ts.map +1 -0
  141. package/dist/src/lib/core/lifecycle-base.d.ts.map +1 -0
  142. package/dist/src/lib/core/node-interface.d.ts +12 -0
  143. package/dist/src/lib/core/node-interface.d.ts.map +1 -0
  144. package/dist/src/lib/core/preset-shader.d.ts +8 -0
  145. package/dist/src/lib/core/preset-shader.d.ts.map +1 -0
  146. package/dist/{lib → src/lib}/core/three-addons/Timer.d.ts +1 -16
  147. package/dist/src/lib/core/three-addons/Timer.d.ts.map +1 -0
  148. package/dist/src/lib/core/utility/nodes.d.ts.map +1 -0
  149. package/dist/src/lib/core/utility/strings.d.ts.map +1 -0
  150. package/dist/src/lib/core/utility/vector.d.ts +8 -0
  151. package/dist/src/lib/core/utility/vector.d.ts.map +1 -0
  152. package/dist/src/lib/core/vector.d.ts.map +1 -0
  153. package/dist/{lib → src/lib}/core/vessel.d.ts +0 -1
  154. package/dist/src/lib/core/vessel.d.ts.map +1 -0
  155. package/dist/src/lib/debug/console/console-state.d.ts.map +1 -0
  156. package/dist/src/lib/debug/console/console-store.d.ts.map +1 -0
  157. package/dist/{lib → src/lib}/debug/debug-state.d.ts +1 -7
  158. package/dist/src/lib/debug/debug-state.d.ts.map +1 -0
  159. package/dist/src/lib/debug/debug-store.d.ts.map +1 -0
  160. package/dist/src/lib/debug/state-based-debug-loader.d.ts.map +1 -0
  161. package/dist/src/lib/device/aspect-ratio.d.ts.map +1 -0
  162. package/dist/{lib → src/lib}/device/desktop.d.ts.map +1 -1
  163. package/dist/src/lib/device/mobile.d.ts.map +1 -0
  164. package/dist/{lib → src/lib}/device/tablet.d.ts.map +1 -1
  165. package/dist/{lib → src/lib}/entities/actor.d.ts +1 -15
  166. package/dist/src/lib/entities/actor.d.ts.map +1 -0
  167. package/dist/src/lib/entities/box.d.ts.map +1 -0
  168. package/dist/src/lib/entities/builder.d.ts.map +1 -0
  169. package/dist/src/lib/entities/create.d.ts.map +1 -0
  170. package/dist/src/lib/entities/delegates/animation.d.ts.map +1 -0
  171. package/dist/{lib → src/lib}/entities/delegates/debug.d.ts +1 -10
  172. package/dist/src/lib/entities/delegates/debug.d.ts.map +1 -0
  173. package/dist/src/lib/entities/delegates/loader.d.ts.map +1 -0
  174. package/dist/src/lib/entities/destroy.d.ts.map +1 -0
  175. package/dist/src/lib/entities/entity-factory.d.ts +10 -0
  176. package/dist/src/lib/entities/entity-factory.d.ts.map +1 -0
  177. package/dist/{lib → src/lib}/entities/entity.d.ts +2 -5
  178. package/dist/src/lib/entities/entity.d.ts.map +1 -0
  179. package/dist/{lib → src/lib}/entities/index.d.ts +1 -1
  180. package/dist/src/lib/entities/index.d.ts.map +1 -0
  181. package/dist/src/lib/entities/plane.d.ts.map +1 -0
  182. package/dist/src/lib/entities/rect.d.ts.map +1 -0
  183. package/dist/src/lib/entities/sphere.d.ts.map +1 -0
  184. package/dist/{lib → src/lib}/entities/sprite.d.ts +1 -0
  185. package/dist/src/lib/entities/sprite.d.ts.map +1 -0
  186. package/dist/src/lib/entities/text.d.ts.map +1 -0
  187. package/dist/src/lib/entities/zone.d.ts.map +1 -0
  188. package/dist/src/lib/game/game-blueprint.d.ts.map +1 -0
  189. package/dist/src/lib/game/game-canvas.d.ts.map +1 -0
  190. package/dist/{lib → src/lib}/game/game-config.d.ts +0 -4
  191. package/dist/src/lib/game/game-config.d.ts.map +1 -0
  192. package/dist/src/lib/game/game-default.d.ts +14 -0
  193. package/dist/src/lib/game/game-default.d.ts.map +1 -0
  194. package/dist/src/lib/game/game-interfaces.d.ts.map +1 -0
  195. package/dist/{lib → src/lib}/game/game-retro-resolutions.d.ts +2 -1
  196. package/dist/src/lib/game/game-retro-resolutions.d.ts.map +1 -0
  197. package/dist/src/lib/game/game-state.d.ts.map +1 -0
  198. package/dist/{lib → src/lib}/game/game.d.ts +4 -2
  199. package/dist/src/lib/game/game.d.ts.map +1 -0
  200. package/dist/{lib → src/lib}/game/zylem-game.d.ts +1 -1
  201. package/dist/src/lib/game/zylem-game.d.ts.map +1 -0
  202. package/dist/src/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +1 -0
  203. package/dist/src/lib/graphics/material.d.ts.map +1 -0
  204. package/dist/src/lib/graphics/mesh.d.ts.map +1 -0
  205. package/dist/src/lib/graphics/render-pass.d.ts.map +1 -0
  206. package/dist/src/lib/graphics/zylem-scene.d.ts.map +1 -0
  207. package/dist/src/lib/input/gamepad-provider.d.ts.map +1 -0
  208. package/dist/src/lib/input/input-manager.d.ts.map +1 -0
  209. package/dist/src/lib/input/input-provider.d.ts.map +1 -0
  210. package/dist/{lib → src/lib}/input/input.d.ts +0 -4
  211. package/dist/src/lib/input/input.d.ts.map +1 -0
  212. package/dist/src/lib/input/keyboard-provider.d.ts.map +1 -0
  213. package/dist/{lib → src/lib}/interfaces/entity.d.ts +0 -6
  214. package/dist/src/lib/interfaces/entity.d.ts.map +1 -0
  215. package/dist/src/lib/sounds/index.d.ts.map +1 -0
  216. package/dist/src/lib/sounds/ping-pong-sound.d.ts.map +1 -0
  217. package/dist/src/lib/sounds/ricochet-sound.d.ts.map +1 -0
  218. package/dist/src/lib/stage/debug-entity-cursor.d.ts.map +1 -0
  219. package/dist/src/lib/stage/entity-spawner.d.ts.map +1 -0
  220. package/dist/src/lib/stage/stage-camera-debug-delegate.d.ts.map +1 -0
  221. package/dist/src/lib/stage/stage-debug-delegate.d.ts.map +1 -0
  222. package/dist/src/lib/stage/stage-default.d.ts +3 -0
  223. package/dist/src/lib/stage/stage-default.d.ts.map +1 -0
  224. package/dist/src/lib/stage/stage-factory.d.ts +6 -0
  225. package/dist/src/lib/stage/stage-factory.d.ts.map +1 -0
  226. package/dist/src/lib/stage/stage-manager.d.ts +30 -0
  227. package/dist/src/lib/stage/stage-manager.d.ts.map +1 -0
  228. package/dist/{lib → src/lib}/stage/stage-state.d.ts +1 -4
  229. package/dist/src/lib/stage/stage-state.d.ts.map +1 -0
  230. package/dist/{lib → src/lib}/stage/stage.d.ts +3 -1
  231. package/dist/src/lib/stage/stage.d.ts.map +1 -0
  232. package/dist/{lib → src/lib}/stage/zylem-stage.d.ts +0 -1
  233. package/dist/src/lib/stage/zylem-stage.d.ts.map +1 -0
  234. package/dist/src/lib/systems/test-system.d.ts.map +1 -0
  235. package/dist/src/lib/systems/transformable.system.d.ts.map +1 -0
  236. package/dist/{lib → src/lib}/types/entity-types.d.ts +0 -15
  237. package/dist/src/lib/types/entity-types.d.ts.map +1 -0
  238. package/dist/src/lib/types/index.d.ts.map +1 -0
  239. package/dist/{lib → src/lib}/types/stage-types.d.ts +0 -9
  240. package/dist/src/lib/types/stage-types.d.ts.map +1 -0
  241. package/dist/src/lib/ui/Debug.d.ts +6 -0
  242. package/dist/src/lib/ui/Debug.d.ts.map +1 -0
  243. package/dist/src/lib/ui/console/Console.d.ts.map +1 -0
  244. package/dist/src/lib/ui/debug-panel/AccordionMenu.d.ts.map +1 -0
  245. package/dist/src/lib/ui/debug-panel/Menu.d.ts.map +1 -0
  246. package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts +4 -0
  247. package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +1 -0
  248. package/dist/src/lib/ui/debug-panel/sections/GameSection.d.ts.map +1 -0
  249. package/dist/src/lib/ui/debug-panel/sections/StagesSection.d.ts.map +1 -0
  250. package/dist/src/lib/ui/debug-panel/sections/all.d.ts.map +1 -0
  251. package/dist/src/lib/ui/toolbar/Toolbar.d.ts.map +1 -0
  252. package/dist/stage.js +4 -20
  253. package/dist/tests/e2e/basic-game.spec.d.ts +2 -0
  254. package/dist/tests/e2e/basic-game.spec.d.ts.map +1 -0
  255. package/dist/tests/integration/debug.sim.spec.d.ts +2 -0
  256. package/dist/tests/integration/debug.sim.spec.d.ts.map +1 -0
  257. package/dist/tests/unit/collision/collision.spec.d.ts.map +1 -1
  258. package/dist/tests/unit/core/base-node.spec.d.ts +2 -0
  259. package/dist/tests/unit/core/base-node.spec.d.ts.map +1 -0
  260. package/dist/tests/unit/core/game.spec.d.ts.map +1 -1
  261. package/dist/tests/unit/core/stage.spec.d.ts.map +1 -1
  262. package/dist/tests/unit/core/vessel.spec.d.ts.map +1 -1
  263. package/package.json +24 -42
  264. package/dist/api/actions.d.ts.map +0 -1
  265. package/dist/api/behaviors.d.ts.map +0 -1
  266. package/dist/api/camera.d.ts.map +0 -1
  267. package/dist/api/core.d.ts.map +0 -1
  268. package/dist/api/entities.d.ts.map +0 -1
  269. package/dist/api/main.d.ts.map +0 -1
  270. package/dist/api/stage.d.ts +0 -7
  271. package/dist/api/stage.d.ts.map +0 -1
  272. package/dist/lib/actions/behaviors/actions.d.ts.map +0 -1
  273. package/dist/lib/actions/behaviors/behavior.d.ts.map +0 -1
  274. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts.map +0 -1
  275. package/dist/lib/actions/behaviors/character-controller.d.ts.map +0 -1
  276. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts.map +0 -1
  277. package/dist/lib/actions/behaviors/debug/debug-update.d.ts.map +0 -1
  278. package/dist/lib/actions/behaviors/debug/debug.d.ts.map +0 -1
  279. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +0 -1
  280. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +0 -1
  281. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +0 -1
  282. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts.map +0 -1
  283. package/dist/lib/actions/behaviors/zylem-behavior.d.ts.map +0 -1
  284. package/dist/lib/actions/capabilities/moveable.d.ts.map +0 -1
  285. package/dist/lib/actions/capabilities/rotatable.d.ts.map +0 -1
  286. package/dist/lib/actions/capabilities/transformable.d.ts.map +0 -1
  287. package/dist/lib/actions/global-change.d.ts.map +0 -1
  288. package/dist/lib/camera/camera.d.ts.map +0 -1
  289. package/dist/lib/camera/fixed-2d.d.ts.map +0 -1
  290. package/dist/lib/camera/perspective.d.ts.map +0 -1
  291. package/dist/lib/camera/third-person.d.ts.map +0 -1
  292. package/dist/lib/camera/zylem-camera.d.ts.map +0 -1
  293. package/dist/lib/collision/collision-builder.d.ts.map +0 -1
  294. package/dist/lib/collision/collision-delegate.d.ts +0 -12
  295. package/dist/lib/collision/collision-delegate.d.ts.map +0 -1
  296. package/dist/lib/collision/collision-group.d.ts.map +0 -1
  297. package/dist/lib/collision/collision-mask.d.ts.map +0 -1
  298. package/dist/lib/collision/collision.d.ts.map +0 -1
  299. package/dist/lib/collision/utils.d.ts.map +0 -1
  300. package/dist/lib/collision/world.d.ts.map +0 -1
  301. package/dist/lib/core/asset-manager.d.ts.map +0 -1
  302. package/dist/lib/core/base-node-life-cycle.d.ts +0 -68
  303. package/dist/lib/core/base-node-life-cycle.d.ts.map +0 -1
  304. package/dist/lib/core/base-node.d.ts.map +0 -1
  305. package/dist/lib/core/entity-asset-loader.d.ts +0 -30
  306. package/dist/lib/core/entity-asset-loader.d.ts.map +0 -1
  307. package/dist/lib/core/errors.d.ts.map +0 -1
  308. package/dist/lib/core/flags.d.ts.map +0 -1
  309. package/dist/lib/core/index.d.ts.map +0 -1
  310. package/dist/lib/core/lazy-loader.d.ts.map +0 -1
  311. package/dist/lib/core/lifecycle-base.d.ts.map +0 -1
  312. package/dist/lib/core/preset-shader.d.ts +0 -12
  313. package/dist/lib/core/preset-shader.d.ts.map +0 -1
  314. package/dist/lib/core/three-addons/Timer.d.ts.map +0 -1
  315. package/dist/lib/core/utility/nodes.d.ts.map +0 -1
  316. package/dist/lib/core/utility/strings.d.ts.map +0 -1
  317. package/dist/lib/core/utility/vector.d.ts +0 -14
  318. package/dist/lib/core/utility/vector.d.ts.map +0 -1
  319. package/dist/lib/core/vector.d.ts.map +0 -1
  320. package/dist/lib/core/vessel.d.ts.map +0 -1
  321. package/dist/lib/debug/console/console-state.d.ts.map +0 -1
  322. package/dist/lib/debug/console/console-store.d.ts.map +0 -1
  323. package/dist/lib/debug/debug-state.d.ts.map +0 -1
  324. package/dist/lib/debug/debug-store.d.ts.map +0 -1
  325. package/dist/lib/debug/state-based-debug-loader.d.ts.map +0 -1
  326. package/dist/lib/device/aspect-ratio.d.ts.map +0 -1
  327. package/dist/lib/device/mobile.d.ts.map +0 -1
  328. package/dist/lib/entities/actor.d.ts.map +0 -1
  329. package/dist/lib/entities/box.d.ts.map +0 -1
  330. package/dist/lib/entities/builder.d.ts.map +0 -1
  331. package/dist/lib/entities/create.d.ts.map +0 -1
  332. package/dist/lib/entities/delegates/animation.d.ts.map +0 -1
  333. package/dist/lib/entities/delegates/debug.d.ts.map +0 -1
  334. package/dist/lib/entities/delegates/loader.d.ts.map +0 -1
  335. package/dist/lib/entities/destroy.d.ts.map +0 -1
  336. package/dist/lib/entities/entity.d.ts.map +0 -1
  337. package/dist/lib/entities/index.d.ts.map +0 -1
  338. package/dist/lib/entities/plane.d.ts.map +0 -1
  339. package/dist/lib/entities/rect.d.ts.map +0 -1
  340. package/dist/lib/entities/sphere.d.ts.map +0 -1
  341. package/dist/lib/entities/sprite.d.ts.map +0 -1
  342. package/dist/lib/entities/text.d.ts.map +0 -1
  343. package/dist/lib/entities/zone.d.ts.map +0 -1
  344. package/dist/lib/game/game-blueprint.d.ts.map +0 -1
  345. package/dist/lib/game/game-canvas.d.ts.map +0 -1
  346. package/dist/lib/game/game-config.d.ts.map +0 -1
  347. package/dist/lib/game/game-default.d.ts +0 -19
  348. package/dist/lib/game/game-default.d.ts.map +0 -1
  349. package/dist/lib/game/game-interfaces.d.ts.map +0 -1
  350. package/dist/lib/game/game-retro-resolutions.d.ts.map +0 -1
  351. package/dist/lib/game/game-state.d.ts.map +0 -1
  352. package/dist/lib/game/game.d.ts.map +0 -1
  353. package/dist/lib/game/zylem-game.d.ts.map +0 -1
  354. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +0 -1
  355. package/dist/lib/graphics/material.d.ts.map +0 -1
  356. package/dist/lib/graphics/mesh.d.ts.map +0 -1
  357. package/dist/lib/graphics/render-pass.d.ts.map +0 -1
  358. package/dist/lib/graphics/zylem-scene.d.ts.map +0 -1
  359. package/dist/lib/input/gamepad-provider.d.ts.map +0 -1
  360. package/dist/lib/input/input-manager.d.ts.map +0 -1
  361. package/dist/lib/input/input-provider.d.ts.map +0 -1
  362. package/dist/lib/input/input.d.ts.map +0 -1
  363. package/dist/lib/input/keyboard-provider.d.ts.map +0 -1
  364. package/dist/lib/interfaces/entity.d.ts.map +0 -1
  365. package/dist/lib/sounds/index.d.ts.map +0 -1
  366. package/dist/lib/sounds/ping-pong-sound.d.ts.map +0 -1
  367. package/dist/lib/sounds/ricochet-sound.d.ts.map +0 -1
  368. package/dist/lib/stage/debug-entity-cursor.d.ts.map +0 -1
  369. package/dist/lib/stage/entity-spawner.d.ts.map +0 -1
  370. package/dist/lib/stage/stage-blueprint.d.ts +0 -45
  371. package/dist/lib/stage/stage-blueprint.d.ts.map +0 -1
  372. package/dist/lib/stage/stage-blueprint.js +0 -56
  373. package/dist/lib/stage/stage-camera-debug-delegate.d.ts.map +0 -1
  374. package/dist/lib/stage/stage-debug-delegate.d.ts.map +0 -1
  375. package/dist/lib/stage/stage-default.d.ts +0 -10
  376. package/dist/lib/stage/stage-default.d.ts.map +0 -1
  377. package/dist/lib/stage/stage-state.d.ts.map +0 -1
  378. package/dist/lib/stage/stage.d.ts.map +0 -1
  379. package/dist/lib/stage/zylem-stage.d.ts.map +0 -1
  380. package/dist/lib/systems/test-system.d.ts.map +0 -1
  381. package/dist/lib/systems/transformable.system.d.ts.map +0 -1
  382. package/dist/lib/types/entity-types.d.ts.map +0 -1
  383. package/dist/lib/types/index.d.ts.map +0 -1
  384. package/dist/lib/types/stage-types.d.ts.map +0 -1
  385. package/dist/lib/ui/Debug.d.ts +0 -2
  386. package/dist/lib/ui/Debug.d.ts.map +0 -1
  387. package/dist/lib/ui/console/Console.d.ts.map +0 -1
  388. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts.map +0 -1
  389. package/dist/lib/ui/debug-panel/Menu.d.ts.map +0 -1
  390. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +0 -12
  391. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +0 -1
  392. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts.map +0 -1
  393. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts.map +0 -1
  394. package/dist/lib/ui/debug-panel/sections/all.d.ts.map +0 -1
  395. package/dist/lib/ui/toolbar/Toolbar.d.ts.map +0 -1
  396. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts +0 -2
  397. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts.map +0 -1
  398. /package/dist/{api → src/api}/actions.d.ts +0 -0
  399. /package/dist/{api → src/api}/behaviors.d.ts +0 -0
  400. /package/dist/{api → src/api}/camera.d.ts +0 -0
  401. /package/dist/{api → src/api}/core.d.ts +0 -0
  402. /package/dist/{api → src/api}/entities.d.ts +0 -0
  403. /package/dist/{lib → src/lib}/actions/behaviors/actions.d.ts +0 -0
  404. /package/dist/{lib → src/lib}/actions/behaviors/behavior.d.ts +0 -0
  405. /package/dist/{lib → src/lib}/actions/behaviors/boundaries/boundary.d.ts +0 -0
  406. /package/dist/{lib → src/lib}/actions/behaviors/character-controller.d.ts +0 -0
  407. /package/dist/{lib → src/lib}/actions/behaviors/debug/debug-collision.d.ts +0 -0
  408. /package/dist/{lib → src/lib}/actions/behaviors/debug/debug-update.d.ts +0 -0
  409. /package/dist/{lib → src/lib}/actions/behaviors/debug/debug.d.ts +0 -0
  410. /package/dist/{lib → src/lib}/actions/behaviors/movement/movement-sequence-2d.d.ts +0 -0
  411. /package/dist/{lib → src/lib}/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +0 -0
  412. /package/dist/{lib → src/lib}/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +0 -0
  413. /package/dist/{lib → src/lib}/actions/behaviors/ricochet/ricochet.d.ts +0 -0
  414. /package/dist/{lib → src/lib}/actions/behaviors/zylem-behavior.d.ts +0 -0
  415. /package/dist/{lib → src/lib}/actions/capabilities/moveable.d.ts +0 -0
  416. /package/dist/{lib → src/lib}/actions/capabilities/rotatable.d.ts +0 -0
  417. /package/dist/{lib → src/lib}/actions/capabilities/transformable.d.ts +0 -0
  418. /package/dist/{lib → src/lib}/actions/global-change.d.ts +0 -0
  419. /package/dist/{lib → src/lib}/camera/camera.d.ts +0 -0
  420. /package/dist/{lib → src/lib}/camera/fixed-2d.d.ts +0 -0
  421. /package/dist/{lib → src/lib}/camera/perspective.d.ts +0 -0
  422. /package/dist/{lib → src/lib}/camera/zylem-camera.d.ts +0 -0
  423. /package/dist/{lib → src/lib}/collision/collision-group.d.ts +0 -0
  424. /package/dist/{lib → src/lib}/collision/collision-mask.d.ts +0 -0
  425. /package/dist/{lib → src/lib}/collision/utils.d.ts +0 -0
  426. /package/dist/{lib → src/lib}/collision/world.d.ts +0 -0
  427. /package/dist/{lib → src/lib}/core/asset-manager.d.ts +0 -0
  428. /package/dist/{lib → src/lib}/core/errors.d.ts +0 -0
  429. /package/dist/{lib → src/lib}/core/flags.d.ts +0 -0
  430. /package/dist/{lib → src/lib}/core/index.d.ts +0 -0
  431. /package/dist/{lib → src/lib}/core/lazy-loader.d.ts +0 -0
  432. /package/dist/{lib → src/lib}/core/lifecycle-base.d.ts +0 -0
  433. /package/dist/{lib → src/lib}/core/utility/nodes.d.ts +0 -0
  434. /package/dist/{lib → src/lib}/core/utility/strings.d.ts +0 -0
  435. /package/dist/{lib → src/lib}/core/vector.d.ts +0 -0
  436. /package/dist/{lib → src/lib}/debug/console/console-state.d.ts +0 -0
  437. /package/dist/{lib → src/lib}/debug/console/console-store.d.ts +0 -0
  438. /package/dist/{lib → src/lib}/debug/debug-store.d.ts +0 -0
  439. /package/dist/{lib → src/lib}/debug/state-based-debug-loader.d.ts +0 -0
  440. /package/dist/{lib → src/lib}/device/aspect-ratio.d.ts +0 -0
  441. /package/dist/{lib → src/lib}/device/desktop.d.ts +0 -0
  442. /package/dist/{lib → src/lib}/device/mobile.d.ts +0 -0
  443. /package/dist/{lib → src/lib}/device/tablet.d.ts +0 -0
  444. /package/dist/{lib → src/lib}/entities/box.d.ts +0 -0
  445. /package/dist/{lib → src/lib}/entities/builder.d.ts +0 -0
  446. /package/dist/{lib → src/lib}/entities/create.d.ts +0 -0
  447. /package/dist/{lib → src/lib}/entities/delegates/animation.d.ts +0 -0
  448. /package/dist/{lib → src/lib}/entities/delegates/loader.d.ts +0 -0
  449. /package/dist/{lib → src/lib}/entities/destroy.d.ts +0 -0
  450. /package/dist/{lib → src/lib}/entities/plane.d.ts +0 -0
  451. /package/dist/{lib → src/lib}/entities/rect.d.ts +0 -0
  452. /package/dist/{lib → src/lib}/entities/sphere.d.ts +0 -0
  453. /package/dist/{lib → src/lib}/entities/text.d.ts +0 -0
  454. /package/dist/{lib → src/lib}/entities/zone.d.ts +0 -0
  455. /package/dist/{lib → src/lib}/game/game-blueprint.d.ts +0 -0
  456. /package/dist/{lib → src/lib}/game/game-canvas.d.ts +0 -0
  457. /package/dist/{lib → src/lib}/game/game-interfaces.d.ts +0 -0
  458. /package/dist/{lib → src/lib}/game/game-state.d.ts +0 -0
  459. /package/dist/{lib → src/lib}/graphics/geometries/XZPlaneGeometry.d.ts +0 -0
  460. /package/dist/{lib → src/lib}/graphics/material.d.ts +0 -0
  461. /package/dist/{lib → src/lib}/graphics/mesh.d.ts +0 -0
  462. /package/dist/{lib → src/lib}/graphics/render-pass.d.ts +0 -0
  463. /package/dist/{lib → src/lib}/graphics/zylem-scene.d.ts +0 -0
  464. /package/dist/{lib → src/lib}/input/gamepad-provider.d.ts +0 -0
  465. /package/dist/{lib → src/lib}/input/input-manager.d.ts +0 -0
  466. /package/dist/{lib → src/lib}/input/input-provider.d.ts +0 -0
  467. /package/dist/{lib → src/lib}/input/keyboard-provider.d.ts +0 -0
  468. /package/dist/{lib → src/lib}/sounds/index.d.ts +0 -0
  469. /package/dist/{lib → src/lib}/sounds/ping-pong-sound.d.ts +0 -0
  470. /package/dist/{lib → src/lib}/sounds/ricochet-sound.d.ts +0 -0
  471. /package/dist/{lib → src/lib}/stage/debug-entity-cursor.d.ts +0 -0
  472. /package/dist/{lib → src/lib}/stage/entity-spawner.d.ts +0 -0
  473. /package/dist/{lib → src/lib}/stage/stage-camera-debug-delegate.d.ts +0 -0
  474. /package/dist/{lib → src/lib}/stage/stage-debug-delegate.d.ts +0 -0
  475. /package/dist/{lib → src/lib}/systems/test-system.d.ts +0 -0
  476. /package/dist/{lib → src/lib}/systems/transformable.system.d.ts +0 -0
  477. /package/dist/{lib → src/lib}/types/index.d.ts +0 -0
  478. /package/dist/{lib → src/lib}/ui/console/Console.d.ts +0 -0
  479. /package/dist/{lib → src/lib}/ui/debug-panel/AccordionMenu.d.ts +0 -0
  480. /package/dist/{lib → src/lib}/ui/debug-panel/Menu.d.ts +0 -0
  481. /package/dist/{lib → src/lib}/ui/debug-panel/sections/GameSection.d.ts +0 -0
  482. /package/dist/{lib → src/lib}/ui/debug-panel/sections/StagesSection.d.ts +0 -0
  483. /package/dist/{lib → src/lib}/ui/debug-panel/sections/all.d.ts +0 -0
  484. /package/dist/{lib → src/lib}/ui/toolbar/Toolbar.d.ts +0 -0
@@ -73,7 +73,6 @@ function k(t) {
73
73
  }
74
74
  export {
75
75
  f as GameConfig,
76
- B as createDefaultGameConfig,
77
76
  k as gameConfig,
78
77
  C as resolveGameConfig
79
78
  };
@@ -1,5 +1,5 @@
1
1
  import { proxy as i } from "valtio/vanilla";
2
- import { stage as e } from "../stage/stage.js";
2
+ import { createStage as e } from "../stage/stage.js";
3
3
  const a = () => ({
4
4
  id: "zylem",
5
5
  globals: {},
@@ -19,6 +19,5 @@ function g() {
19
19
  };
20
20
  }
21
21
  export {
22
- t as gameDefaultsState,
23
22
  g as getGameDefaultConfig
24
23
  };
@@ -74,7 +74,6 @@ function l(e) {
74
74
  return !Number.isFinite(i) || !Number.isFinite(s) ? null : { width: i, height: s };
75
75
  }
76
76
  export {
77
- n as RetroPresets,
78
77
  h as getDisplayAspect,
79
78
  r as getPresetResolution,
80
79
  l as parseResolution
@@ -1,10 +1,12 @@
1
- import { ZylemGame as n } from "./zylem-game.js";
2
- import { setPaused as o } from "../debug/debug-state.js";
3
- import { getGlobalState as i, setGlobalState as p } from "./game-state.js";
4
- import { hasStages as d, convertNodes as l } from "../core/utility/nodes.js";
5
- import { resolveGameConfig as h } from "./game-config.js";
6
- import { stage as g } from "../stage/stage.js";
7
- class m {
1
+ import { ZylemGame as l } from "./zylem-game.js";
2
+ import { setPaused as n } from "../debug/debug-state.js";
3
+ import { getGlobalState as g, setGlobalState as m } from "./game-state.js";
4
+ import { hasStages as h, convertNodes as c } from "../core/utility/nodes.js";
5
+ import { resolveGameConfig as u } from "./game-config.js";
6
+ import { createStage as G } from "../stage/stage.js";
7
+ import { StageManager as i, stageState as s } from "../stage/stage-manager.js";
8
+ import { StageFactory as p } from "../stage/stage-factory.js";
9
+ class w {
8
10
  wrappedGame = null;
9
11
  pendingGlobalChangeHandlers = [];
10
12
  options;
@@ -16,7 +18,7 @@ class m {
16
18
  };
17
19
  refErrorMessage = "lost reference to game";
18
20
  constructor(e) {
19
- this.options = e, d(e) || this.options.push(g());
21
+ this.options = e, h(e) || this.options.push(G());
20
22
  }
21
23
  async start() {
22
24
  const e = await this.load();
@@ -24,7 +26,7 @@ class m {
24
26
  }
25
27
  async load() {
26
28
  console.log("loading game", this.options);
27
- const e = await l(this.options), a = h(e), t = new n({
29
+ const e = await c(this.options), a = u(e), t = new l({
28
30
  ...e,
29
31
  ...a
30
32
  }, this);
@@ -42,10 +44,10 @@ class m {
42
44
  }
43
45
  }
44
46
  async pause() {
45
- o(!0);
47
+ n(!0);
46
48
  }
47
49
  async resume() {
48
- o(!1), this.wrappedGame && (this.wrappedGame.previousTimeStamp = 0, this.wrappedGame.timer.reset());
50
+ n(!1), this.wrappedGame && (this.wrappedGame.previousTimeStamp = 0, this.wrappedGame.timer.reset());
49
51
  }
50
52
  async reset() {
51
53
  if (!this.wrappedGame) {
@@ -54,26 +56,46 @@ class m {
54
56
  }
55
57
  await this.wrappedGame.loadStage(this.wrappedGame.stages[0]);
56
58
  }
57
- async nextStage() {
59
+ async previousStage() {
58
60
  if (!this.wrappedGame) {
59
61
  console.error(this.refErrorMessage);
60
62
  return;
61
63
  }
62
- const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a + 1];
64
+ const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a - 1];
63
65
  if (!t) {
64
- console.error("next stage called on last stage");
66
+ console.error("previous stage called on first stage");
65
67
  return;
66
68
  }
67
69
  await this.wrappedGame.loadStage(t);
68
70
  }
69
- async previousStage() {
71
+ async loadStageFromId(e) {
70
72
  if (!this.wrappedGame) {
71
73
  console.error(this.refErrorMessage);
72
74
  return;
73
75
  }
74
- const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a - 1];
76
+ try {
77
+ const a = await i.loadStageData(e), t = await p.createFromBlueprint(a);
78
+ await this.wrappedGame.loadStage(t), s.current = a;
79
+ } catch (a) {
80
+ console.error(`Failed to load stage ${e}`, a);
81
+ }
82
+ }
83
+ async nextStage() {
84
+ if (!this.wrappedGame) {
85
+ console.error(this.refErrorMessage);
86
+ return;
87
+ }
88
+ if (s.next) {
89
+ const r = s.next.id;
90
+ if (await i.transitionForward(r), s.current) {
91
+ const d = await p.createFromBlueprint(s.current);
92
+ await this.wrappedGame.loadStage(d);
93
+ return;
94
+ }
95
+ }
96
+ const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a + 1];
75
97
  if (!t) {
76
- console.error("previous stage called on first stage");
98
+ console.error("next stage called on last stage");
77
99
  return;
78
100
  }
79
101
  await this.wrappedGame.loadStage(t);
@@ -83,14 +105,14 @@ class m {
83
105
  async end() {
84
106
  }
85
107
  getGlobal(e) {
86
- return this.wrappedGame ? this.wrappedGame.getGlobal(e) : i(e);
108
+ return this.wrappedGame ? this.wrappedGame.getGlobal(e) : g(e);
87
109
  }
88
110
  setGlobal(e, a) {
89
111
  if (this.wrappedGame) {
90
112
  this.wrappedGame.setGlobal(e, a);
91
113
  return;
92
114
  }
93
- p(e, a);
115
+ m(e, a);
94
116
  }
95
117
  onGlobalChange(e, a) {
96
118
  if (this.wrappedGame) {
@@ -100,10 +122,10 @@ class m {
100
122
  this.pendingGlobalChangeHandlers.push({ key: e, callback: a });
101
123
  }
102
124
  }
103
- function b(...s) {
104
- return new m(s);
125
+ function M(...o) {
126
+ return new w(o);
105
127
  }
106
128
  export {
107
- m as Game,
108
- b as createGame
129
+ w as Game,
130
+ M as createGame
109
131
  };
@@ -136,6 +136,5 @@ class n {
136
136
  }
137
137
  }
138
138
  export {
139
- n as ZylemGame,
140
- n as default
139
+ n as ZylemGame
141
140
  };
@@ -1,42 +1,32 @@
1
- import { proxy as i } from "valtio/vanilla";
2
- import { Vector3 as r } from "three";
3
- import { ZylemBlueColor as g } from "../core/utility/vector.js";
4
- const o = {
5
- backgroundColor: g,
1
+ import { proxy as r } from "valtio/vanilla";
2
+ import { Vector3 as i } from "three";
3
+ import { ZylemBlueColor as n } from "../core/utility/vector.js";
4
+ const g = {
5
+ backgroundColor: n,
6
6
  backgroundImage: null,
7
7
  inputs: {
8
8
  p1: ["gamepad-1", "keyboard"],
9
9
  p2: ["gamepad-2", "keyboard"]
10
10
  },
11
- gravity: new r(0, 0, 0),
11
+ gravity: new i(0, 0, 0),
12
12
  variables: {}
13
- }, t = i({
14
- ...o
13
+ }, o = r({
14
+ ...g
15
15
  });
16
16
  function b(a) {
17
- Object.assign(t, a);
17
+ const e = l();
18
+ let t = {};
19
+ return typeof a[0] == "object" && (t = a.shift() ?? {}), [{ ...e, ...t }, ...a];
18
20
  }
19
- function d() {
20
- Object.assign(t, o);
21
- }
22
- function m(a) {
23
- const n = u();
24
- let e = {};
25
- return typeof a[0] == "object" && (e = a.shift() ?? {}), [{ ...n, ...e }, ...a];
26
- }
27
- function u() {
21
+ function l() {
28
22
  return {
29
- backgroundColor: t.backgroundColor,
30
- backgroundImage: t.backgroundImage ?? null,
31
- inputs: t.inputs ? { ...t.inputs } : void 0,
32
- gravity: t.gravity,
33
- variables: t.variables ? { ...t.variables } : void 0
23
+ backgroundColor: o.backgroundColor,
24
+ backgroundImage: o.backgroundImage ?? null,
25
+ inputs: o.inputs ? { ...o.inputs } : void 0,
26
+ gravity: o.gravity,
27
+ variables: o.variables ? { ...o.variables } : void 0
34
28
  };
35
29
  }
36
30
  export {
37
- u as getStageDefaultConfig,
38
- m as getStageOptions,
39
- d as resetStageDefaults,
40
- b as setStageDefaults,
41
- t as stageDefaultsState
31
+ b as getStageOptions
42
32
  };
@@ -0,0 +1,22 @@
1
+ import { createStage as a } from "./stage.js";
2
+ import { EntityFactory as i } from "../entities/entity-factory.js";
3
+ const s = {
4
+ async createFromBlueprint(t) {
5
+ const r = a({
6
+ // Map blueprint properties to stage options if needed
7
+ // e.g. name: blueprint.name
8
+ });
9
+ if (t.entities)
10
+ for (const o of t.entities)
11
+ try {
12
+ const e = await i.createFromBlueprint(o);
13
+ r.add(e);
14
+ } catch (e) {
15
+ console.error(`Failed to create entity ${o.id} for stage ${t.id}`, e);
16
+ }
17
+ return r;
18
+ }
19
+ };
20
+ export {
21
+ s as StageFactory
22
+ };
@@ -0,0 +1,49 @@
1
+ import { proxy as i } from "valtio/vanilla";
2
+ import { set as n, get as o } from "../../node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js";
3
+ import { pack as s } from "../../node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/pack.js";
4
+ import { unpack as c } from "../../node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/unpack.js";
5
+ const t = i({
6
+ previous: null,
7
+ current: null,
8
+ next: null,
9
+ isLoading: !1
10
+ }), p = {
11
+ staticRegistry: /* @__PURE__ */ new Map(),
12
+ registerStaticStage(r, a) {
13
+ this.staticRegistry.set(r, a);
14
+ },
15
+ async loadStageData(r) {
16
+ try {
17
+ const a = await o(r);
18
+ if (a)
19
+ return c(a);
20
+ } catch (a) {
21
+ console.warn(`Failed to load stage ${r} from storage`, a);
22
+ }
23
+ if (this.staticRegistry.has(r))
24
+ return this.staticRegistry.get(r);
25
+ throw new Error(`Stage ${r} not found in storage and static loading not fully implemented.`);
26
+ },
27
+ async transitionForward(r, a) {
28
+ if (!t.isLoading) {
29
+ t.isLoading = !0;
30
+ try {
31
+ t.current && await n(t.current.id, s(t.current)), t.previous = t.current, t.current = t.next, t.current?.id !== r && (a ? t.current = await a(r) : t.current = await this.loadStageData(r)), t.next = null;
32
+ } catch (e) {
33
+ console.error("Failed to transition stage:", e);
34
+ } finally {
35
+ t.isLoading = !1;
36
+ }
37
+ }
38
+ },
39
+ /**
40
+ * Manually set the next stage to pre-load it.
41
+ */
42
+ async preloadNext(r, a) {
43
+ a ? t.next = await a(r) : t.next = await this.loadStageData(r);
44
+ }
45
+ };
46
+ export {
47
+ p as StageManager,
48
+ t as stageState
49
+ };
@@ -1,10 +1,11 @@
1
- import { ZylemStage as i } from "./zylem-stage.js";
2
- import { CameraWrapper as o } from "../camera/camera.js";
3
- import { stageState as s, setStageVariable as n, getStageVariable as d } from "./stage-state.js";
4
- import { getStageOptions as g } from "./stage-default.js";
5
- class S {
1
+ import { ZylemStage as o } from "./zylem-stage.js";
2
+ import { CameraWrapper as d } from "../camera/camera.js";
3
+ import { stageState as r, setStageVariable as n, getStageVariable as g } from "./stage-state.js";
4
+ import { getStageOptions as S } from "./stage-default.js";
5
+ class h {
6
6
  wrappedStage;
7
7
  options = [];
8
+ // TODO: these shouldn't be here maybe more like nextFrame(stageInstance, () => {})
8
9
  update = () => {
9
10
  };
10
11
  setup = () => {
@@ -15,27 +16,33 @@ class S {
15
16
  this.options = t, this.wrappedStage = null;
16
17
  }
17
18
  async load(t, e) {
18
- this.wrappedStage = new i(this.options), this.wrappedStage.wrapperRef = this;
19
- const a = e instanceof o ? e.cameraRef : e;
20
- await this.wrappedStage.load(t, a);
19
+ r.entities = [], this.wrappedStage = new o(this.options), this.wrappedStage.wrapperRef = this;
20
+ const a = e instanceof d ? e.cameraRef : e;
21
+ await this.wrappedStage.load(t, a), this.wrappedStage.onEntityAdded((p) => {
22
+ const s = this.wrappedStage.buildEntityState(p);
23
+ r.entities = [...r.entities, s];
24
+ }, { replayExisting: !0 });
21
25
  }
22
26
  async addEntities(t) {
23
27
  this.options.push(...t), this.wrappedStage && this.wrappedStage.enqueue(...t);
24
28
  }
25
29
  add(...t) {
26
- this.wrappedStage.enqueue(...t);
30
+ this.addToBlueprints(...t), this.addToStage(...t);
31
+ }
32
+ addToBlueprints(...t) {
33
+ this.wrappedStage || this.options.push(...t);
34
+ }
35
+ addToStage(...t) {
36
+ this.wrappedStage && this.wrappedStage.enqueue(...t);
27
37
  }
28
38
  start(t) {
29
- this.wrappedStage?.nodeSetup(t), this.wrappedStage.onEntityAdded((e) => {
30
- const a = this.wrappedStage.buildEntityState(e);
31
- s.entities = [...s.entities, a];
32
- }, { replayExisting: !0 });
39
+ this.wrappedStage?.nodeSetup(t);
33
40
  }
34
41
  onUpdate(...t) {
35
- this.wrappedStage.update = (e) => {
42
+ this.wrappedStage && (this.wrappedStage.update = (e) => {
36
43
  const a = { ...e, stage: this };
37
- t.forEach((r) => r(a));
38
- };
44
+ t.forEach((p) => p(a));
45
+ });
39
46
  }
40
47
  onSetup(t) {
41
48
  this.wrappedStage.setup = t;
@@ -47,14 +54,14 @@ class S {
47
54
  n(t, e);
48
55
  }
49
56
  getVariable(t) {
50
- return d(t);
57
+ return g(t);
51
58
  }
52
59
  }
53
- function c(...p) {
54
- const t = g(p);
55
- return new S([...t]);
60
+ function c(...i) {
61
+ const t = S(i);
62
+ return new h([...t]);
56
63
  }
57
64
  export {
58
- S as Stage,
59
- c as stage
65
+ h as Stage,
66
+ c as createStage
60
67
  };
@@ -264,6 +264,5 @@ class Y extends v {
264
264
  }
265
265
  }
266
266
  export {
267
- W as STAGE_TYPE,
268
267
  Y as ZylemStage
269
268
  };
package/dist/main.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { createGame as m } from "./lib/game/game.js";
2
2
  import { gameConfig as a } from "./lib/game/game-config.js";
3
- import { stage as f } from "./lib/stage/stage.js";
4
- import { entitySpawner as s } from "./lib/stage/entity-spawner.js";
3
+ import { createStage as f } from "./lib/stage/stage.js";
4
+ import { entitySpawner as n } from "./lib/stage/entity-spawner.js";
5
5
  import { vessel as i } from "./lib/core/vessel.js";
6
- import { camera as c } from "./lib/camera/camera.js";
6
+ import { camera as b } from "./lib/camera/camera.js";
7
7
  import { Perspectives as h } from "./lib/camera/perspective.js";
8
8
  import { ZylemBox as v, box as d } from "./lib/entities/box.js";
9
9
  import { sphere as R } from "./lib/entities/sphere.js";
@@ -11,9 +11,9 @@ import { sprite as E } from "./lib/entities/sprite.js";
11
11
  import { plane as w } from "./lib/entities/plane.js";
12
12
  import { zone as D } from "./lib/entities/zone.js";
13
13
  import { actor as I } from "./lib/entities/actor.js";
14
- import { text as T } from "./lib/entities/text.js";
15
- import { rect as A } from "./lib/entities/rect.js";
16
- import { makeMoveable as M } from "./lib/actions/capabilities/moveable.js";
14
+ import { text as S } from "./lib/entities/text.js";
15
+ import { rect as z } from "./lib/entities/rect.js";
16
+ import { makeMoveable as G } from "./lib/actions/capabilities/moveable.js";
17
17
  import { makeRotatable as Z } from "./lib/actions/capabilities/rotatable.js";
18
18
  import { makeTransformable as q } from "./lib/actions/capabilities/transformable.js";
19
19
  import { ricochet2DInBounds as J } from "./lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.js";
@@ -33,24 +33,24 @@ export {
33
33
  I as actor,
34
34
  O as boundary2d,
35
35
  d as box,
36
- c as camera,
36
+ b as camera,
37
37
  m as createGame,
38
+ f as createStage,
38
39
  U as destroy,
39
- s as entitySpawner,
40
+ n as entitySpawner,
40
41
  a as gameConfig,
41
42
  Y as globalChange,
42
43
  _ as globalChanges,
43
- M as makeMoveable,
44
+ G as makeMoveable,
44
45
  Z as makeRotatable,
45
46
  q as makeTransformable,
46
47
  w as plane,
47
- A as rect,
48
+ z as rect,
48
49
  L as ricochet2DCollision,
49
50
  J as ricochet2DInBounds,
50
51
  R as sphere,
51
52
  E as sprite,
52
- f as stage,
53
- T as text,
53
+ S as text,
54
54
  $ as variableChange,
55
55
  oo as variableChanges,
56
56
  i as vessel,
@@ -0,0 +1,34 @@
1
+ function i(e) {
2
+ return new Promise((n, t) => {
3
+ e.oncomplete = e.onsuccess = () => n(e.result), e.onabort = e.onerror = () => t(e.error);
4
+ });
5
+ }
6
+ function f(e, n) {
7
+ let t;
8
+ const o = () => {
9
+ if (t)
10
+ return t;
11
+ const r = indexedDB.open(e);
12
+ return r.onupgradeneeded = () => r.result.createObjectStore(n), t = i(r), t.then((u) => {
13
+ u.onclose = () => t = void 0;
14
+ }, () => {
15
+ }), t;
16
+ };
17
+ return (r, u) => o().then((d) => u(d.transaction(n, r).objectStore(n)));
18
+ }
19
+ let c;
20
+ function a() {
21
+ return c || (c = f("keyval-store", "keyval")), c;
22
+ }
23
+ function l(e, n = a()) {
24
+ return n("readonly", (t) => i(t.get(e)));
25
+ }
26
+ function s(e, n, t = a()) {
27
+ return t("readwrite", (o) => (o.put(n, e), i(o.transaction)));
28
+ }
29
+ export {
30
+ f as createStore,
31
+ l as get,
32
+ i as promisifyRequest,
33
+ s as set
34
+ };