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.
- package/.gitattributes +63 -63
- package/CHANGELOG.md +2003 -1955
- package/LICENSE.md +25 -25
- package/README.md +134 -134
- package/STYLEGUIDE.md +136 -136
- package/build/dist/Actions/Action/ActionSequence.js +31 -0
- package/build/dist/Actions/Action/ActionSequence.js.map +1 -0
- package/build/dist/Actions/Action/Blink.js +54 -0
- package/build/dist/Actions/Action/Blink.js.map +1 -0
- package/build/dist/Actions/Action/CallMethod.js +21 -0
- package/build/dist/Actions/Action/CallMethod.js.map +1 -0
- package/build/dist/Actions/Action/Delay.js +26 -0
- package/build/dist/Actions/Action/Delay.js.map +1 -0
- package/build/dist/Actions/Action/Die.js +22 -0
- package/build/dist/Actions/Action/Die.js.map +1 -0
- package/build/dist/Actions/Action/EaseBy.js +70 -0
- package/build/dist/Actions/Action/EaseBy.js.map +1 -0
- package/build/dist/Actions/Action/EaseTo.js +69 -0
- package/build/dist/Actions/Action/EaseTo.js.map +1 -0
- package/build/dist/Actions/Action/Fade.js +48 -0
- package/build/dist/Actions/Action/Fade.js.map +1 -0
- package/build/dist/Actions/Action/Follow.js +56 -0
- package/build/dist/Actions/Action/Follow.js.map +1 -0
- package/build/dist/Actions/Action/Meet.js +54 -0
- package/build/dist/Actions/Action/Meet.js.map +1 -0
- package/build/dist/Actions/Action/MoveBy.js +48 -0
- package/build/dist/Actions/Action/MoveBy.js.map +1 -0
- package/build/dist/Actions/Action/MoveTo.js +41 -0
- package/build/dist/Actions/Action/MoveTo.js.map +1 -0
- package/build/dist/Actions/Action/ParallelActions.js +23 -0
- package/build/dist/Actions/Action/ParallelActions.js.map +1 -0
- package/build/dist/Actions/Action/Repeat.js +31 -0
- package/build/dist/Actions/Action/Repeat.js.map +1 -0
- package/build/dist/Actions/Action/RepeatForever.js +37 -0
- package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
- package/build/dist/Actions/Action/RotateBy.js +95 -0
- package/build/dist/Actions/Action/RotateBy.js.map +1 -0
- package/build/dist/Actions/Action/RotateTo.js +91 -0
- package/build/dist/Actions/Action/RotateTo.js.map +1 -0
- package/build/dist/Actions/Action/ScaleBy.js +46 -0
- package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
- package/build/dist/Actions/Action/ScaleTo.js +58 -0
- package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
- package/build/dist/Actions/Action.js +2 -0
- package/build/dist/Actions/Action.js.map +1 -0
- package/build/dist/Actions/ActionContext.js +322 -0
- package/build/dist/Actions/ActionContext.js.map +1 -0
- package/build/dist/Actions/ActionQueue.js +87 -0
- package/build/dist/Actions/ActionQueue.js.map +1 -0
- package/build/dist/Actions/Actionable.js +2 -0
- package/build/dist/Actions/Actionable.js.map +1 -0
- package/build/dist/Actions/ActionsComponent.js +195 -0
- package/build/dist/Actions/ActionsComponent.js.map +1 -0
- package/build/dist/Actions/ActionsSystem.js +30 -0
- package/build/dist/Actions/ActionsSystem.js.map +1 -0
- package/build/dist/Actions/Index.js +26 -0
- package/build/dist/Actions/Index.js.map +1 -0
- package/build/dist/Actions/RotationType.js +27 -0
- package/build/dist/Actions/RotationType.js.map +1 -0
- package/build/dist/Actor.js +629 -0
- package/build/dist/Actor.js.map +1 -0
- package/build/dist/Camera.js +660 -0
- package/build/dist/Camera.js.map +1 -0
- package/build/dist/Collision/BoundingBox.js +415 -0
- package/build/dist/Collision/BoundingBox.js.map +1 -0
- package/build/dist/Collision/ColliderComponent.js +202 -0
- package/build/dist/Collision/ColliderComponent.js.map +1 -0
- package/build/dist/Collision/Colliders/CircleCollider.js +226 -0
- package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/Collider.js +32 -0
- package/build/dist/Collision/Colliders/Collider.js.map +1 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +300 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js +229 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js +556 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
- package/build/dist/Collision/Colliders/Shape.js +99 -0
- package/build/dist/Collision/Colliders/Shape.js.map +1 -0
- package/build/dist/Collision/CollisionType.js +33 -0
- package/build/dist/Collision/CollisionType.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionContact.js +51 -0
- package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
- package/build/dist/Collision/Detection/DynamicTree.js +442 -0
- package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
- package/build/dist/Collision/Detection/Pair.js +92 -0
- package/build/dist/Collision/Detection/Pair.js.map +1 -0
- package/build/dist/Collision/Detection/QuadTree.js +193 -0
- package/build/dist/Collision/Detection/QuadTree.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroup.js +3 -3
- package/build/dist/Collision/Integrator.js +25 -0
- package/build/dist/Collision/Integrator.js.map +1 -0
- package/build/dist/Collision/MotionSystem.js +35 -0
- package/build/dist/Collision/MotionSystem.js.map +1 -0
- package/build/dist/Collision/Physics.js +163 -0
- package/build/dist/Collision/Physics.js.map +1 -0
- package/build/dist/Collision/PhysicsWorld.js +10 -0
- package/build/dist/Collision/PhysicsWorld.js.map +1 -0
- package/build/dist/Collision/Side.js +51 -0
- package/build/dist/Collision/Side.js.map +1 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js +154 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +87 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
- package/build/dist/Collision/Solver/RealisticSolver.js +293 -0
- package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
- package/build/dist/Collision/Solver/Solver.js +2 -0
- package/build/dist/Collision/Solver/Solver.js.map +1 -0
- package/build/dist/Color.js +417 -0
- package/build/dist/Color.js.map +1 -0
- package/build/dist/Configurable.js +32 -0
- package/build/dist/Configurable.js.map +1 -0
- package/build/dist/Debug/Debug.d.ts +11 -0
- package/build/dist/Debug/Debug.js +385 -0
- package/build/dist/Debug/Debug.js.map +1 -0
- package/build/dist/Debug/DebugFlags.js +40 -0
- package/build/dist/Debug/DebugFlags.js.map +1 -0
- package/build/dist/Debug/DebugSystem.js +263 -0
- package/build/dist/Debug/DebugSystem.js.map +1 -0
- package/build/dist/Debug/index.js +4 -0
- package/build/dist/Debug/index.js.map +1 -0
- package/build/dist/Deprecated.js +2 -0
- package/build/dist/Deprecated.js.map +1 -0
- package/build/dist/Engine.js +986 -0
- package/build/dist/Engine.js.map +1 -0
- package/build/dist/EntityComponentSystem/Component.js +65 -0
- package/build/dist/EntityComponentSystem/Component.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js +107 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Entity.js +487 -0
- package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
- package/build/dist/EntityComponentSystem/EntityManager.js +137 -0
- package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Query.js +90 -0
- package/build/dist/EntityComponentSystem/Query.js.map +1 -0
- package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
- package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/System.js +76 -0
- package/build/dist/EntityComponentSystem/System.js.map +1 -0
- package/build/dist/EntityComponentSystem/SystemManager.js +104 -0
- package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Util.js +5 -0
- package/build/dist/EntityComponentSystem/Util.js.map +1 -0
- package/build/dist/EntityComponentSystem/World.js +55 -0
- package/build/dist/EntityComponentSystem/World.js.map +1 -0
- package/build/dist/EntityComponentSystem/index.js +11 -0
- package/build/dist/EntityComponentSystem/index.js.map +1 -0
- package/build/dist/EventDispatcher.js +122 -0
- package/build/dist/EventDispatcher.js.map +1 -0
- package/build/dist/EventEmitter.js +86 -0
- package/build/dist/EventEmitter.js.map +1 -0
- package/build/dist/Events/ExEvent.js +12 -0
- package/build/dist/Events/ExEvent.js.map +1 -0
- package/build/dist/Events/MediaEvents.js +75 -0
- package/build/dist/Events/MediaEvents.js.map +1 -0
- package/build/dist/Events/PointerEvents.js +52 -0
- package/build/dist/Events/PointerEvents.js.map +1 -0
- package/build/dist/Events.js +473 -0
- package/build/dist/Events.js.map +1 -0
- package/build/dist/Flags.js +67 -0
- package/build/dist/Flags.js.map +1 -0
- package/build/dist/Graphics/Animation.js +344 -0
- package/build/dist/Graphics/Animation.js.map +1 -0
- package/build/dist/Graphics/Canvas.js +38 -0
- package/build/dist/Graphics/Canvas.js.map +1 -0
- package/build/dist/Graphics/Circle.js +48 -0
- package/build/dist/Graphics/Circle.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +237 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +481 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +52 -52
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +174 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -37
- package/build/dist/Graphics/Context/debug-text.js +47 -0
- package/build/dist/Graphics/Context/debug-text.js.map +1 -0
- package/build/dist/Graphics/Context/draw-call.js +16 -0
- package/build/dist/Graphics/Context/draw-call.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +32 -32
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js +246 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.vert.glsl +32 -32
- package/build/dist/Graphics/Context/line-renderer/line-fragment.glsl +10 -10
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js +90 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/line-renderer/line-vertex.glsl +14 -14
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js +23 -2
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js.map +1 -1
- package/build/dist/Graphics/Context/material.d.ts +2 -0
- package/build/dist/Graphics/Context/material.js +72 -0
- package/build/dist/Graphics/Context/material.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-fragment.glsl +19 -19
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js +91 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/quad-index-buffer.js +67 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -85
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +305 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -42
- package/build/dist/Graphics/Context/render-source.js +16 -0
- package/build/dist/Graphics/Context/render-source.js.map +1 -0
- package/build/dist/Graphics/Context/render-target.js +65 -0
- package/build/dist/Graphics/Context/render-target.js.map +1 -0
- package/build/dist/Graphics/Context/renderer.js +2 -0
- package/build/dist/Graphics/Context/renderer.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +13 -13
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +56 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/state-stack.js +37 -0
- package/build/dist/Graphics/Context/state-stack.js.map +1 -0
- package/build/dist/Graphics/Context/texture-loader.js +109 -0
- package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
- package/build/dist/Graphics/Context/transform-stack.js +30 -0
- package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-buffer.js +53 -0
- package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-util.js +79 -0
- package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
- package/build/dist/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/dist/Graphics/DebugGraphicsComponent.js +16 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/Filtering.js +17 -0
- package/build/dist/Graphics/Filtering.js.map +1 -0
- package/build/dist/Graphics/Font.js +148 -0
- package/build/dist/Graphics/Font.js.map +1 -0
- package/build/dist/Graphics/FontCache.d.ts +1 -0
- package/build/dist/Graphics/FontCache.js +80 -0
- package/build/dist/Graphics/FontCache.js.map +1 -0
- package/build/dist/Graphics/FontCommon.js +109 -0
- package/build/dist/Graphics/FontCommon.js.map +1 -0
- package/build/dist/Graphics/FontTextInstance.js +230 -0
- package/build/dist/Graphics/FontTextInstance.js.map +1 -0
- package/build/dist/Graphics/Graphic.js +208 -0
- package/build/dist/Graphics/Graphic.js.map +1 -0
- package/build/dist/Graphics/GraphicsComponent.js +336 -0
- package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
- package/build/dist/Graphics/GraphicsGroup.js +69 -0
- package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
- package/build/dist/Graphics/GraphicsSystem.js +210 -0
- package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
- package/build/dist/Graphics/ImageSource.js +124 -0
- package/build/dist/Graphics/ImageSource.js.map +1 -0
- package/build/dist/Graphics/Line.js +45 -0
- package/build/dist/Graphics/Line.js.map +1 -0
- package/build/dist/Graphics/OffscreenSystem.js +64 -0
- package/build/dist/Graphics/OffscreenSystem.js.map +1 -0
- package/build/dist/Graphics/ParallaxComponent.js +11 -0
- package/build/dist/Graphics/ParallaxComponent.js.map +1 -0
- package/build/dist/Graphics/Polygon.js +59 -0
- package/build/dist/Graphics/Polygon.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js +59 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +64 -64
- package/build/dist/Graphics/Raster.js +215 -0
- package/build/dist/Graphics/Raster.js.map +1 -0
- package/build/dist/Graphics/Rectangle.js +29 -0
- package/build/dist/Graphics/Rectangle.js.map +1 -0
- package/build/dist/Graphics/Sprite.js +82 -0
- package/build/dist/Graphics/Sprite.js.map +1 -0
- package/build/dist/Graphics/SpriteFont.js +139 -0
- package/build/dist/Graphics/SpriteFont.js.map +1 -0
- package/build/dist/Graphics/SpriteSheet.js +116 -0
- package/build/dist/Graphics/SpriteSheet.js.map +1 -0
- package/build/dist/Graphics/Text.js +103 -0
- package/build/dist/Graphics/Text.js.map +1 -0
- package/build/dist/Graphics/index.js +46 -0
- package/build/dist/Graphics/index.js.map +1 -0
- package/build/dist/Id.js +8 -0
- package/build/dist/Id.js.map +1 -0
- package/build/dist/Input/CapturePointerConfig.js +5 -0
- package/build/dist/Input/CapturePointerConfig.js.map +1 -0
- package/build/dist/Input/EngineInput.js +2 -0
- package/build/dist/Input/EngineInput.js.map +1 -0
- package/build/dist/Input/Gamepad.js +422 -0
- package/build/dist/Input/Gamepad.js.map +1 -0
- package/build/dist/Input/Index.js +88 -0
- package/build/dist/Input/Index.js.map +1 -0
- package/build/dist/Input/InputMapper.js +45 -0
- package/build/dist/Input/InputMapper.js.map +1 -0
- package/build/dist/Input/Keyboard.js +348 -0
- package/build/dist/Input/Keyboard.js.map +1 -0
- package/build/dist/Input/NativePointerButton.js +12 -0
- package/build/dist/Input/NativePointerButton.js.map +1 -0
- package/build/dist/Input/PointerAbstraction.js +44 -0
- package/build/dist/Input/PointerAbstraction.js.map +1 -0
- package/build/dist/Input/PointerButton.js +12 -0
- package/build/dist/Input/PointerButton.js.map +1 -0
- package/build/dist/Input/PointerComponent.js +28 -0
- package/build/dist/Input/PointerComponent.js.map +1 -0
- package/build/dist/Input/PointerEvent.js +25 -0
- package/build/dist/Input/PointerEvent.js.map +1 -0
- package/build/dist/Input/PointerEventReceiver.js +456 -0
- package/build/dist/Input/PointerEventReceiver.js.map +1 -0
- package/build/dist/Input/PointerScope.js +16 -0
- package/build/dist/Input/PointerScope.js.map +1 -0
- package/build/dist/Input/PointerSystem.js +249 -0
- package/build/dist/Input/PointerSystem.js.map +1 -0
- package/build/dist/Input/PointerType.js +11 -0
- package/build/dist/Input/PointerType.js.map +1 -0
- package/build/dist/Input/WheelDeltaMode.js +7 -0
- package/build/dist/Input/WheelDeltaMode.js.map +1 -0
- package/build/dist/Input/WheelEvent.js +21 -0
- package/build/dist/Input/WheelEvent.js.map +1 -0
- package/build/dist/Interfaces/Audio.js +2 -0
- package/build/dist/Interfaces/Audio.js.map +1 -0
- package/build/dist/Interfaces/AudioImplementation.js +11 -0
- package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
- package/build/dist/Interfaces/Clonable.js +2 -0
- package/build/dist/Interfaces/Clonable.js.map +1 -0
- package/build/dist/Interfaces/Evented.js +2 -0
- package/build/dist/Interfaces/Evented.js.map +1 -0
- package/build/dist/Interfaces/Index.js +8 -0
- package/build/dist/Interfaces/Index.js.map +1 -0
- package/build/dist/Interfaces/LifecycleEvents.js +51 -0
- package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
- package/build/dist/Interfaces/Loadable.js +2 -0
- package/build/dist/Interfaces/Loadable.js.map +1 -0
- package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
- package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
- package/build/dist/Label.js +81 -0
- package/build/dist/Label.js.map +1 -0
- package/build/dist/Loader.js +416 -0
- package/build/dist/Loader.js.map +1 -0
- package/build/dist/Math/Index.js +13 -0
- package/build/dist/Math/Index.js.map +1 -0
- package/build/dist/Math/Random.js +239 -0
- package/build/dist/Math/Random.js.map +1 -0
- package/build/dist/Math/affine-matrix.js +331 -0
- package/build/dist/Math/affine-matrix.js.map +1 -0
- package/build/dist/Math/coord-plane.js +17 -0
- package/build/dist/Math/coord-plane.js.map +1 -0
- package/build/dist/Math/global-coordinates.js +30 -0
- package/build/dist/Math/global-coordinates.js.map +1 -0
- package/build/dist/Math/line-segment.js +205 -0
- package/build/dist/Math/line-segment.js.map +1 -0
- package/build/dist/Math/matrix.js +457 -0
- package/build/dist/Math/matrix.js.map +1 -0
- package/build/dist/Math/projection.js +24 -0
- package/build/dist/Math/projection.js.map +1 -0
- package/build/dist/Math/ray.js +52 -0
- package/build/dist/Math/ray.js.map +1 -0
- package/build/dist/Math/transform.js +219 -0
- package/build/dist/Math/transform.js.map +1 -0
- package/build/dist/Math/util.js +82 -0
- package/build/dist/Math/util.js.map +1 -0
- package/build/dist/Math/vector-view.js +25 -0
- package/build/dist/Math/vector-view.js.map +1 -0
- package/build/dist/Math/vector.js +340 -0
- package/build/dist/Math/vector.js.map +1 -0
- package/build/dist/Math/watch-vector.js +26 -0
- package/build/dist/Math/watch-vector.js.map +1 -0
- package/build/dist/Particles.js +430 -0
- package/build/dist/Particles.js.map +1 -0
- package/build/dist/Polyfill.js +56 -0
- package/build/dist/Polyfill.js.map +1 -0
- package/build/dist/Resources/Gif.js +464 -0
- package/build/dist/Resources/Gif.js.map +1 -0
- package/build/dist/Resources/Index.js +4 -0
- package/build/dist/Resources/Index.js.map +1 -0
- package/build/dist/Resources/Resource.js +81 -0
- package/build/dist/Resources/Resource.js.map +1 -0
- package/build/dist/Resources/Sound/AudioContext.js +16 -0
- package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
- package/build/dist/Resources/Sound/Index.js +4 -0
- package/build/dist/Resources/Sound/Index.js.map +1 -0
- package/build/dist/Resources/Sound/Sound.js +326 -0
- package/build/dist/Resources/Sound/Sound.js.map +1 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js +190 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
- package/build/dist/Scene.js +444 -0
- package/build/dist/Scene.js.map +1 -0
- package/build/dist/Screen.js +782 -0
- package/build/dist/Screen.js.map +1 -0
- package/build/dist/ScreenElement.js +43 -0
- package/build/dist/ScreenElement.js.map +1 -0
- package/build/dist/TileMap/IsometricEntityComponent.js +17 -0
- package/build/dist/TileMap/IsometricEntityComponent.js.map +1 -0
- package/build/dist/TileMap/IsometricEntitySystem.js +23 -0
- package/build/dist/TileMap/IsometricEntitySystem.js.map +1 -0
- package/build/dist/TileMap/IsometricMap.js +311 -0
- package/build/dist/TileMap/IsometricMap.js.map +1 -0
- package/build/dist/TileMap/TileMap.d.ts +2 -1
- package/build/dist/TileMap/TileMap.js +630 -0
- package/build/dist/TileMap/TileMap.js.map +1 -0
- package/build/dist/TileMap/index.js +5 -0
- package/build/dist/TileMap/index.js.map +1 -0
- package/build/dist/Timer.js +202 -0
- package/build/dist/Timer.js.map +1 -0
- package/build/dist/Trigger.js +94 -0
- package/build/dist/Trigger.js.map +1 -0
- package/build/dist/Util/Browser.js +66 -0
- package/build/dist/Util/Browser.js.map +1 -0
- package/build/dist/Util/Clock.js +219 -0
- package/build/dist/Util/Clock.js.map +1 -0
- package/build/dist/Util/Decorators.js +78 -0
- package/build/dist/Util/Decorators.js.map +1 -0
- package/build/dist/Util/Detector.js +167 -0
- package/build/dist/Util/Detector.js.map +1 -0
- package/build/dist/Util/DrawUtil.js +115 -0
- package/build/dist/Util/DrawUtil.js.map +1 -0
- package/build/dist/Util/EasingFunctions.js +102 -0
- package/build/dist/Util/EasingFunctions.js.map +1 -0
- package/build/dist/Util/Fps.js +47 -0
- package/build/dist/Util/Fps.js.map +1 -0
- package/build/dist/Util/Future.js +30 -0
- package/build/dist/Util/Future.js.map +1 -0
- package/build/dist/Util/IFrame.js +23 -0
- package/build/dist/Util/IFrame.js.map +1 -0
- package/build/dist/Util/Index.js +7 -0
- package/build/dist/Util/Index.js.map +1 -0
- package/build/dist/Util/Log.js +195 -0
- package/build/dist/Util/Log.js.map +1 -0
- package/build/dist/Util/Observable.js +66 -0
- package/build/dist/Util/Observable.js.map +1 -0
- package/build/dist/Util/Pool.js +74 -0
- package/build/dist/Util/Pool.js.map +1 -0
- package/build/dist/Util/Semaphore.js +55 -0
- package/build/dist/Util/Semaphore.js.map +1 -0
- package/build/dist/Util/Sound.js +22 -0
- package/build/dist/Util/Sound.js.map +1 -0
- package/build/dist/Util/StateMachine.js +79 -0
- package/build/dist/Util/StateMachine.js.map +1 -0
- package/build/dist/Util/Toaster.css +28 -28
- package/build/dist/Util/Toaster.js +84 -0
- package/build/dist/Util/Toaster.js.map +1 -0
- package/build/dist/Util/Util.d.ts +6 -0
- package/build/dist/Util/Util.js +95 -0
- package/build/dist/Util/Util.js.map +1 -0
- package/build/dist/Util/Watch.js +67 -0
- package/build/dist/Util/Watch.js.map +1 -0
- package/build/dist/Util/WebAudio.js +62 -0
- package/build/dist/Util/WebAudio.js.map +1 -0
- package/build/dist/excalibur.d.ts +2 -2
- package/build/dist/excalibur.js +389 -258
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/dist/index.js +81 -0
- package/build/dist/index.js.map +1 -0
- package/build/esm/Debug/Debug.d.ts +11 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/esm/Graphics/Context/material.d.ts +2 -0
- package/build/esm/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/esm/Graphics/FontCache.d.ts +1 -0
- package/build/esm/TileMap/TileMap.d.ts +2 -1
- package/build/esm/Util/Util.d.ts +6 -0
- package/build/esm/excalibur.d.ts +2 -2
- package/build/esm/excalibur.js +389 -258
- package/build/esm/excalibur.js.map +1 -1
- package/build/esm/excalibur.min.js +1 -1
- package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
- package/build/esm/excalibur.min.js.map +1 -1
- package/docker-compose.yml +11 -11
- package/package.json +131 -131
- package/build/dist/Loader.css +0 -122
- package/build/nuget/Excalibur.0.28.3.nupkg +0 -0
- package/build/v0.28.3.zip +0 -0
- 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;AACH,MAAM,UAAU,kBAAkB,CAAC,CAA2B;IAC5D,OAAO,CAAC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AAC,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":"E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