excalibur 0.28.3 → 0.28.4

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 (482) hide show
  1. package/.gitattributes +63 -63
  2. package/CHANGELOG.md +2003 -1955
  3. package/LICENSE.md +25 -25
  4. package/README.md +134 -134
  5. package/STYLEGUIDE.md +136 -136
  6. package/build/dist/Actions/Action/ActionSequence.js +31 -0
  7. package/build/dist/Actions/Action/ActionSequence.js.map +1 -0
  8. package/build/dist/Actions/Action/Blink.js +54 -0
  9. package/build/dist/Actions/Action/Blink.js.map +1 -0
  10. package/build/dist/Actions/Action/CallMethod.js +21 -0
  11. package/build/dist/Actions/Action/CallMethod.js.map +1 -0
  12. package/build/dist/Actions/Action/Delay.js +26 -0
  13. package/build/dist/Actions/Action/Delay.js.map +1 -0
  14. package/build/dist/Actions/Action/Die.js +22 -0
  15. package/build/dist/Actions/Action/Die.js.map +1 -0
  16. package/build/dist/Actions/Action/EaseBy.js +70 -0
  17. package/build/dist/Actions/Action/EaseBy.js.map +1 -0
  18. package/build/dist/Actions/Action/EaseTo.js +69 -0
  19. package/build/dist/Actions/Action/EaseTo.js.map +1 -0
  20. package/build/dist/Actions/Action/Fade.js +48 -0
  21. package/build/dist/Actions/Action/Fade.js.map +1 -0
  22. package/build/dist/Actions/Action/Follow.js +56 -0
  23. package/build/dist/Actions/Action/Follow.js.map +1 -0
  24. package/build/dist/Actions/Action/Meet.js +54 -0
  25. package/build/dist/Actions/Action/Meet.js.map +1 -0
  26. package/build/dist/Actions/Action/MoveBy.js +48 -0
  27. package/build/dist/Actions/Action/MoveBy.js.map +1 -0
  28. package/build/dist/Actions/Action/MoveTo.js +41 -0
  29. package/build/dist/Actions/Action/MoveTo.js.map +1 -0
  30. package/build/dist/Actions/Action/ParallelActions.js +23 -0
  31. package/build/dist/Actions/Action/ParallelActions.js.map +1 -0
  32. package/build/dist/Actions/Action/Repeat.js +31 -0
  33. package/build/dist/Actions/Action/Repeat.js.map +1 -0
  34. package/build/dist/Actions/Action/RepeatForever.js +37 -0
  35. package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
  36. package/build/dist/Actions/Action/RotateBy.js +95 -0
  37. package/build/dist/Actions/Action/RotateBy.js.map +1 -0
  38. package/build/dist/Actions/Action/RotateTo.js +91 -0
  39. package/build/dist/Actions/Action/RotateTo.js.map +1 -0
  40. package/build/dist/Actions/Action/ScaleBy.js +46 -0
  41. package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
  42. package/build/dist/Actions/Action/ScaleTo.js +58 -0
  43. package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
  44. package/build/dist/Actions/Action.js +2 -0
  45. package/build/dist/Actions/Action.js.map +1 -0
  46. package/build/dist/Actions/ActionContext.js +322 -0
  47. package/build/dist/Actions/ActionContext.js.map +1 -0
  48. package/build/dist/Actions/ActionQueue.js +87 -0
  49. package/build/dist/Actions/ActionQueue.js.map +1 -0
  50. package/build/dist/Actions/Actionable.js +2 -0
  51. package/build/dist/Actions/Actionable.js.map +1 -0
  52. package/build/dist/Actions/ActionsComponent.js +195 -0
  53. package/build/dist/Actions/ActionsComponent.js.map +1 -0
  54. package/build/dist/Actions/ActionsSystem.js +30 -0
  55. package/build/dist/Actions/ActionsSystem.js.map +1 -0
  56. package/build/dist/Actions/Index.js +26 -0
  57. package/build/dist/Actions/Index.js.map +1 -0
  58. package/build/dist/Actions/RotationType.js +27 -0
  59. package/build/dist/Actions/RotationType.js.map +1 -0
  60. package/build/dist/Actor.js +629 -0
  61. package/build/dist/Actor.js.map +1 -0
  62. package/build/dist/Camera.js +660 -0
  63. package/build/dist/Camera.js.map +1 -0
  64. package/build/dist/Collision/BoundingBox.js +415 -0
  65. package/build/dist/Collision/BoundingBox.js.map +1 -0
  66. package/build/dist/Collision/ColliderComponent.js +202 -0
  67. package/build/dist/Collision/ColliderComponent.js.map +1 -0
  68. package/build/dist/Collision/Colliders/CircleCollider.js +226 -0
  69. package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
  70. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
  71. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
  72. package/build/dist/Collision/Colliders/Collider.js +32 -0
  73. package/build/dist/Collision/Colliders/Collider.js.map +1 -0
  74. package/build/dist/Collision/Colliders/CollisionJumpTable.js +300 -0
  75. package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
  76. package/build/dist/Collision/Colliders/EdgeCollider.js +229 -0
  77. package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
  78. package/build/dist/Collision/Colliders/PolygonCollider.js +556 -0
  79. package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
  80. package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
  81. package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
  82. package/build/dist/Collision/Colliders/Shape.js +99 -0
  83. package/build/dist/Collision/Colliders/Shape.js.map +1 -0
  84. package/build/dist/Collision/CollisionType.js +33 -0
  85. package/build/dist/Collision/CollisionType.js.map +1 -0
  86. package/build/dist/Collision/Detection/CollisionContact.js +51 -0
  87. package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
  88. package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
  89. package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
  90. package/build/dist/Collision/Detection/DynamicTree.js +442 -0
  91. package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
  92. package/build/dist/Collision/Detection/Pair.js +92 -0
  93. package/build/dist/Collision/Detection/Pair.js.map +1 -0
  94. package/build/dist/Collision/Detection/QuadTree.js +193 -0
  95. package/build/dist/Collision/Detection/QuadTree.js.map +1 -0
  96. package/build/dist/Collision/Group/CollisionGroup.js +3 -3
  97. package/build/dist/Collision/Integrator.js +25 -0
  98. package/build/dist/Collision/Integrator.js.map +1 -0
  99. package/build/dist/Collision/MotionSystem.js +35 -0
  100. package/build/dist/Collision/MotionSystem.js.map +1 -0
  101. package/build/dist/Collision/Physics.js +163 -0
  102. package/build/dist/Collision/Physics.js.map +1 -0
  103. package/build/dist/Collision/PhysicsWorld.js +10 -0
  104. package/build/dist/Collision/PhysicsWorld.js.map +1 -0
  105. package/build/dist/Collision/Side.js +51 -0
  106. package/build/dist/Collision/Side.js.map +1 -0
  107. package/build/dist/Collision/Solver/ArcadeSolver.js +154 -0
  108. package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
  109. package/build/dist/Collision/Solver/ContactConstraintPoint.js +87 -0
  110. package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
  111. package/build/dist/Collision/Solver/RealisticSolver.js +293 -0
  112. package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
  113. package/build/dist/Collision/Solver/Solver.js +2 -0
  114. package/build/dist/Collision/Solver/Solver.js.map +1 -0
  115. package/build/dist/Color.js +417 -0
  116. package/build/dist/Color.js.map +1 -0
  117. package/build/dist/Configurable.js +32 -0
  118. package/build/dist/Configurable.js.map +1 -0
  119. package/build/dist/Debug/Debug.d.ts +11 -0
  120. package/build/dist/Debug/Debug.js +385 -0
  121. package/build/dist/Debug/Debug.js.map +1 -0
  122. package/build/dist/Debug/DebugFlags.js +40 -0
  123. package/build/dist/Debug/DebugFlags.js.map +1 -0
  124. package/build/dist/Debug/DebugSystem.js +263 -0
  125. package/build/dist/Debug/DebugSystem.js.map +1 -0
  126. package/build/dist/Debug/index.js +4 -0
  127. package/build/dist/Debug/index.js.map +1 -0
  128. package/build/dist/Deprecated.js +2 -0
  129. package/build/dist/Deprecated.js.map +1 -0
  130. package/build/dist/Engine.js +986 -0
  131. package/build/dist/Engine.js.map +1 -0
  132. package/build/dist/EntityComponentSystem/Component.js +65 -0
  133. package/build/dist/EntityComponentSystem/Component.js.map +1 -0
  134. package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
  135. package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
  136. package/build/dist/EntityComponentSystem/Components/TransformComponent.js +107 -0
  137. package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
  138. package/build/dist/EntityComponentSystem/Entity.js +487 -0
  139. package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
  140. package/build/dist/EntityComponentSystem/EntityManager.js +137 -0
  141. package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
  142. package/build/dist/EntityComponentSystem/Query.js +90 -0
  143. package/build/dist/EntityComponentSystem/Query.js.map +1 -0
  144. package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
  145. package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
  146. package/build/dist/EntityComponentSystem/System.js +76 -0
  147. package/build/dist/EntityComponentSystem/System.js.map +1 -0
  148. package/build/dist/EntityComponentSystem/SystemManager.js +104 -0
  149. package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
  150. package/build/dist/EntityComponentSystem/Util.js +5 -0
  151. package/build/dist/EntityComponentSystem/Util.js.map +1 -0
  152. package/build/dist/EntityComponentSystem/World.js +55 -0
  153. package/build/dist/EntityComponentSystem/World.js.map +1 -0
  154. package/build/dist/EntityComponentSystem/index.js +11 -0
  155. package/build/dist/EntityComponentSystem/index.js.map +1 -0
  156. package/build/dist/EventDispatcher.js +122 -0
  157. package/build/dist/EventDispatcher.js.map +1 -0
  158. package/build/dist/EventEmitter.js +86 -0
  159. package/build/dist/EventEmitter.js.map +1 -0
  160. package/build/dist/Events/ExEvent.js +12 -0
  161. package/build/dist/Events/ExEvent.js.map +1 -0
  162. package/build/dist/Events/MediaEvents.js +75 -0
  163. package/build/dist/Events/MediaEvents.js.map +1 -0
  164. package/build/dist/Events/PointerEvents.js +52 -0
  165. package/build/dist/Events/PointerEvents.js.map +1 -0
  166. package/build/dist/Events.js +473 -0
  167. package/build/dist/Events.js.map +1 -0
  168. package/build/dist/Flags.js +67 -0
  169. package/build/dist/Flags.js.map +1 -0
  170. package/build/dist/Graphics/Animation.js +344 -0
  171. package/build/dist/Graphics/Animation.js.map +1 -0
  172. package/build/dist/Graphics/Canvas.js +38 -0
  173. package/build/dist/Graphics/Canvas.js.map +1 -0
  174. package/build/dist/Graphics/Circle.js +48 -0
  175. package/build/dist/Graphics/Circle.js.map +1 -0
  176. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
  177. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
  178. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +237 -0
  179. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
  180. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
  181. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +481 -0
  182. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
  183. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +52 -52
  184. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +174 -0
  185. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
  186. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -37
  187. package/build/dist/Graphics/Context/debug-text.js +47 -0
  188. package/build/dist/Graphics/Context/debug-text.js.map +1 -0
  189. package/build/dist/Graphics/Context/draw-call.js +16 -0
  190. package/build/dist/Graphics/Context/draw-call.js.map +1 -0
  191. package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +32 -32
  192. package/build/dist/Graphics/Context/image-renderer/image-renderer.js +246 -0
  193. package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
  194. package/build/dist/Graphics/Context/image-renderer/image-renderer.vert.glsl +32 -32
  195. package/build/dist/Graphics/Context/line-renderer/line-fragment.glsl +10 -10
  196. package/build/dist/Graphics/Context/line-renderer/line-renderer.js +90 -0
  197. package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
  198. package/build/dist/Graphics/Context/line-renderer/line-vertex.glsl +14 -14
  199. package/build/dist/Graphics/Context/material-renderer/material-renderer.js +23 -2
  200. package/build/dist/Graphics/Context/material-renderer/material-renderer.js.map +1 -1
  201. package/build/dist/Graphics/Context/material.d.ts +2 -0
  202. package/build/dist/Graphics/Context/material.js +72 -0
  203. package/build/dist/Graphics/Context/material.js.map +1 -0
  204. package/build/dist/Graphics/Context/point-renderer/point-fragment.glsl +19 -19
  205. package/build/dist/Graphics/Context/point-renderer/point-renderer.js +91 -0
  206. package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
  207. package/build/dist/Graphics/Context/point-renderer/point-vertex.glsl +11 -11
  208. package/build/dist/Graphics/Context/quad-index-buffer.js +67 -0
  209. package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
  210. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -85
  211. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +305 -0
  212. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
  213. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -42
  214. package/build/dist/Graphics/Context/render-source.js +16 -0
  215. package/build/dist/Graphics/Context/render-source.js.map +1 -0
  216. package/build/dist/Graphics/Context/render-target.js +65 -0
  217. package/build/dist/Graphics/Context/render-target.js.map +1 -0
  218. package/build/dist/Graphics/Context/renderer.js +2 -0
  219. package/build/dist/Graphics/Context/renderer.js.map +1 -0
  220. package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +13 -13
  221. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +56 -0
  222. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
  223. package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -11
  224. package/build/dist/Graphics/Context/state-stack.js +37 -0
  225. package/build/dist/Graphics/Context/state-stack.js.map +1 -0
  226. package/build/dist/Graphics/Context/texture-loader.js +109 -0
  227. package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
  228. package/build/dist/Graphics/Context/transform-stack.js +30 -0
  229. package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
  230. package/build/dist/Graphics/Context/vertex-buffer.js +53 -0
  231. package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
  232. package/build/dist/Graphics/Context/webgl-util.js +79 -0
  233. package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
  234. package/build/dist/Graphics/DebugGraphicsComponent.d.ts +3 -2
  235. package/build/dist/Graphics/DebugGraphicsComponent.js +16 -0
  236. package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
  237. package/build/dist/Graphics/Filtering.js +17 -0
  238. package/build/dist/Graphics/Filtering.js.map +1 -0
  239. package/build/dist/Graphics/Font.js +148 -0
  240. package/build/dist/Graphics/Font.js.map +1 -0
  241. package/build/dist/Graphics/FontCache.d.ts +1 -0
  242. package/build/dist/Graphics/FontCache.js +80 -0
  243. package/build/dist/Graphics/FontCache.js.map +1 -0
  244. package/build/dist/Graphics/FontCommon.js +109 -0
  245. package/build/dist/Graphics/FontCommon.js.map +1 -0
  246. package/build/dist/Graphics/FontTextInstance.js +230 -0
  247. package/build/dist/Graphics/FontTextInstance.js.map +1 -0
  248. package/build/dist/Graphics/Graphic.js +208 -0
  249. package/build/dist/Graphics/Graphic.js.map +1 -0
  250. package/build/dist/Graphics/GraphicsComponent.js +336 -0
  251. package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
  252. package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
  253. package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
  254. package/build/dist/Graphics/GraphicsGroup.js +69 -0
  255. package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
  256. package/build/dist/Graphics/GraphicsSystem.js +210 -0
  257. package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
  258. package/build/dist/Graphics/ImageSource.js +124 -0
  259. package/build/dist/Graphics/ImageSource.js.map +1 -0
  260. package/build/dist/Graphics/Line.js +45 -0
  261. package/build/dist/Graphics/Line.js.map +1 -0
  262. package/build/dist/Graphics/OffscreenSystem.js +64 -0
  263. package/build/dist/Graphics/OffscreenSystem.js.map +1 -0
  264. package/build/dist/Graphics/ParallaxComponent.js +11 -0
  265. package/build/dist/Graphics/ParallaxComponent.js.map +1 -0
  266. package/build/dist/Graphics/Polygon.js +59 -0
  267. package/build/dist/Graphics/Polygon.js.map +1 -0
  268. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
  269. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
  270. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
  271. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
  272. package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
  273. package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
  274. package/build/dist/Graphics/PostProcessor/ScreenShader.js +59 -0
  275. package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
  276. package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +64 -64
  277. package/build/dist/Graphics/Raster.js +215 -0
  278. package/build/dist/Graphics/Raster.js.map +1 -0
  279. package/build/dist/Graphics/Rectangle.js +29 -0
  280. package/build/dist/Graphics/Rectangle.js.map +1 -0
  281. package/build/dist/Graphics/Sprite.js +82 -0
  282. package/build/dist/Graphics/Sprite.js.map +1 -0
  283. package/build/dist/Graphics/SpriteFont.js +139 -0
  284. package/build/dist/Graphics/SpriteFont.js.map +1 -0
  285. package/build/dist/Graphics/SpriteSheet.js +116 -0
  286. package/build/dist/Graphics/SpriteSheet.js.map +1 -0
  287. package/build/dist/Graphics/Text.js +103 -0
  288. package/build/dist/Graphics/Text.js.map +1 -0
  289. package/build/dist/Graphics/index.js +46 -0
  290. package/build/dist/Graphics/index.js.map +1 -0
  291. package/build/dist/Id.js +8 -0
  292. package/build/dist/Id.js.map +1 -0
  293. package/build/dist/Input/CapturePointerConfig.js +5 -0
  294. package/build/dist/Input/CapturePointerConfig.js.map +1 -0
  295. package/build/dist/Input/EngineInput.js +2 -0
  296. package/build/dist/Input/EngineInput.js.map +1 -0
  297. package/build/dist/Input/Gamepad.js +422 -0
  298. package/build/dist/Input/Gamepad.js.map +1 -0
  299. package/build/dist/Input/Index.js +88 -0
  300. package/build/dist/Input/Index.js.map +1 -0
  301. package/build/dist/Input/InputMapper.js +45 -0
  302. package/build/dist/Input/InputMapper.js.map +1 -0
  303. package/build/dist/Input/Keyboard.js +348 -0
  304. package/build/dist/Input/Keyboard.js.map +1 -0
  305. package/build/dist/Input/NativePointerButton.js +12 -0
  306. package/build/dist/Input/NativePointerButton.js.map +1 -0
  307. package/build/dist/Input/PointerAbstraction.js +44 -0
  308. package/build/dist/Input/PointerAbstraction.js.map +1 -0
  309. package/build/dist/Input/PointerButton.js +12 -0
  310. package/build/dist/Input/PointerButton.js.map +1 -0
  311. package/build/dist/Input/PointerComponent.js +28 -0
  312. package/build/dist/Input/PointerComponent.js.map +1 -0
  313. package/build/dist/Input/PointerEvent.js +25 -0
  314. package/build/dist/Input/PointerEvent.js.map +1 -0
  315. package/build/dist/Input/PointerEventReceiver.js +456 -0
  316. package/build/dist/Input/PointerEventReceiver.js.map +1 -0
  317. package/build/dist/Input/PointerScope.js +16 -0
  318. package/build/dist/Input/PointerScope.js.map +1 -0
  319. package/build/dist/Input/PointerSystem.js +249 -0
  320. package/build/dist/Input/PointerSystem.js.map +1 -0
  321. package/build/dist/Input/PointerType.js +11 -0
  322. package/build/dist/Input/PointerType.js.map +1 -0
  323. package/build/dist/Input/WheelDeltaMode.js +7 -0
  324. package/build/dist/Input/WheelDeltaMode.js.map +1 -0
  325. package/build/dist/Input/WheelEvent.js +21 -0
  326. package/build/dist/Input/WheelEvent.js.map +1 -0
  327. package/build/dist/Interfaces/Audio.js +2 -0
  328. package/build/dist/Interfaces/Audio.js.map +1 -0
  329. package/build/dist/Interfaces/AudioImplementation.js +11 -0
  330. package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
  331. package/build/dist/Interfaces/Clonable.js +2 -0
  332. package/build/dist/Interfaces/Clonable.js.map +1 -0
  333. package/build/dist/Interfaces/Evented.js +2 -0
  334. package/build/dist/Interfaces/Evented.js.map +1 -0
  335. package/build/dist/Interfaces/Index.js +8 -0
  336. package/build/dist/Interfaces/Index.js.map +1 -0
  337. package/build/dist/Interfaces/LifecycleEvents.js +51 -0
  338. package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
  339. package/build/dist/Interfaces/Loadable.js +2 -0
  340. package/build/dist/Interfaces/Loadable.js.map +1 -0
  341. package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
  342. package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
  343. package/build/dist/Label.js +81 -0
  344. package/build/dist/Label.js.map +1 -0
  345. package/build/dist/Loader.js +416 -0
  346. package/build/dist/Loader.js.map +1 -0
  347. package/build/dist/Math/Index.js +13 -0
  348. package/build/dist/Math/Index.js.map +1 -0
  349. package/build/dist/Math/Random.js +239 -0
  350. package/build/dist/Math/Random.js.map +1 -0
  351. package/build/dist/Math/affine-matrix.js +331 -0
  352. package/build/dist/Math/affine-matrix.js.map +1 -0
  353. package/build/dist/Math/coord-plane.js +17 -0
  354. package/build/dist/Math/coord-plane.js.map +1 -0
  355. package/build/dist/Math/global-coordinates.js +30 -0
  356. package/build/dist/Math/global-coordinates.js.map +1 -0
  357. package/build/dist/Math/line-segment.js +205 -0
  358. package/build/dist/Math/line-segment.js.map +1 -0
  359. package/build/dist/Math/matrix.js +457 -0
  360. package/build/dist/Math/matrix.js.map +1 -0
  361. package/build/dist/Math/projection.js +24 -0
  362. package/build/dist/Math/projection.js.map +1 -0
  363. package/build/dist/Math/ray.js +52 -0
  364. package/build/dist/Math/ray.js.map +1 -0
  365. package/build/dist/Math/transform.js +219 -0
  366. package/build/dist/Math/transform.js.map +1 -0
  367. package/build/dist/Math/util.js +82 -0
  368. package/build/dist/Math/util.js.map +1 -0
  369. package/build/dist/Math/vector-view.js +25 -0
  370. package/build/dist/Math/vector-view.js.map +1 -0
  371. package/build/dist/Math/vector.js +340 -0
  372. package/build/dist/Math/vector.js.map +1 -0
  373. package/build/dist/Math/watch-vector.js +26 -0
  374. package/build/dist/Math/watch-vector.js.map +1 -0
  375. package/build/dist/Particles.js +430 -0
  376. package/build/dist/Particles.js.map +1 -0
  377. package/build/dist/Polyfill.js +56 -0
  378. package/build/dist/Polyfill.js.map +1 -0
  379. package/build/dist/Resources/Gif.js +464 -0
  380. package/build/dist/Resources/Gif.js.map +1 -0
  381. package/build/dist/Resources/Index.js +4 -0
  382. package/build/dist/Resources/Index.js.map +1 -0
  383. package/build/dist/Resources/Resource.js +81 -0
  384. package/build/dist/Resources/Resource.js.map +1 -0
  385. package/build/dist/Resources/Sound/AudioContext.js +16 -0
  386. package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
  387. package/build/dist/Resources/Sound/Index.js +4 -0
  388. package/build/dist/Resources/Sound/Index.js.map +1 -0
  389. package/build/dist/Resources/Sound/Sound.js +326 -0
  390. package/build/dist/Resources/Sound/Sound.js.map +1 -0
  391. package/build/dist/Resources/Sound/WebAudioInstance.js +190 -0
  392. package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
  393. package/build/dist/Scene.js +444 -0
  394. package/build/dist/Scene.js.map +1 -0
  395. package/build/dist/Screen.js +782 -0
  396. package/build/dist/Screen.js.map +1 -0
  397. package/build/dist/ScreenElement.js +43 -0
  398. package/build/dist/ScreenElement.js.map +1 -0
  399. package/build/dist/TileMap/IsometricEntityComponent.js +17 -0
  400. package/build/dist/TileMap/IsometricEntityComponent.js.map +1 -0
  401. package/build/dist/TileMap/IsometricEntitySystem.js +23 -0
  402. package/build/dist/TileMap/IsometricEntitySystem.js.map +1 -0
  403. package/build/dist/TileMap/IsometricMap.js +311 -0
  404. package/build/dist/TileMap/IsometricMap.js.map +1 -0
  405. package/build/dist/TileMap/TileMap.d.ts +2 -1
  406. package/build/dist/TileMap/TileMap.js +630 -0
  407. package/build/dist/TileMap/TileMap.js.map +1 -0
  408. package/build/dist/TileMap/index.js +5 -0
  409. package/build/dist/TileMap/index.js.map +1 -0
  410. package/build/dist/Timer.js +202 -0
  411. package/build/dist/Timer.js.map +1 -0
  412. package/build/dist/Trigger.js +94 -0
  413. package/build/dist/Trigger.js.map +1 -0
  414. package/build/dist/Util/Browser.js +66 -0
  415. package/build/dist/Util/Browser.js.map +1 -0
  416. package/build/dist/Util/Clock.js +219 -0
  417. package/build/dist/Util/Clock.js.map +1 -0
  418. package/build/dist/Util/Decorators.js +78 -0
  419. package/build/dist/Util/Decorators.js.map +1 -0
  420. package/build/dist/Util/Detector.js +167 -0
  421. package/build/dist/Util/Detector.js.map +1 -0
  422. package/build/dist/Util/DrawUtil.js +115 -0
  423. package/build/dist/Util/DrawUtil.js.map +1 -0
  424. package/build/dist/Util/EasingFunctions.js +102 -0
  425. package/build/dist/Util/EasingFunctions.js.map +1 -0
  426. package/build/dist/Util/Fps.js +47 -0
  427. package/build/dist/Util/Fps.js.map +1 -0
  428. package/build/dist/Util/Future.js +30 -0
  429. package/build/dist/Util/Future.js.map +1 -0
  430. package/build/dist/Util/IFrame.js +23 -0
  431. package/build/dist/Util/IFrame.js.map +1 -0
  432. package/build/dist/Util/Index.js +7 -0
  433. package/build/dist/Util/Index.js.map +1 -0
  434. package/build/dist/Util/Log.js +195 -0
  435. package/build/dist/Util/Log.js.map +1 -0
  436. package/build/dist/Util/Observable.js +66 -0
  437. package/build/dist/Util/Observable.js.map +1 -0
  438. package/build/dist/Util/Pool.js +74 -0
  439. package/build/dist/Util/Pool.js.map +1 -0
  440. package/build/dist/Util/Semaphore.js +55 -0
  441. package/build/dist/Util/Semaphore.js.map +1 -0
  442. package/build/dist/Util/Sound.js +22 -0
  443. package/build/dist/Util/Sound.js.map +1 -0
  444. package/build/dist/Util/StateMachine.js +79 -0
  445. package/build/dist/Util/StateMachine.js.map +1 -0
  446. package/build/dist/Util/Toaster.css +28 -28
  447. package/build/dist/Util/Toaster.js +84 -0
  448. package/build/dist/Util/Toaster.js.map +1 -0
  449. package/build/dist/Util/Util.d.ts +6 -0
  450. package/build/dist/Util/Util.js +95 -0
  451. package/build/dist/Util/Util.js.map +1 -0
  452. package/build/dist/Util/Watch.js +67 -0
  453. package/build/dist/Util/Watch.js.map +1 -0
  454. package/build/dist/Util/WebAudio.js +62 -0
  455. package/build/dist/Util/WebAudio.js.map +1 -0
  456. package/build/dist/excalibur.d.ts +2 -2
  457. package/build/dist/excalibur.js +389 -258
  458. package/build/dist/excalibur.js.map +1 -1
  459. package/build/dist/excalibur.min.js +1 -1
  460. package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
  461. package/build/dist/excalibur.min.js.map +1 -1
  462. package/build/dist/index.js +81 -0
  463. package/build/dist/index.js.map +1 -0
  464. package/build/esm/Debug/Debug.d.ts +11 -0
  465. package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
  466. package/build/esm/Graphics/Context/material.d.ts +2 -0
  467. package/build/esm/Graphics/DebugGraphicsComponent.d.ts +3 -2
  468. package/build/esm/Graphics/FontCache.d.ts +1 -0
  469. package/build/esm/TileMap/TileMap.d.ts +2 -1
  470. package/build/esm/Util/Util.d.ts +6 -0
  471. package/build/esm/excalibur.d.ts +2 -2
  472. package/build/esm/excalibur.js +389 -258
  473. package/build/esm/excalibur.js.map +1 -1
  474. package/build/esm/excalibur.min.js +1 -1
  475. package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
  476. package/build/esm/excalibur.min.js.map +1 -1
  477. package/docker-compose.yml +11 -11
  478. package/package.json +131 -131
  479. package/build/dist/Loader.css +0 -122
  480. package/build/nuget/Excalibur.0.28.3.nupkg +0 -0
  481. package/build/v0.28.3.zip +0 -0
  482. package/excalibur-0.28.3.tgz +0 -0
@@ -0,0 +1,487 @@
1
+ import { Component, TagComponent } from './Component';
2
+ import { Observable } from '../Util/Observable';
3
+ import { InitializeEvent, PreUpdateEvent, PostUpdateEvent } from '../Events';
4
+ import { EventEmitter, Util } from '..';
5
+ /**
6
+ * AddedComponent message
7
+ */
8
+ export class AddedComponent {
9
+ constructor(data) {
10
+ this.data = data;
11
+ this.type = 'Component Added';
12
+ }
13
+ }
14
+ /**
15
+ * Type guard to know if message is f an Added Component
16
+ */
17
+ export function isAddedComponent(x) {
18
+ return !!x && x.type === 'Component Added';
19
+ }
20
+ /**
21
+ * RemovedComponent message
22
+ */
23
+ export class RemovedComponent {
24
+ constructor(data) {
25
+ this.data = data;
26
+ this.type = 'Component Removed';
27
+ }
28
+ }
29
+ /**
30
+ * Type guard to know if message is for a Removed Component
31
+ */
32
+ export function isRemovedComponent(x) {
33
+ return !!x && x.type === 'Component Removed';
34
+ }
35
+ export const EntityEvents = {
36
+ Initialize: 'initialize',
37
+ PreUpdate: 'preupdate',
38
+ PostUpdate: 'postupdate'
39
+ };
40
+ /**
41
+ * An Entity is the base type of anything that can have behavior in Excalibur, they are part of the built in entity component system
42
+ *
43
+ * Entities can be strongly typed with the components they contain
44
+ *
45
+ * ```typescript
46
+ * const entity = new Entity<ComponentA | ComponentB>();
47
+ * entity.components.a; // Type ComponentA
48
+ * entity.components.b; // Type ComponentB
49
+ * ```
50
+ */
51
+ export class Entity {
52
+ constructor(components, name) {
53
+ /**
54
+ * Listen to or emit events for an entity
55
+ */
56
+ this.events = new EventEmitter();
57
+ /**
58
+ * The unique identifier for the entity
59
+ */
60
+ this.id = Entity._ID++;
61
+ /**
62
+ * The scene that the entity is in, if any
63
+ */
64
+ this.scene = null;
65
+ this._name = 'anonymous';
66
+ /**
67
+ * Whether this entity is active, if set to false it will be reclaimed
68
+ */
69
+ this.active = true;
70
+ /**
71
+ * Bucket to hold on to deferred removals
72
+ */
73
+ this._componentsToRemove = [];
74
+ this._componentTypeToInstance = new Map();
75
+ this._componentStringToInstance = new Map();
76
+ this._tagsMemo = [];
77
+ this._typesMemo = [];
78
+ /**
79
+ * Observable that keeps track of component add or remove changes on the entity
80
+ */
81
+ this.componentAdded$ = new Observable();
82
+ this.componentRemoved$ = new Observable();
83
+ this._parent = null;
84
+ this.childrenAdded$ = new Observable();
85
+ this.childrenRemoved$ = new Observable();
86
+ this._children = [];
87
+ this._isInitialized = false;
88
+ this._setName(name);
89
+ if (components) {
90
+ for (const component of components) {
91
+ this.addComponent(component);
92
+ }
93
+ }
94
+ }
95
+ _setName(name) {
96
+ if (name) {
97
+ this._name = name;
98
+ }
99
+ else {
100
+ this._name = `Entity#${this.id}`;
101
+ }
102
+ }
103
+ get name() {
104
+ return this._name;
105
+ }
106
+ set name(name) {
107
+ this._setName(name);
108
+ }
109
+ /**
110
+ * Kill the entity, means it will no longer be updated. Kills are deferred to the end of the update.
111
+ * If parented it will be removed from the parent when killed.
112
+ */
113
+ kill() {
114
+ if (this.active) {
115
+ this.active = false;
116
+ this.unparent();
117
+ }
118
+ }
119
+ isKilled() {
120
+ return !this.active;
121
+ }
122
+ /**
123
+ * Specifically get the tags on the entity from [[TagComponent]]
124
+ */
125
+ get tags() {
126
+ return this._tagsMemo;
127
+ }
128
+ /**
129
+ * Check if a tag exists on the entity
130
+ * @param tag name to check for
131
+ */
132
+ hasTag(tag) {
133
+ return this.tags.includes(tag);
134
+ }
135
+ /**
136
+ * Adds a tag to an entity
137
+ * @param tag
138
+ * @returns Entity
139
+ */
140
+ addTag(tag) {
141
+ return this.addComponent(new TagComponent(tag));
142
+ }
143
+ /**
144
+ * Removes a tag on the entity
145
+ *
146
+ * Removals are deferred until the end of update
147
+ * @param tag
148
+ * @param force Remove component immediately, no deferred
149
+ */
150
+ removeTag(tag, force = false) {
151
+ return this.removeComponent(tag, force);
152
+ }
153
+ /**
154
+ * The types of the components on the Entity
155
+ */
156
+ get types() {
157
+ return this._typesMemo;
158
+ }
159
+ _rebuildMemos() {
160
+ this._tagsMemo = Array.from(this._componentStringToInstance.values())
161
+ .filter((c) => c instanceof TagComponent)
162
+ .map((c) => c.type);
163
+ this._typesMemo = Array.from(this._componentStringToInstance.keys());
164
+ }
165
+ getComponents() {
166
+ return Array.from(this._componentStringToInstance.values());
167
+ }
168
+ _notifyAddComponent(component) {
169
+ this._rebuildMemos();
170
+ const added = new AddedComponent({
171
+ component,
172
+ entity: this
173
+ });
174
+ this.componentAdded$.notifyAll(added);
175
+ }
176
+ _notifyRemoveComponent(component) {
177
+ const removed = new RemovedComponent({
178
+ component,
179
+ entity: this
180
+ });
181
+ this.componentRemoved$.notifyAll(removed);
182
+ this._rebuildMemos();
183
+ }
184
+ get parent() {
185
+ return this._parent;
186
+ }
187
+ /**
188
+ * Get the direct children of this entity
189
+ */
190
+ get children() {
191
+ return this._children;
192
+ }
193
+ /**
194
+ * Unparents this entity, if there is a parent. Otherwise it does nothing.
195
+ */
196
+ unparent() {
197
+ if (this._parent) {
198
+ this._parent.removeChild(this);
199
+ this._parent = null;
200
+ }
201
+ }
202
+ /**
203
+ * Adds an entity to be a child of this entity
204
+ * @param entity
205
+ */
206
+ addChild(entity) {
207
+ if (entity.parent === null) {
208
+ if (this.getAncestors().includes(entity)) {
209
+ throw new Error('Cycle detected, cannot add entity');
210
+ }
211
+ this._children.push(entity);
212
+ entity._parent = this;
213
+ this.childrenAdded$.notifyAll(entity);
214
+ }
215
+ else {
216
+ throw new Error('Entity already has a parent, cannot add without unparenting');
217
+ }
218
+ return this;
219
+ }
220
+ /**
221
+ * Remove an entity from children if it exists
222
+ * @param entity
223
+ */
224
+ removeChild(entity) {
225
+ if (entity.parent === this) {
226
+ Util.removeItemFromArray(entity, this._children);
227
+ entity._parent = null;
228
+ this.childrenRemoved$.notifyAll(entity);
229
+ }
230
+ return this;
231
+ }
232
+ /**
233
+ * Removes all children from this entity
234
+ */
235
+ removeAllChildren() {
236
+ // Avoid modifying the array issue by walking backwards
237
+ for (let i = this.children.length - 1; i >= 0; i--) {
238
+ this.removeChild(this.children[i]);
239
+ }
240
+ return this;
241
+ }
242
+ /**
243
+ * Returns a list of parent entities starting with the topmost parent. Includes the current entity.
244
+ */
245
+ getAncestors() {
246
+ const result = [this];
247
+ let current = this.parent;
248
+ while (current) {
249
+ result.push(current);
250
+ current = current.parent;
251
+ }
252
+ return result.reverse();
253
+ }
254
+ /**
255
+ * Returns a list of all the entities that descend from this entity. Includes the current entity.
256
+ */
257
+ getDescendants() {
258
+ let result = [this];
259
+ let queue = [this];
260
+ while (queue.length > 0) {
261
+ const curr = queue.pop();
262
+ queue = queue.concat(curr.children);
263
+ result = result.concat(curr.children);
264
+ }
265
+ return result;
266
+ }
267
+ /**
268
+ * Creates a deep copy of the entity and a copy of all its components
269
+ */
270
+ clone() {
271
+ const newEntity = new Entity();
272
+ for (const c of this.types) {
273
+ newEntity.addComponent(this.get(c).clone());
274
+ }
275
+ for (const child of this.children) {
276
+ newEntity.addChild(child.clone());
277
+ }
278
+ return newEntity;
279
+ }
280
+ /**
281
+ * Adds a copy of all the components from another template entity as a "prefab"
282
+ * @param templateEntity Entity to use as a template
283
+ * @param force Force component replacement if it already exists on the target entity
284
+ */
285
+ addTemplate(templateEntity, force = false) {
286
+ for (const c of templateEntity.getComponents()) {
287
+ this.addComponent(c.clone(), force);
288
+ }
289
+ for (const child of templateEntity.children) {
290
+ this.addChild(child.clone().addTemplate(child));
291
+ }
292
+ return this;
293
+ }
294
+ /**
295
+ * Adds a component to the entity
296
+ * @param component Component or Entity to add copy of components from
297
+ * @param force Optionally overwrite any existing components of the same type
298
+ */
299
+ addComponent(component, force = false) {
300
+ // if component already exists, skip if not forced
301
+ if (this.has(component.type)) {
302
+ if (force) {
303
+ // Remove existing component type if exists when forced
304
+ this.removeComponent(component, true);
305
+ }
306
+ else {
307
+ // early exit component exits
308
+ return this;
309
+ }
310
+ }
311
+ // TODO circular dependencies will be a problem
312
+ if (component.dependencies && component.dependencies.length) {
313
+ for (const ctor of component.dependencies) {
314
+ this.addComponent(new ctor());
315
+ }
316
+ }
317
+ component.owner = this;
318
+ const constuctorType = component.constructor;
319
+ this._componentTypeToInstance.set(constuctorType, component);
320
+ this._componentStringToInstance.set(component.type, component);
321
+ if (component.onAdd) {
322
+ component.onAdd(this);
323
+ }
324
+ this._notifyAddComponent(component);
325
+ return this;
326
+ }
327
+ /**
328
+ * Removes a component from the entity, by default removals are deferred to the end of entity update to avoid consistency issues
329
+ *
330
+ * Components can be force removed with the `force` flag, the removal is not deferred and happens immediately
331
+ * @param componentOrType
332
+ * @param force
333
+ */
334
+ removeComponent(componentOrType, force = false) {
335
+ if (force) {
336
+ if (typeof componentOrType === 'string') {
337
+ this._removeComponentByType(componentOrType);
338
+ }
339
+ else if (componentOrType instanceof Component) {
340
+ this._removeComponentByType(componentOrType.type);
341
+ }
342
+ }
343
+ else {
344
+ this._componentsToRemove.push(componentOrType);
345
+ }
346
+ return this;
347
+ }
348
+ clearComponents() {
349
+ const components = this.getComponents();
350
+ for (const c of components) {
351
+ this.removeComponent(c);
352
+ }
353
+ }
354
+ _removeComponentByType(type) {
355
+ if (this.has(type)) {
356
+ const component = this.get(type);
357
+ component.owner = null;
358
+ if (component.onRemove) {
359
+ component.onRemove(this);
360
+ }
361
+ const ctor = component.constructor;
362
+ this._componentTypeToInstance.delete(ctor);
363
+ this._componentStringToInstance.delete(component.type);
364
+ this._notifyRemoveComponent(component);
365
+ }
366
+ }
367
+ /**
368
+ * @hidden
369
+ * @internal
370
+ */
371
+ processComponentRemoval() {
372
+ for (const componentOrType of this._componentsToRemove) {
373
+ const type = typeof componentOrType === 'string' ? componentOrType : componentOrType.type;
374
+ this._removeComponentByType(type);
375
+ }
376
+ this._componentsToRemove.length = 0;
377
+ }
378
+ has(type) {
379
+ if (typeof type === 'string') {
380
+ return this._componentStringToInstance.has(type);
381
+ }
382
+ else {
383
+ return this._componentTypeToInstance.has(type);
384
+ }
385
+ }
386
+ get(type) {
387
+ if (typeof type === 'string') {
388
+ return this._componentStringToInstance.get(type);
389
+ }
390
+ else {
391
+ return this._componentTypeToInstance.get(type);
392
+ }
393
+ }
394
+ /**
395
+ * Gets whether the actor is Initialized
396
+ */
397
+ get isInitialized() {
398
+ return this._isInitialized;
399
+ }
400
+ /**
401
+ * Initializes this entity, meant to be called by the Scene before first update not by users of Excalibur.
402
+ *
403
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
404
+ * @internal
405
+ */
406
+ _initialize(engine) {
407
+ if (!this.isInitialized) {
408
+ this.onInitialize(engine);
409
+ this.events.emit('initialize', new InitializeEvent(engine, this));
410
+ this._isInitialized = true;
411
+ }
412
+ }
413
+ /**
414
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
415
+ *
416
+ * Internal _preupdate handler for [[onPreUpdate]] lifecycle event
417
+ * @internal
418
+ */
419
+ _preupdate(engine, delta) {
420
+ this.events.emit('preupdate', new PreUpdateEvent(engine, delta, this));
421
+ this.onPreUpdate(engine, delta);
422
+ }
423
+ /**
424
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
425
+ *
426
+ * Internal _preupdate handler for [[onPostUpdate]] lifecycle event
427
+ * @internal
428
+ */
429
+ _postupdate(engine, delta) {
430
+ this.events.emit('postupdate', new PostUpdateEvent(engine, delta, this));
431
+ this.onPostUpdate(engine, delta);
432
+ }
433
+ /**
434
+ * `onInitialize` is called before the first update of the entity. This method is meant to be
435
+ * overridden.
436
+ *
437
+ * Synonymous with the event handler `.on('initialize', (evt) => {...})`
438
+ */
439
+ onInitialize(_engine) {
440
+ // Override me
441
+ }
442
+ /**
443
+ * Safe to override onPreUpdate lifecycle event handler. Synonymous with `.on('preupdate', (evt) =>{...})`
444
+ *
445
+ * `onPreUpdate` is called directly before an entity is updated.
446
+ */
447
+ onPreUpdate(_engine, _delta) {
448
+ // Override me
449
+ }
450
+ /**
451
+ * Safe to override onPostUpdate lifecycle event handler. Synonymous with `.on('postupdate', (evt) =>{...})`
452
+ *
453
+ * `onPostUpdate` is called directly after an entity is updated.
454
+ */
455
+ onPostUpdate(_engine, _delta) {
456
+ // Override me
457
+ }
458
+ /**
459
+ *
460
+ *Entity update lifecycle, called internally
461
+ * @internal
462
+ * @param engine
463
+ * @param delta
464
+ */
465
+ update(engine, delta) {
466
+ this._initialize(engine);
467
+ this._preupdate(engine, delta);
468
+ for (const child of this.children) {
469
+ child.update(engine, delta);
470
+ }
471
+ this._postupdate(engine, delta);
472
+ }
473
+ emit(eventName, event) {
474
+ this.events.emit(eventName, event);
475
+ }
476
+ on(eventName, handler) {
477
+ return this.events.on(eventName, handler);
478
+ }
479
+ once(eventName, handler) {
480
+ return this.events.once(eventName, handler);
481
+ }
482
+ off(eventName, handler) {
483
+ this.events.off(eventName, handler);
484
+ }
485
+ }
486
+ Entity._ID = 0;
487
+ //# sourceMappingURL=Entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../../src/engine/EntityComponentSystem/Entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,UAAU,EAAW,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,YAAY,EAA0C,IAAI,EAAE,MAAM,IAAI,CAAC;AAUhF;;GAEG;AACH,MAAM,OAAO,cAAc;IAEzB,YAAmB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QAD/B,SAAI,GAAsB,iBAAiB,CAAC;IACV,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAA2B;IAC1D,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAE3B,YAAmB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QAD/B,SAAI,GAAwB,mBAAmB,CAAC;IACd,CAAC;CAC7C;AAED;;GAEG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,EAAE,OAAqB;QACxG,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAIM,IAAI,CAAqD,SAAqB,EAAE,OAAqB;QAC1G,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAKM,GAAG,CAAqD,SAAqB,EAAE,OAAsB;QAC1G,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;;AAvfc,UAAG,GAAG,CAAC,AAAJ,CAAK"}
@@ -0,0 +1,137 @@
1
+ import { Entity, isAddedComponent, isRemovedComponent } from './Entity';
2
+ import { Util } from '..';
3
+ // Add/Remove entities and components
4
+ export class EntityManager {
5
+ constructor(_world) {
6
+ this._world = _world;
7
+ this.entities = [];
8
+ this._entityIndex = {};
9
+ this._entitiesToRemove = [];
10
+ }
11
+ /**
12
+ * Runs the entity lifecycle
13
+ * @param _context
14
+ */
15
+ updateEntities(_context, elapsed) {
16
+ for (const entity of this.entities) {
17
+ // TODO is this right?
18
+ entity.update(_context.engine, elapsed);
19
+ if (!entity.active) {
20
+ this.removeEntity(entity);
21
+ }
22
+ }
23
+ }
24
+ findEntitiesForRemoval() {
25
+ for (const entity of this.entities) {
26
+ if (!entity.active) {
27
+ this.removeEntity(entity);
28
+ }
29
+ }
30
+ }
31
+ /**
32
+ * EntityManager observes changes on entities
33
+ * @param message
34
+ */
35
+ notify(message) {
36
+ if (isAddedComponent(message)) {
37
+ // we don't need the component, it's already on the entity
38
+ this._world.queryManager.addEntity(message.data.entity);
39
+ }
40
+ if (isRemovedComponent(message)) {
41
+ this._world.queryManager.removeComponent(message.data.entity, message.data.component);
42
+ }
43
+ }
44
+ /**
45
+ * Adds an entity to be tracked by the EntityManager
46
+ * @param entity
47
+ */
48
+ addEntity(entity) {
49
+ entity.active = true;
50
+ entity.scene = this._world.context;
51
+ if (entity && !this._entityIndex[entity.id]) {
52
+ this._entityIndex[entity.id] = entity;
53
+ this.entities.push(entity);
54
+ this._world.queryManager.addEntity(entity);
55
+ entity.componentAdded$.register(this);
56
+ entity.componentRemoved$.register(this);
57
+ // if entity has children
58
+ entity.children.forEach((c) => {
59
+ c.scene = entity.scene;
60
+ this.addEntity(c);
61
+ });
62
+ entity.childrenAdded$.register({
63
+ notify: (e) => {
64
+ this.addEntity(e);
65
+ }
66
+ });
67
+ entity.childrenRemoved$.register({
68
+ notify: (e) => {
69
+ this.removeEntity(e, false);
70
+ }
71
+ });
72
+ }
73
+ }
74
+ removeEntity(idOrEntity, deferred = true) {
75
+ var _a;
76
+ let id = 0;
77
+ if (idOrEntity instanceof Entity) {
78
+ id = idOrEntity.id;
79
+ }
80
+ else {
81
+ id = idOrEntity;
82
+ }
83
+ const entity = this._entityIndex[id];
84
+ if (entity && entity.active) {
85
+ entity.active = false;
86
+ }
87
+ if (entity && deferred) {
88
+ this._entitiesToRemove.push(entity);
89
+ return;
90
+ }
91
+ delete this._entityIndex[id];
92
+ if (entity) {
93
+ entity.scene = null;
94
+ Util.removeItemFromArray(entity, this.entities);
95
+ this._world.queryManager.removeEntity(entity);
96
+ entity.componentAdded$.unregister(this);
97
+ entity.componentRemoved$.unregister(this);
98
+ // if entity has children
99
+ entity.children.forEach((c) => {
100
+ c.scene = null;
101
+ this.removeEntity(c, deferred);
102
+ });
103
+ entity.childrenAdded$.clear();
104
+ entity.childrenRemoved$.clear();
105
+ // stats
106
+ if ((_a = this._world.context) === null || _a === void 0 ? void 0 : _a.engine) {
107
+ this._world.context.engine.stats.currFrame.actors.killed++;
108
+ }
109
+ }
110
+ }
111
+ processEntityRemovals() {
112
+ for (const entity of this._entitiesToRemove) {
113
+ if (entity.active) {
114
+ continue;
115
+ }
116
+ this.removeEntity(entity, false);
117
+ }
118
+ this._entitiesToRemove.length = 0;
119
+ }
120
+ processComponentRemovals() {
121
+ for (const entity of this.entities) {
122
+ entity.processComponentRemoval();
123
+ }
124
+ }
125
+ getById(id) {
126
+ return this._entityIndex[id];
127
+ }
128
+ getByName(name) {
129
+ return this.entities.filter(e => e.name === name);
130
+ }
131
+ clear() {
132
+ for (let i = this.entities.length - 1; i >= 0; i--) {
133
+ this.removeEntity(this.entities[i]);
134
+ }
135
+ }
136
+ }
137
+ //# sourceMappingURL=EntityManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityManager.js","sourceRoot":"","sources":["../../../src/engine/EntityComponentSystem/EntityManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoC,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG1G,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,qCAAqC;AAErC,MAAM,OAAO,aAAa;IAIxB,YAAoB,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;QAHvC,aAAQ,GAAa,EAAE,CAAC;QACxB,iBAAY,GAAmC,EAAE,CAAC;QAmHjD,sBAAiB,GAAa,EAAE,CAAC;IAjHQ,CAAC;IAElD;;;OAGG;IACI,cAAc,CAAC,QAAqB,EAAE,OAAe;QAC1D,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,sBAAsB;YACtB,MAAM,CAAC,MAAM,CAAE,QAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAEM,sBAAsB;QAC3B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;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