bard-legends-framework 0.11.0 → 0.12.1

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 (258) hide show
  1. package/dist/actions-performance.test.d.ts +1 -0
  2. package/dist/actions-performance.test.js +83 -0
  3. package/dist/game-entities/controller/controller.d.ts +2 -2
  4. package/dist/game-entities/controller/controller.js +8 -8
  5. package/dist/game-entities/controller/controller.test.js +2 -2
  6. package/dist/game-entities/entity/entity.d.ts +7 -7
  7. package/dist/game-entities/entity/entity.js +18 -12
  8. package/dist/game-entities/entity/entity.test.js +93 -30
  9. package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +3 -3
  10. package/dist/game-entities/entity/helpers/entity-store.helper.js +12 -12
  11. package/dist/game-entities/entity/helpers/entity-store.helper.test.js +11 -11
  12. package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +6 -6
  13. package/dist/game-entities/entity/helpers/entity-views.helper.js +25 -22
  14. package/dist/game-entities/entity/singleton-entity.test.js +9 -4
  15. package/dist/game-entities/hard-reset.d.ts +5 -0
  16. package/dist/game-entities/hard-reset.js +14 -0
  17. package/dist/game-entities/index.d.ts +1 -1
  18. package/dist/game-entities/index.js +3 -3
  19. package/dist/game-entities/scene/scene.d.ts +13 -13
  20. package/dist/game-entities/scene/scene.js +41 -46
  21. package/dist/game-entities/scene/scene.test.js +95 -37
  22. package/dist/game-entities/service/service.d.ts +1 -4
  23. package/dist/game-entities/service/service.js +12 -13
  24. package/dist/game-entities/service/service.test.js +33 -12
  25. package/dist/game-entities/unit-test.helper.js +1 -1
  26. package/dist/game-entities/update-cycle.d.ts +7 -17
  27. package/dist/game-entities/update-cycle.js +25 -19
  28. package/dist/game-entities/view/view.d.ts +6 -6
  29. package/dist/game-entities/view/view.js +15 -21
  30. package/dist/game-entities/view/view.test.js +40 -9
  31. package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -1
  32. package/dist/physics/entity-types/immovable-physics-entity.js +4 -4
  33. package/dist/physics/entity-types/movable-entity.d.ts +1 -1
  34. package/dist/physics/entity-types/movable-entity.js +2 -2
  35. package/dist/physics/entity-types/movable-physics-entity.d.ts +8 -8
  36. package/dist/physics/entity-types/movable-physics-entity.js +27 -27
  37. package/dist/physics/entity-types/physics-entity.d.ts +10 -14
  38. package/dist/physics/entity-types/physics-entity.js +27 -26
  39. package/dist/physics/interfaces.d.ts +6 -6
  40. package/dist/physics/interfaces.js +4 -4
  41. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
  42. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
  43. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +19 -19
  44. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
  45. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
  46. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
  47. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
  48. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +10 -10
  49. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
  50. package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
  51. package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
  52. package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
  53. package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
  54. package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
  55. package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
  56. package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
  57. package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
  58. package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
  59. package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
  60. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
  61. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +27 -26
  62. package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
  63. package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
  64. package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
  65. package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
  66. package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
  67. package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
  68. package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
  69. package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
  70. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
  71. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
  72. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
  73. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +12 -12
  74. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
  75. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +12 -12
  76. package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
  77. package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
  78. package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
  79. package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
  80. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
  81. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +43 -42
  82. package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
  83. package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
  84. package/dist/pixi/components/display-object-array.d.ts +5 -5
  85. package/dist/pixi/components/display-object-array.js +14 -14
  86. package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
  87. package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
  88. package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
  89. package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
  90. package/dist/pixi/components/menu/menu-entity.js +48 -0
  91. package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
  92. package/dist/pixi/components/menu/menu.ui.js +97 -0
  93. package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -2
  94. package/dist/pixi/components/mouse-wheel-listener.ui.js +11 -11
  95. package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
  96. package/dist/pixi/components/scroll-area.ui.js +9 -9
  97. package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
  98. package/dist/pixi/components/scroll-mask.ui.js +25 -24
  99. package/dist/pixi/display-object/container-attributes.d.ts +24 -25
  100. package/dist/pixi/display-object/container-attributes.js +26 -26
  101. package/dist/pixi/display-object/container.d.ts +3 -3
  102. package/dist/pixi/display-object/container.js +2 -2
  103. package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
  104. package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
  105. package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
  106. package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
  107. package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
  108. package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
  109. package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
  110. package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
  111. package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
  112. package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
  113. package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
  114. package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
  115. package/dist/pixi/display-object/filters.d.ts +7 -7
  116. package/dist/pixi/display-object/filters.js +34 -34
  117. package/dist/pixi/display-object/index.d.ts +1 -1
  118. package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
  119. package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
  120. package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
  121. package/dist/pixi/display-object/objects/placeholder.js +7 -7
  122. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
  123. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +26 -25
  124. package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
  125. package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
  126. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
  127. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
  128. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
  129. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
  130. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
  131. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
  132. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
  133. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
  134. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
  135. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
  136. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
  137. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
  138. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
  139. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
  140. package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
  141. package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
  142. package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
  143. package/dist/pixi/display-object/objects/text/text.js +34 -35
  144. package/dist/pixi/game.d.ts +20 -15
  145. package/dist/pixi/game.js +40 -35
  146. package/dist/pixi/helpers/game-assets.d.ts +5 -5
  147. package/dist/pixi/helpers/game-assets.js +14 -11
  148. package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
  149. package/dist/pixi/helpers/position-conversion.helper.js +3 -3
  150. package/dist/pixi/index.d.ts +3 -37
  151. package/dist/pixi/index.js +6 -22
  152. package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
  153. package/dist/pixi/modules/CAMERA/camera.js +9 -9
  154. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
  155. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
  156. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
  157. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
  158. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
  159. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
  160. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
  161. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
  162. package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
  163. package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
  164. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
  165. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +49 -48
  166. package/dist/pixi/pixi-definitions.d.ts +38 -0
  167. package/dist/pixi/pixi-definitions.js +37 -0
  168. package/dist/pixi/services/keyboard/keyboard.d.ts +2 -2
  169. package/dist/pixi/services/keyboard/keyboard.js +9 -9
  170. package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +10 -10
  171. package/dist/pixi/services/mouse/mouse-target-focus.service.js +28 -28
  172. package/dist/pixi/services/mouse/mouse.service.d.ts +1 -1
  173. package/dist/pixi/services/mouse/mouse.service.js +5 -5
  174. package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
  175. package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
  176. package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
  177. package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
  178. package/dist/utilities/animator/animations.d.ts +14 -6
  179. package/dist/utilities/animator/animations.js +15 -11
  180. package/dist/utilities/animator/animator/animator.d.ts +44 -0
  181. package/dist/utilities/animator/animator/animator.js +234 -0
  182. package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
  183. package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
  184. package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
  185. package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
  186. package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
  187. package/dist/utilities/animator/animator/animator.test.js +1046 -0
  188. package/dist/utilities/animator/animator.d.ts +2 -3
  189. package/dist/utilities/animator/animator.js +66 -59
  190. package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
  191. package/dist/utilities/animator/animator.performance.test.js +46 -0
  192. package/dist/utilities/animator/animator.test.js +89 -28
  193. package/dist/utilities/animator/animator2/animator.d.ts +42 -0
  194. package/dist/utilities/animator/animator2/animator.js +222 -0
  195. package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
  196. package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
  197. package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
  198. package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
  199. package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
  200. package/dist/utilities/animator/animator2/animator.test.js +1007 -0
  201. package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
  202. package/dist/utilities/animator/animator_old/animator.js +337 -0
  203. package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
  204. package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
  205. package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
  206. package/dist/utilities/animator/animator_old/animator.test.js +996 -0
  207. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
  208. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
  209. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
  210. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
  211. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
  212. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
  213. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
  214. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
  215. package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
  216. package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
  217. package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
  218. package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
  219. package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
  220. package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
  221. package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
  222. package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
  223. package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
  224. package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
  225. package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
  226. package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
  227. package/dist/utilities/animator/index.d.ts +6 -6
  228. package/dist/utilities/animator/index.js +6 -6
  229. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
  230. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
  231. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
  232. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
  233. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
  234. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
  235. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
  236. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
  237. package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
  238. package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
  239. package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
  240. package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
  241. package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
  242. package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
  243. package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
  244. package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
  245. package/dist/utilities/animator/state-animation/slide-state-animation.test.js +30 -30
  246. package/dist/utilities/animator/state-animation/state-animation.js +7 -7
  247. package/dist/utilities/animator/state-animation/state-animation.test.js +24 -24
  248. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +30 -30
  249. package/dist/utilities/data-structures/vector-set/vector-set.d.ts +1 -1
  250. package/dist/utilities/data-structures/vector-set/vector-set.js +5 -5
  251. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +1 -1
  252. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +5 -5
  253. package/dist/utilities/grid-algorithms/path-finder/path-finder.js +21 -21
  254. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +9 -9
  255. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +14 -14
  256. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +43 -43
  257. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +21 -21
  258. package/package.json +7 -5
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Animator = exports.AnimationsCompletionHandlingType = exports.ReAnimateHandlingType = void 0;
4
+ const actions_lib_1 = require("actions-lib");
5
+ const helpers_lib_1 = require("helpers-lib");
6
+ const game_entities_1 = require("../../../game-entities");
7
+ const animations_1 = require("../animations");
8
+ var ReAnimateHandlingType;
9
+ (function (ReAnimateHandlingType) {
10
+ ReAnimateHandlingType[ReAnimateHandlingType["ThrowError"] = 1] = "ThrowError";
11
+ ReAnimateHandlingType[ReAnimateHandlingType["IgnoreNewAnimation"] = 2] = "IgnoreNewAnimation";
12
+ ReAnimateHandlingType[ReAnimateHandlingType["CompletePrevious"] = 3] = "CompletePrevious";
13
+ })(ReAnimateHandlingType || (exports.ReAnimateHandlingType = ReAnimateHandlingType = {}));
14
+ var AnimationsCompletionHandlingType;
15
+ (function (AnimationsCompletionHandlingType) {
16
+ AnimationsCompletionHandlingType[AnimationsCompletionHandlingType["ReturnToOriginal"] = 1] = "ReturnToOriginal";
17
+ AnimationsCompletionHandlingType[AnimationsCompletionHandlingType["StayInCurrentState"] = 2] = "StayInCurrentState";
18
+ AnimationsCompletionHandlingType[AnimationsCompletionHandlingType["JumpToEnd"] = 3] = "JumpToEnd";
19
+ AnimationsCompletionHandlingType[AnimationsCompletionHandlingType["Loop"] = 4] = "Loop";
20
+ })(AnimationsCompletionHandlingType || (exports.AnimationsCompletionHandlingType = AnimationsCompletionHandlingType = {}));
21
+ class Animator {
22
+ static { this._animatedObjects = new WeakMap(); }
23
+ static _getAnimatedObjectProperties(target) {
24
+ let animatedObjectProperties = Animator._animatedObjects.get(target);
25
+ if (!animatedObjectProperties) {
26
+ animatedObjectProperties = new helpers_lib_1.MapToWeakRefs();
27
+ Animator._animatedObjects.set(target, animatedObjectProperties);
28
+ }
29
+ return animatedObjectProperties;
30
+ }
31
+ get animating() {
32
+ return this._ongoingAnimation !== undefined;
33
+ }
34
+ get target() {
35
+ return this._target;
36
+ }
37
+ get value() {
38
+ if (!this._value) {
39
+ this._value = new actions_lib_1.Variable(this._target);
40
+ }
41
+ return this._value.notifier;
42
+ }
43
+ constructor(target, animatedProperties, partialOptions) {
44
+ this._target = target;
45
+ this._options = {
46
+ duration: 200,
47
+ animation: animations_1.Animations.lineer,
48
+ reAnimateHandling: ReAnimateHandlingType.ThrowError,
49
+ completionHandling: AnimationsCompletionHandlingType.StayInCurrentState,
50
+ ...partialOptions
51
+ };
52
+ this._animatedProperties = helpers_lib_1.Comparator.isArray(animatedProperties) ? animatedProperties : [animatedProperties];
53
+ this._lockAnimatedProperties(target, this._animatedProperties); // NOTE: this can be removed in release mode
54
+ }
55
+ animate(values, partialOptions) {
56
+ let options = {
57
+ ...this._options,
58
+ ...partialOptions
59
+ };
60
+ if (this._ongoingAnimation) {
61
+ switch (options.reAnimateHandling) {
62
+ case ReAnimateHandlingType.ThrowError:
63
+ throw new Error(`Animator: new animation triggered while another is not complete yet.`);
64
+ case ReAnimateHandlingType.IgnoreNewAnimation:
65
+ return actions_lib_1.SingleEvent.instant();
66
+ case ReAnimateHandlingType.CompletePrevious:
67
+ this._setCompletionValues(options.completionHandling, this._ongoingAnimation._properties, true);
68
+ break;
69
+ default: {
70
+ let _ = options.reAnimateHandling;
71
+ throw new Error(`Animator: unknown re-animate handling type: "${options.reAnimateHandling}"`);
72
+ }
73
+ }
74
+ }
75
+ let event = actions_lib_1.SingleEvent.create(resolve => {
76
+ let properties = this._animatedProperties.reduce((acc, key) => {
77
+ acc[key] = {
78
+ _startingValue: this._target[key],
79
+ _targetValue: values[key]
80
+ };
81
+ return acc;
82
+ }, {});
83
+ let updateCycleSubscription;
84
+ let animationState = {
85
+ _duration: options.duration,
86
+ _elapsedTime: 0,
87
+ _properties: properties,
88
+ _completionHandling: options.completionHandling,
89
+ _animation: options.animation,
90
+ _completionCallback: resolve
91
+ };
92
+ if (animationState._completionHandling !== AnimationsCompletionHandlingType.Loop &&
93
+ this._isAnimatingToSameValues(animationState)) {
94
+ this._ongoingAnimation = undefined;
95
+ resolve();
96
+ return;
97
+ }
98
+ else {
99
+ animationState._animation.start();
100
+ }
101
+ let previousAnimationState = this._ongoingAnimation;
102
+ this._ongoingAnimation = animationState;
103
+ updateCycleSubscription = game_entities_1.UpdateCycle.beforeSceneUpdateAction
104
+ .subscribe(update => {
105
+ animationState._elapsedTime += update.delta;
106
+ let animationIsCompete = animationState._elapsedTime >= animationState._duration;
107
+ if (animationIsCompete) {
108
+ if (animationState._completionHandling === AnimationsCompletionHandlingType.Loop) {
109
+ animationState._elapsedTime %= animationState._duration;
110
+ animationState._animation.start();
111
+ animationIsCompete = false;
112
+ }
113
+ else {
114
+ this._setCompletionValues(animationState._completionHandling, animationState._properties, false);
115
+ this._ongoingAnimation = undefined;
116
+ animationState._completionCallback();
117
+ }
118
+ }
119
+ if (!animationIsCompete) {
120
+ let multiplier = animationState._animation.multiplierFunction(animationState._elapsedTime / animationState._duration);
121
+ let changeHappened = false;
122
+ for (let i = 0; i < this._animatedProperties.length; i++) {
123
+ let key = this._animatedProperties[i];
124
+ let propertyState = animationState._properties[key];
125
+ let relativeTarget = propertyState._targetValue - propertyState._startingValue;
126
+ let newValue = relativeTarget * multiplier + propertyState._startingValue;
127
+ if (newValue !== this._target[key]) {
128
+ changeHappened = true;
129
+ this._target[key] = newValue;
130
+ }
131
+ }
132
+ changeHappened && this._value?.set(this._target);
133
+ }
134
+ })
135
+ .attachToRoot();
136
+ previousAnimationState?._completionCallback();
137
+ return () => {
138
+ updateCycleSubscription.destroy();
139
+ if (this._ongoingAnimation === animationState) {
140
+ if (!(this._target instanceof actions_lib_1.Attachable && this._target.destroyed)) {
141
+ this._setCompletionValues(this._ongoingAnimation._completionHandling, this._ongoingAnimation._properties, true);
142
+ }
143
+ this._ongoingAnimation = undefined;
144
+ }
145
+ };
146
+ });
147
+ return event;
148
+ }
149
+ set(values) {
150
+ let changeHappened = false;
151
+ for (let i = 0; i < this._animatedProperties.length; i++) {
152
+ let key = this._animatedProperties[i];
153
+ if (this._target[key] !== values[key]) {
154
+ changeHappened = true;
155
+ this._target[key] = values[key];
156
+ }
157
+ }
158
+ changeHappened && this._value?.set(this._target);
159
+ this._ongoingAnimation?._completionCallback();
160
+ }
161
+ completeAnimation(completionHandling) {
162
+ if (this._ongoingAnimation) {
163
+ completionHandling = completionHandling ?? this._ongoingAnimation._completionHandling;
164
+ this._setCompletionValues(completionHandling, this._ongoingAnimation._properties, true);
165
+ let callback = this._ongoingAnimation._completionCallback;
166
+ this._ongoingAnimation = undefined;
167
+ callback();
168
+ }
169
+ }
170
+ _isAnimatingToSameValues(ongoingAnimation) {
171
+ for (let i = 0; i < this._animatedProperties.length; i++) {
172
+ let key = this._animatedProperties[i];
173
+ if (this._target[key] !== ongoingAnimation._properties[key]._targetValue) {
174
+ return false;
175
+ }
176
+ }
177
+ return true;
178
+ }
179
+ _setCompletionValues(completionHandling, values, interruptedCompletion) {
180
+ switch (completionHandling) {
181
+ case AnimationsCompletionHandlingType.ReturnToOriginal:
182
+ this._returnToStartingValues(values);
183
+ break;
184
+ case AnimationsCompletionHandlingType.StayInCurrentState:
185
+ if (!interruptedCompletion) {
186
+ this._jumpToTargetValues(values);
187
+ }
188
+ break;
189
+ case AnimationsCompletionHandlingType.JumpToEnd:
190
+ this._jumpToTargetValues(values);
191
+ break;
192
+ case AnimationsCompletionHandlingType.Loop:
193
+ this._returnToStartingValues(values);
194
+ break;
195
+ default: {
196
+ let _ = completionHandling;
197
+ throw new Error(`Animator: unknown completion handling type: "${completionHandling}"`);
198
+ }
199
+ }
200
+ }
201
+ _returnToStartingValues(values) {
202
+ let changeHappened = false;
203
+ for (let i = 0; i < this._animatedProperties.length; i++) {
204
+ let key = this._animatedProperties[i];
205
+ if (this._target[key] !== values[key]._startingValue) {
206
+ changeHappened = true;
207
+ this._target[key] = values[key]._startingValue;
208
+ }
209
+ }
210
+ changeHappened && this._value?.set(this._target);
211
+ }
212
+ _jumpToTargetValues(values) {
213
+ let changeHappened = false;
214
+ for (let i = 0; i < this._animatedProperties.length; i++) {
215
+ let key = this._animatedProperties[i];
216
+ if (this._target[key] !== values[key]._targetValue) {
217
+ changeHappened = true;
218
+ this._target[key] = values[key]._targetValue;
219
+ }
220
+ }
221
+ changeHappened && this._value?.set(this._target);
222
+ }
223
+ _lockAnimatedProperties(target, animatedProperties) {
224
+ let animatedObjectProperties = Animator._getAnimatedObjectProperties(target);
225
+ for (let key of animatedProperties) {
226
+ if (animatedObjectProperties.has(key)) {
227
+ throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(target, undefined, 2)}", Property: "${key}"`);
228
+ }
229
+ animatedObjectProperties.set(key, this);
230
+ }
231
+ }
232
+ }
233
+ exports.Animator = Animator;
234
+ //# sourceMappingURL=animator.js.map
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@memlab/core");
4
+ const actions_lib_1 = require("actions-lib");
5
+ const helpers_lib_1 = require("helpers-lib");
6
+ const vitest_1 = require("vitest");
7
+ const game_entities_1 = require("../../../game-entities");
8
+ const animator_1 = require("./animator");
9
+ const ClassNamesToCheck = ['Animator', 'SingleEvent'];
10
+ vitest_1.describe.skipIf(process.env.QUICK)('Memory Leak', () => {
11
+ (0, vitest_1.beforeEach)(() => {
12
+ actions_lib_1.ActionLib.hardReset();
13
+ });
14
+ async function checkMemoryLeaks(...additionalNames) {
15
+ await helpers_lib_1.UnitTestHelper.waitForAllOperations();
16
+ await (0, helpers_lib_1.Wait)();
17
+ let snapshot = await (0, core_1.takeNodeMinimalHeap)();
18
+ ClassNamesToCheck.concat(additionalNames).forEach(name => {
19
+ if (snapshot.hasObjectWithClassName(name)) {
20
+ throw new Error(`"${name}" has at least one instance in the memory.`);
21
+ }
22
+ });
23
+ }
24
+ (0, vitest_1.test)('simple animator', async () => {
25
+ let target = { x: 1 };
26
+ let animator = new animator_1.Animator(target, 'x');
27
+ (0, vitest_1.expect)(animator).toBeDefined();
28
+ animator = undefined;
29
+ await (0, vitest_1.expect)(checkMemoryLeaks()).resolves.not.toThrow();
30
+ }, 60000);
31
+ (0, vitest_1.test)('sample animation', async () => {
32
+ let target = { x: 1 };
33
+ let animator = new animator_1.Animator(target, 'x');
34
+ let animation = animator.animate({ x: 2 }).attachToRoot();
35
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
36
+ (0, vitest_1.expect)(animation).toBeDefined();
37
+ animation.destroy();
38
+ animator = undefined;
39
+ animation = undefined;
40
+ await (0, vitest_1.expect)(checkMemoryLeaks()).resolves.not.toThrow();
41
+ }, 60000);
42
+ (0, vitest_1.test)('target contains the animator', async () => {
43
+ class Foo {
44
+ constructor() {
45
+ this.x = 0;
46
+ this.animator = new animator_1.Animator(this, 'x');
47
+ }
48
+ }
49
+ let foo = new Foo();
50
+ (0, vitest_1.expect)(foo).toBeDefined();
51
+ foo = undefined;
52
+ await (0, vitest_1.expect)(checkMemoryLeaks(Foo.name)).resolves.not.toThrow();
53
+ }, 60000);
54
+ (0, vitest_1.test)('default animation contains the animator', async () => {
55
+ class FaultyAnimation {
56
+ start() { }
57
+ multiplierFunction(t) {
58
+ return 0;
59
+ }
60
+ setAnimator(anim) {
61
+ this._animator = anim;
62
+ }
63
+ }
64
+ let animation = new FaultyAnimation();
65
+ let animator = new animator_1.Animator({ x: 1 }, 'x', { animation });
66
+ animation.setAnimator(animator);
67
+ (0, vitest_1.expect)(animator).toBeDefined();
68
+ animation = undefined;
69
+ animator = undefined;
70
+ await (0, vitest_1.expect)(checkMemoryLeaks(FaultyAnimation.name)).resolves.not.toThrow();
71
+ }, 60000);
72
+ });
73
+ //# sourceMappingURL=animator.memory-leak.test.js.map
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const helpers_lib_1 = require("helpers-lib");
4
+ const vitest_1 = require("vitest");
5
+ const game_entities_1 = require("../../../game-entities");
6
+ const animator_1 = require("./animator");
7
+ vitest_1.describe.skipIf(!process.env.MANUAL)('Performance Tests', () => {
8
+ (0, vitest_1.test)('no anim single', async () => {
9
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
10
+ return new Promise(resolve => {
11
+ let obj = { x: 0, y: 0 };
12
+ new animator_1.Animator(obj, 'x', {
13
+ duration: 1
14
+ });
15
+ resolve();
16
+ });
17
+ // old animator: 18.053100109100342
18
+ // 11.454499959945679
19
+ // not using context.attachable: 11.263000011444092
20
+ }, { sampleCount: 100, repetationCount: 10000 });
21
+ }, 60000);
22
+ (0, vitest_1.test)('no anim multiple', async () => {
23
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
24
+ return new Promise(resolve => {
25
+ let obj = { x: 0, y: 0 };
26
+ new animator_1.Animator(obj, ['x', 'y'], {
27
+ duration: 1
28
+ });
29
+ resolve();
30
+ });
31
+ // old animator: 18.6875
32
+ // 12.170400142669678
33
+ // not using context.attachable: 11.783799886703491
34
+ }, { sampleCount: 100, repetationCount: 10000 });
35
+ }, 60000);
36
+ (0, vitest_1.test)('single anim with trigger', async () => {
37
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
38
+ return new Promise(resolve => {
39
+ let obj = { x: 0, y: 0 };
40
+ let animator = new animator_1.Animator(obj, 'x', {
41
+ duration: 1
42
+ });
43
+ animator.animate({ x: 1 }).tap(resolve).attachToRoot();
44
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
45
+ });
46
+ // old animator: 40.16639995574951
47
+ // 31.48099994659424
48
+ // not using context.attachable: 28.500200033187866
49
+ }, { sampleCount: 100, repetationCount: 10000 });
50
+ }, 60000);
51
+ (0, vitest_1.test)('multiple anim with trigger', async () => {
52
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
53
+ return new Promise(resolve => {
54
+ let obj = { x: 0, y: 0 };
55
+ let animator = new animator_1.Animator(obj, ['x', 'y'], {
56
+ duration: 1
57
+ });
58
+ animator.animate({ x: 1, y: 1 }).tap(resolve).attachToRoot();
59
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
60
+ });
61
+ // old animator: 43.13860011100769
62
+ // 34.62980008125305
63
+ // not using context.attachable: 33.04159998893738
64
+ }, { sampleCount: 100, repetationCount: 10000 });
65
+ }, 60000);
66
+ (0, vitest_1.test)('single anim with 10 duration', async () => {
67
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
68
+ return new Promise(resolve => {
69
+ let obj = { x: 0, y: 0 };
70
+ let animator = new animator_1.Animator(obj, 'x', {
71
+ duration: 10
72
+ });
73
+ animator.animate({ x: 1 }).tap(resolve).attachToRoot();
74
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
75
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
76
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
77
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
78
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
79
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
80
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
81
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
82
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
83
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
84
+ });
85
+ // old animator: 45.116599798202515
86
+ // 42.34260010719299
87
+ // after single event optimizations: 39.85520005226135
88
+ // not using context.attachable: 34.36899995803833
89
+ }, { sampleCount: 200, repetationCount: 10000 });
90
+ }, 60000);
91
+ (0, vitest_1.test)('multiple anim with 10 duration', async () => {
92
+ await helpers_lib_1.UnitTestHelper.testPerformance(async () => {
93
+ return new Promise(resolve => {
94
+ let obj = { x: 0, y: 0 };
95
+ let animator = new animator_1.Animator(obj, ['x', 'y'], {
96
+ duration: 10
97
+ });
98
+ animator.animate({ x: 1, y: 1 }).tap(resolve).attachToRoot();
99
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
100
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
101
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
102
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
103
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
104
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
105
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
106
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
107
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
108
+ game_entities_1.UpdateCycle.triggerUpdateTick(1);
109
+ });
110
+ // old animator: 55.35859990119934
111
+ // 54.57029986381531
112
+ // not using context.attachable: 50.5145001411438
113
+ }, { sampleCount: 50, repetationCount: 10000 });
114
+ }, 60000);
115
+ });
116
+ //# sourceMappingURL=animator.performance.test.js.map