dacha 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/build/contrib/components/animatable/comparator-condition-component-value.d.ts +5 -0
- package/build/contrib/components/animatable/comparator-condition-component-value.js +12 -0
- package/build/contrib/components/animatable/comparator-condition-number-value.d.ts +5 -0
- package/build/contrib/components/animatable/comparator-condition-number-value.js +9 -0
- package/build/contrib/components/animatable/comparator-condition-props.d.ts +9 -0
- package/build/contrib/components/animatable/comparator-condition-props.js +12 -0
- package/build/contrib/components/animatable/comparator-condition-values.d.ts +8 -0
- package/build/contrib/components/animatable/comparator-condition-values.js +8 -0
- package/build/contrib/components/animatable/condition-props.d.ts +6 -0
- package/build/contrib/components/animatable/condition-props.js +6 -0
- package/build/contrib/components/animatable/condition.d.ts +9 -0
- package/build/contrib/components/animatable/condition.js +12 -0
- package/build/contrib/components/animatable/event-condition-props.d.ts +4 -0
- package/build/contrib/components/animatable/event-condition-props.js +6 -0
- package/build/contrib/components/animatable/group-state.d.ts +11 -0
- package/build/contrib/components/animatable/group-state.js +16 -0
- package/build/contrib/components/animatable/index.d.ts +14 -0
- package/build/contrib/components/animatable/index.js +41 -0
- package/build/contrib/components/animatable/individual-state.d.ts +7 -0
- package/build/contrib/components/animatable/individual-state.js +10 -0
- package/build/contrib/components/animatable/one-dimensional-props.d.ts +4 -0
- package/build/contrib/components/animatable/one-dimensional-props.js +10 -0
- package/build/contrib/components/animatable/pick-props.d.ts +6 -0
- package/build/contrib/components/animatable/pick-props.js +6 -0
- package/build/contrib/components/animatable/state.d.ts +10 -0
- package/build/contrib/components/animatable/state.js +16 -0
- package/build/contrib/components/animatable/substate.d.ts +9 -0
- package/build/contrib/components/animatable/substate.js +13 -0
- package/build/contrib/components/animatable/timeline.d.ts +11 -0
- package/build/contrib/components/animatable/timeline.js +28 -0
- package/build/contrib/components/animatable/transition.d.ts +9 -0
- package/build/contrib/components/animatable/transition.js +14 -0
- package/build/contrib/components/animatable/two-dimensional-props.d.ts +5 -0
- package/build/contrib/components/animatable/two-dimensional-props.js +12 -0
- package/build/contrib/components/animatable/types.d.ts +78 -0
- package/build/contrib/components/animatable/types.js +1 -0
- package/build/contrib/components/camera/index.d.ts +13 -0
- package/build/contrib/components/camera/index.js +21 -0
- package/build/contrib/components/collider-container/box-collider.d.ts +7 -0
- package/build/contrib/components/collider-container/box-collider.js +12 -0
- package/build/contrib/components/collider-container/circle-collider.d.ts +6 -0
- package/build/contrib/components/collider-container/circle-collider.js +10 -0
- package/build/contrib/components/collider-container/index.d.ts +13 -0
- package/build/contrib/components/collider-container/index.js +28 -0
- package/build/contrib/components/index.d.ts +20 -0
- package/build/contrib/components/index.js +10 -0
- package/build/contrib/components/keyboard-control/index.d.ts +28 -0
- package/build/contrib/components/keyboard-control/index.js +46 -0
- package/build/contrib/components/light/index.d.ts +20 -0
- package/build/contrib/components/light/index.js +18 -0
- package/build/contrib/components/mouse-control/index.d.ts +25 -0
- package/build/contrib/components/mouse-control/index.js +46 -0
- package/build/contrib/components/renderable/index.d.ts +44 -0
- package/build/contrib/components/renderable/index.js +65 -0
- package/build/contrib/components/renderable/material.d.ts +16 -0
- package/build/contrib/components/renderable/material.js +8 -0
- package/build/contrib/components/rigid-body/index.d.ts +20 -0
- package/build/contrib/components/rigid-body/index.js +29 -0
- package/build/contrib/components/script-bundle/index.d.ts +14 -0
- package/build/contrib/components/script-bundle/index.js +15 -0
- package/build/contrib/components/sprite/index.d.ts +35 -0
- package/build/contrib/components/sprite/index.js +50 -0
- package/build/contrib/components/sprite/material.d.ts +16 -0
- package/build/contrib/components/sprite/material.js +8 -0
- package/build/contrib/components/transform/index.d.ts +32 -0
- package/build/contrib/components/transform/index.js +69 -0
- package/build/contrib/events/index.d.ts +63 -0
- package/build/contrib/events/index.js +11 -0
- package/build/contrib/systems/animator/condition-controllers/comparator-condition-controller.d.ts +10 -0
- package/build/contrib/systems/animator/condition-controllers/comparator-condition-controller.js +32 -0
- package/build/contrib/systems/animator/condition-controllers/condition-controller.d.ts +3 -0
- package/build/contrib/systems/animator/condition-controllers/condition-controller.js +1 -0
- package/build/contrib/systems/animator/condition-controllers/event-condition-controller.d.ts +8 -0
- package/build/contrib/systems/animator/condition-controllers/event-condition-controller.js +18 -0
- package/build/contrib/systems/animator/condition-controllers/index.d.ts +3 -0
- package/build/contrib/systems/animator/condition-controllers/index.js +6 -0
- package/build/contrib/systems/animator/index.d.ts +15 -0
- package/build/contrib/systems/animator/index.js +93 -0
- package/build/contrib/systems/animator/substate-pickers/index.d.ts +4 -0
- package/build/contrib/systems/animator/substate-pickers/index.js +6 -0
- package/build/contrib/systems/animator/substate-pickers/one-dimensional-picker.d.ts +8 -0
- package/build/contrib/systems/animator/substate-pickers/one-dimensional-picker.js +25 -0
- package/build/contrib/systems/animator/substate-pickers/picker.d.ts +7 -0
- package/build/contrib/systems/animator/substate-pickers/picker.js +1 -0
- package/build/contrib/systems/animator/substate-pickers/two-dimensional-picker.d.ts +8 -0
- package/build/contrib/systems/animator/substate-pickers/two-dimensional-picker.js +27 -0
- package/build/contrib/systems/animator/utils.d.ts +3 -0
- package/build/contrib/systems/animator/utils.js +32 -0
- package/build/contrib/systems/camera-system/index.d.ts +2 -0
- package/build/contrib/systems/camera-system/index.js +2 -0
- package/build/contrib/systems/camera-system/service.d.ts +13 -0
- package/build/contrib/systems/camera-system/service.js +25 -0
- package/build/contrib/systems/camera-system/system.d.ts +16 -0
- package/build/contrib/systems/camera-system/system.js +65 -0
- package/build/contrib/systems/game-stats-meter/index.d.ts +11 -0
- package/build/contrib/systems/game-stats-meter/index.js +34 -0
- package/build/contrib/systems/index.d.ts +13 -0
- package/build/contrib/systems/index.js +11 -0
- package/build/contrib/systems/keyboard-control-system/index.d.ts +14 -0
- package/build/contrib/systems/keyboard-control-system/index.js +73 -0
- package/build/contrib/systems/keyboard-input-system/index.d.ts +10 -0
- package/build/contrib/systems/keyboard-input-system/index.js +28 -0
- package/build/contrib/systems/keyboard-input-system/input-listener.d.ts +12 -0
- package/build/contrib/systems/keyboard-input-system/input-listener.js +36 -0
- package/build/contrib/systems/mouse-control-system/index.d.ts +10 -0
- package/build/contrib/systems/mouse-control-system/index.js +43 -0
- package/build/contrib/systems/mouse-input-system/index.d.ts +10 -0
- package/build/contrib/systems/mouse-input-system/index.js +23 -0
- package/build/contrib/systems/mouse-input-system/subsystems/coordinates-projector/index.d.ts +9 -0
- package/build/contrib/systems/mouse-input-system/subsystems/coordinates-projector/index.js +23 -0
- package/build/contrib/systems/mouse-input-system/subsystems/index.d.ts +2 -0
- package/build/contrib/systems/mouse-input-system/subsystems/index.js +2 -0
- package/build/contrib/systems/mouse-input-system/subsystems/input-subsystem/index.d.ts +9 -0
- package/build/contrib/systems/mouse-input-system/subsystems/input-subsystem/index.js +25 -0
- package/build/contrib/systems/mouse-input-system/subsystems/input-subsystem/mouse-input-listener.d.ts +11 -0
- package/build/contrib/systems/mouse-input-system/subsystems/input-subsystem/mouse-input-listener.js +46 -0
- package/build/contrib/systems/physics-system/consts.d.ts +4 -0
- package/build/contrib/systems/physics-system/consts.js +4 -0
- package/build/contrib/systems/physics-system/index.d.ts +13 -0
- package/build/contrib/systems/physics-system/index.js +38 -0
- package/build/contrib/systems/physics-system/subsystems/collision-broadcast/collision.d.ts +15 -0
- package/build/contrib/systems/physics-system/subsystems/collision-broadcast/collision.js +31 -0
- package/build/contrib/systems/physics-system/subsystems/collision-broadcast/index.d.ts +12 -0
- package/build/contrib/systems/physics-system/subsystems/collision-broadcast/index.js +55 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-aabb.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-aabb.js +13 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-aabb.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-aabb.js +8 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/index.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/index.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/dispersion-calculator/index.d.ts +11 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/dispersion-calculator/index.js +27 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +46 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +13 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.d.ts +4 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.d.ts +29 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +235 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-box-and-circle-intersection.d.ts +16 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-box-and-circle-intersection.js +80 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-boxes-intersection.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-boxes-intersection.js +72 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-circles-intersection.d.ts +11 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-circles-intersection.js +39 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.js +13 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.js +16 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-transform.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-transform.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/index.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/index.js +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +70 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/types.js +1 -0
- package/build/contrib/systems/physics-system/subsystems/collision-solver/index.d.ts +11 -0
- package/build/contrib/systems/physics-system/subsystems/collision-solver/index.js +52 -0
- package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.d.ts +15 -0
- package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.js +123 -0
- package/build/contrib/systems/physics-system/subsystems/index.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/index.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/physics/index.d.ts +18 -0
- package/build/contrib/systems/physics-system/subsystems/physics/index.js +131 -0
- package/build/contrib/systems/physics-system/types.d.ts +4 -0
- package/build/contrib/systems/physics-system/types.js +1 -0
- package/build/contrib/systems/script-system/index.d.ts +18 -0
- package/build/contrib/systems/script-system/index.js +68 -0
- package/build/contrib/systems/script-system/types.d.ts +20 -0
- package/build/contrib/systems/script-system/types.js +3 -0
- package/build/contrib/systems/sprite-renderer/index.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/index.js +2 -0
- package/build/contrib/systems/sprite-renderer/light-subsystem/index.d.ts +13 -0
- package/build/contrib/systems/sprite-renderer/light-subsystem/index.js +51 -0
- package/build/contrib/systems/sprite-renderer/light-subsystem/light-factory.d.ts +4 -0
- package/build/contrib/systems/sprite-renderer/light-subsystem/light-factory.js +27 -0
- package/build/contrib/systems/sprite-renderer/material-factory/index.d.ts +4 -0
- package/build/contrib/systems/sprite-renderer/material-factory/index.js +32 -0
- package/build/contrib/systems/sprite-renderer/renderer.d.ts +32 -0
- package/build/contrib/systems/sprite-renderer/renderer.js +214 -0
- package/build/contrib/systems/sprite-renderer/service/index.d.ts +24 -0
- package/build/contrib/systems/sprite-renderer/service/index.js +52 -0
- package/build/contrib/systems/sprite-renderer/sort/index.d.ts +8 -0
- package/build/contrib/systems/sprite-renderer/sort/index.js +15 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-fit.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-fit.js +12 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-layer.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-layer.js +14 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-x-axis.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-x-axis.js +15 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-y-axis.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-y-axis.js +15 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-z-axis.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/sort-by-z-axis.js +6 -0
- package/build/contrib/systems/sprite-renderer/sort/types.d.ts +2 -0
- package/build/contrib/systems/sprite-renderer/sort/types.js +1 -0
- package/build/contrib/systems/sprite-renderer/sort/utils.d.ts +1 -0
- package/build/contrib/systems/sprite-renderer/sort/utils.js +6 -0
- package/build/contrib/systems/sprite-renderer/sprite-cropper.d.ts +8 -0
- package/build/contrib/systems/sprite-renderer/sprite-cropper.js +30 -0
- package/build/contrib/systems/sprite-renderer/utils.d.ts +8 -0
- package/build/contrib/systems/sprite-renderer/utils.js +41 -0
- package/build/contrib/systems/ui-bridge/index.d.ts +40 -0
- package/build/contrib/systems/ui-bridge/index.js +62 -0
- package/build/contrib/systems/ui-bridge/observer/index.d.ts +1 -0
- package/build/contrib/systems/ui-bridge/observer/index.js +1 -0
- package/build/contrib/systems/ui-bridge/observer/observer.d.ts +8 -0
- package/build/contrib/systems/ui-bridge/observer/observer.js +21 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/color-reader.d.ts +3 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/color-reader.js +1 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/consts.d.ts +3 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/consts.js +10 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/hex-color-reader.d.ts +4 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/hex-color-reader.js +14 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/index.d.ts +6 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/index.js +6 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/short-hex-color-reader.d.ts +4 -0
- package/build/contrib/systems/webgl-render-system/color/color-reader/short-hex-color-reader.js +11 -0
- package/build/contrib/systems/webgl-render-system/color/index.d.ts +7 -0
- package/build/contrib/systems/webgl-render-system/color/index.js +41 -0
- package/build/contrib/systems/webgl-render-system/consts.d.ts +9 -0
- package/build/contrib/systems/webgl-render-system/consts.js +9 -0
- package/build/contrib/systems/webgl-render-system/geometry/rectangle.d.ts +6 -0
- package/build/contrib/systems/webgl-render-system/geometry/rectangle.js +22 -0
- package/build/contrib/systems/webgl-render-system/index.d.ts +66 -0
- package/build/contrib/systems/webgl-render-system/index.js +405 -0
- package/build/contrib/systems/webgl-render-system/matrix-transformer/index.d.ts +20 -0
- package/build/contrib/systems/webgl-render-system/matrix-transformer/index.js +55 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/fragment-shader.d.ts +1 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/fragment-shader.js +29 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/index.d.ts +11 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/index.js +39 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/shader-provider.d.ts +10 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/shader-provider.js +34 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/vertex-shader.d.ts +1 -0
- package/build/contrib/systems/webgl-render-system/shader-builder/vertex-shader.js +16 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/index.d.ts +7 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/index.js +6 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/sprite-texture-handler.d.ts +10 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/sprite-texture-handler.js +16 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/static-texture-handler.d.ts +9 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/static-texture-handler.js +10 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/texture-handler.d.ts +10 -0
- package/build/contrib/systems/webgl-render-system/texture-handlers/texture-handler.js +1 -0
- package/build/contrib/systems/webgl-render-system/utils/index.d.ts +1 -0
- package/build/contrib/systems/webgl-render-system/utils/index.js +1 -0
- package/build/contrib/systems/webgl-render-system/utils/split-to-batch.d.ts +3 -0
- package/build/contrib/systems/webgl-render-system/utils/split-to-batch.js +19 -0
- package/build/contrib/types/index.d.ts +1 -0
- package/build/contrib/types/index.js +1 -0
- package/build/contrib/types/input-events.d.ts +21 -0
- package/build/contrib/types/input-events.js +1 -0
- package/build/contrib/utils/coordinates-projection.d.ts +3 -0
- package/build/contrib/utils/coordinates-projection.js +11 -0
- package/build/contrib/utils/get-window-node.d.ts +1 -0
- package/build/contrib/utils/get-window-node.js +7 -0
- package/build/engine/actor/actor-collection.d.ts +31 -0
- package/build/engine/actor/actor-collection.js +98 -0
- package/build/engine/actor/actor-creator.d.ts +21 -0
- package/build/engine/actor/actor-creator.js +82 -0
- package/build/engine/actor/actor-spawner.d.ts +7 -0
- package/build/engine/actor/actor-spawner.js +12 -0
- package/build/engine/actor/actor.d.ts +31 -0
- package/build/engine/actor/actor.js +60 -0
- package/build/engine/actor/index.d.ts +5 -0
- package/build/engine/actor/index.js +4 -0
- package/build/engine/component/component.d.ts +13 -0
- package/build/engine/component/component.js +21 -0
- package/build/engine/component/index.d.ts +2 -0
- package/build/engine/component/index.js +1 -0
- package/build/engine/controllers/controller.d.ts +7 -0
- package/build/engine/controllers/controller.js +1 -0
- package/build/engine/controllers/index.d.ts +2 -0
- package/build/engine/controllers/index.js +1 -0
- package/build/engine/controllers/scene-controller.d.ts +11 -0
- package/build/engine/controllers/scene-controller.js +50 -0
- package/build/engine/data-lib/index.d.ts +2 -0
- package/build/engine/data-lib/index.js +2 -0
- package/build/engine/data-lib/queue.d.ts +8 -0
- package/build/engine/data-lib/queue.js +34 -0
- package/build/engine/data-lib/sort/index.d.ts +1 -0
- package/build/engine/data-lib/sort/index.js +1 -0
- package/build/engine/data-lib/sort/insertion-sort.d.ts +1 -0
- package/build/engine/data-lib/sort/insertion-sort.js +14 -0
- package/build/engine/engine.d.ts +22 -0
- package/build/engine/engine.js +89 -0
- package/build/engine/entity/entity.d.ts +17 -0
- package/build/engine/entity/entity.js +40 -0
- package/build/engine/entity/index.d.ts +3 -0
- package/build/engine/entity/index.js +2 -0
- package/build/engine/entity/utils.d.ts +3 -0
- package/build/engine/entity/utils.js +26 -0
- package/build/engine/event-target/event-queue.d.ts +9 -0
- package/build/engine/event-target/event-queue.js +16 -0
- package/build/engine/event-target/event-target.d.ts +13 -0
- package/build/engine/event-target/event-target.js +59 -0
- package/build/engine/event-target/index.d.ts +4 -0
- package/build/engine/event-target/index.js +2 -0
- package/build/engine/event-target/types.d.ts +12 -0
- package/build/engine/event-target/types.js +1 -0
- package/build/engine/events/index.d.ts +51 -0
- package/build/engine/events/index.js +8 -0
- package/build/engine/game-loop.d.ts +14 -0
- package/build/engine/game-loop.js +51 -0
- package/build/engine/index.d.ts +1 -0
- package/build/engine/index.js +1 -0
- package/build/engine/math-lib/index.d.ts +3 -0
- package/build/engine/math-lib/index.js +3 -0
- package/build/engine/math-lib/math/ops.d.ts +14 -0
- package/build/engine/math-lib/math/ops.js +52 -0
- package/build/engine/math-lib/vector/ops.d.ts +38 -0
- package/build/engine/math-lib/vector/ops.js +76 -0
- package/build/engine/math-lib/vector/vector2.d.ts +10 -0
- package/build/engine/math-lib/vector/vector2.js +25 -0
- package/build/engine/resource-loader/index.d.ts +1 -0
- package/build/engine/resource-loader/index.js +1 -0
- package/build/engine/resource-loader/loaders/image-loader.d.ts +7 -0
- package/build/engine/resource-loader/loaders/image-loader.js +21 -0
- package/build/engine/resource-loader/loaders/index.d.ts +4 -0
- package/build/engine/resource-loader/loaders/index.js +6 -0
- package/build/engine/resource-loader/loaders/json-loader.d.ts +7 -0
- package/build/engine/resource-loader/loaders/json-loader.js +14 -0
- package/build/engine/resource-loader/loaders/loader.d.ts +4 -0
- package/build/engine/resource-loader/loaders/loader.js +1 -0
- package/build/engine/resource-loader/resource-loader-qualifier.d.ts +7 -0
- package/build/engine/resource-loader/resource-loader-qualifier.js +18 -0
- package/build/engine/resource-loader/resource-loader.d.ts +5 -0
- package/build/engine/resource-loader/resource-loader.js +17 -0
- package/build/engine/scene/index.d.ts +3 -0
- package/build/engine/scene/index.js +2 -0
- package/build/engine/scene/scene-provider.d.ts +50 -0
- package/build/engine/scene/scene-provider.js +151 -0
- package/build/engine/scene/scene.d.ts +46 -0
- package/build/engine/scene/scene.js +98 -0
- package/build/engine/system/index.d.ts +2 -0
- package/build/engine/system/index.js +1 -0
- package/build/engine/system/system.d.ts +25 -0
- package/build/engine/system/system.js +3 -0
- package/build/engine/template/index.d.ts +2 -0
- package/build/engine/template/index.js +2 -0
- package/build/engine/template/template-collection.d.ts +13 -0
- package/build/engine/template/template-collection.js +44 -0
- package/build/engine/template/template.d.ts +17 -0
- package/build/engine/template/template.js +43 -0
- package/build/engine/types/config.d.ts +47 -0
- package/build/engine/types/config.js +1 -0
- package/build/engine/types/index.d.ts +1 -0
- package/build/engine/types/index.js +1 -0
- package/build/events/index.d.ts +4 -0
- package/build/events/index.js +2 -0
- package/build/index.d.ts +15 -0
- package/build/index.js +11 -0
- package/build/types/events.d.ts +9 -0
- package/build/types/events.js +1 -0
- package/build/types/global.d.ts +2 -0
- package/build/types/global.js +2 -0
- package/build/types/utils.d.ts +1 -0
- package/build/types/utils.js +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
export class Transform extends Component {
|
|
3
|
+
relativeOffsetX;
|
|
4
|
+
relativeOffsetY;
|
|
5
|
+
relativeOffsetZ;
|
|
6
|
+
relativeRotation;
|
|
7
|
+
relativeScaleX;
|
|
8
|
+
relativeScaleY;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super();
|
|
11
|
+
this.relativeOffsetX = config.offsetX;
|
|
12
|
+
this.relativeOffsetY = config.offsetY;
|
|
13
|
+
this.relativeOffsetZ = config.offsetZ;
|
|
14
|
+
this.relativeRotation = config.rotation;
|
|
15
|
+
this.relativeScaleX = config.scaleX || 1;
|
|
16
|
+
this.relativeScaleY = config.scaleY || 1;
|
|
17
|
+
}
|
|
18
|
+
_getPropertyFromParent(name, defaultValue) {
|
|
19
|
+
const parentComponent = this.getParentComponent();
|
|
20
|
+
return parentComponent ? parentComponent[name] : defaultValue;
|
|
21
|
+
}
|
|
22
|
+
set offsetX(offsetX) {
|
|
23
|
+
this.relativeOffsetX = offsetX - this._getPropertyFromParent('offsetX', 0);
|
|
24
|
+
}
|
|
25
|
+
get offsetX() {
|
|
26
|
+
return this.relativeOffsetX + this._getPropertyFromParent('offsetX', 0);
|
|
27
|
+
}
|
|
28
|
+
set offsetY(offsetY) {
|
|
29
|
+
this.relativeOffsetY = offsetY - this._getPropertyFromParent('offsetY', 0);
|
|
30
|
+
}
|
|
31
|
+
get offsetY() {
|
|
32
|
+
return this.relativeOffsetY + this._getPropertyFromParent('offsetY', 0);
|
|
33
|
+
}
|
|
34
|
+
set offsetZ(offsetZ) {
|
|
35
|
+
this.relativeOffsetZ = offsetZ - this._getPropertyFromParent('offsetZ', 0);
|
|
36
|
+
}
|
|
37
|
+
get offsetZ() {
|
|
38
|
+
return this.relativeOffsetZ + this._getPropertyFromParent('offsetZ', 0);
|
|
39
|
+
}
|
|
40
|
+
set rotation(rotation) {
|
|
41
|
+
this.relativeRotation = rotation - this._getPropertyFromParent('rotation', 0);
|
|
42
|
+
}
|
|
43
|
+
get rotation() {
|
|
44
|
+
return this.relativeRotation + this._getPropertyFromParent('rotation', 0);
|
|
45
|
+
}
|
|
46
|
+
set scaleX(scaleX) {
|
|
47
|
+
this.relativeScaleX = scaleX / this._getPropertyFromParent('scaleX', 1);
|
|
48
|
+
}
|
|
49
|
+
get scaleX() {
|
|
50
|
+
return this.relativeScaleX * this._getPropertyFromParent('scaleX', 1);
|
|
51
|
+
}
|
|
52
|
+
set scaleY(scaleY) {
|
|
53
|
+
this.relativeScaleY = scaleY / this._getPropertyFromParent('scaleY', 1);
|
|
54
|
+
}
|
|
55
|
+
get scaleY() {
|
|
56
|
+
return this.relativeScaleY * this._getPropertyFromParent('scaleY', 1);
|
|
57
|
+
}
|
|
58
|
+
clone() {
|
|
59
|
+
return new Transform({
|
|
60
|
+
offsetX: this.relativeOffsetX,
|
|
61
|
+
offsetY: this.relativeOffsetY,
|
|
62
|
+
offsetZ: this.relativeOffsetZ,
|
|
63
|
+
rotation: this.relativeRotation,
|
|
64
|
+
scaleX: this.relativeScaleX,
|
|
65
|
+
scaleY: this.relativeScaleY,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
Transform.componentName = 'Transform';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Actor } from '../../engine/actor';
|
|
2
|
+
import type { Vector2 } from '../../engine/math-lib';
|
|
3
|
+
import type { CustomMouseEvent, CustomKeyboardEvent } from '../types/input-events';
|
|
4
|
+
import type { ActorEvent, SceneEvent } from '../../types/events';
|
|
5
|
+
export declare const SetCamera = "SetCamera";
|
|
6
|
+
export declare const GameStatsUpdate = "GameStatsUpdate";
|
|
7
|
+
export declare const Collision = "Collision";
|
|
8
|
+
export declare const KeyboardInput = "KeyboardInput";
|
|
9
|
+
export declare const MouseInput = "MouseInput";
|
|
10
|
+
export declare const CollisionEnter = "CollisionEnter";
|
|
11
|
+
export declare const CollisionStay = "CollisionStay";
|
|
12
|
+
export declare const CollisionLeave = "CollisionLeave";
|
|
13
|
+
export declare const AddForce = "AddForce";
|
|
14
|
+
export declare const AddImpulse = "AddImpulse";
|
|
15
|
+
export declare const StopMovement = "StopMovement";
|
|
16
|
+
export type MouseInputEvent = SceneEvent<CustomMouseEvent>;
|
|
17
|
+
export type KeyboardInputEvent = SceneEvent<CustomKeyboardEvent>;
|
|
18
|
+
export type SetCameraEvent = SceneEvent<{
|
|
19
|
+
actorId: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type GameStatsUpdateEvent = SceneEvent<{
|
|
22
|
+
fps: number;
|
|
23
|
+
actorsCount: number;
|
|
24
|
+
}>;
|
|
25
|
+
export type CollisionEvent = SceneEvent<{
|
|
26
|
+
actor1: Actor;
|
|
27
|
+
actor2: Actor;
|
|
28
|
+
mtv1: Vector2;
|
|
29
|
+
mtv2: Vector2;
|
|
30
|
+
}>;
|
|
31
|
+
export type MouseControlEvent<T = Record<string, never>> = ActorEvent<Pick<CustomMouseEvent, 'x' | 'y' | 'screenX' | 'screenY' | 'nativeEvent'>> & T;
|
|
32
|
+
export type KeyboardControlEvent<T = Record<string, never>> = ActorEvent<T>;
|
|
33
|
+
type CollisionStateEvent = ActorEvent<{
|
|
34
|
+
actor: Actor;
|
|
35
|
+
mtv: Vector2;
|
|
36
|
+
}>;
|
|
37
|
+
export type CollisionEnterEvent = CollisionStateEvent;
|
|
38
|
+
export type CollisionStayEvent = CollisionStateEvent;
|
|
39
|
+
export type CollisionLeaveEvent = CollisionStateEvent;
|
|
40
|
+
export type AddForceEvent = ActorEvent<{
|
|
41
|
+
value: Vector2;
|
|
42
|
+
}>;
|
|
43
|
+
export type AddImpulseEvent = ActorEvent<{
|
|
44
|
+
value: Vector2;
|
|
45
|
+
}>;
|
|
46
|
+
declare module '../../types/events' {
|
|
47
|
+
interface SceneEventMap {
|
|
48
|
+
[MouseInput]: MouseInputEvent;
|
|
49
|
+
[KeyboardInput]: KeyboardInputEvent;
|
|
50
|
+
[SetCamera]: SetCameraEvent;
|
|
51
|
+
[GameStatsUpdate]: GameStatsUpdateEvent;
|
|
52
|
+
[Collision]: CollisionEvent;
|
|
53
|
+
}
|
|
54
|
+
interface ActorEventMap {
|
|
55
|
+
[CollisionEnter]: CollisionEnterEvent;
|
|
56
|
+
[CollisionStay]: CollisionStayEvent;
|
|
57
|
+
[CollisionLeave]: CollisionLeaveEvent;
|
|
58
|
+
[AddForce]: AddForceEvent;
|
|
59
|
+
[AddImpulse]: AddImpulseEvent;
|
|
60
|
+
[StopMovement]: ActorEvent;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const SetCamera = 'SetCamera';
|
|
2
|
+
export const GameStatsUpdate = 'GameStatsUpdate';
|
|
3
|
+
export const Collision = 'Collision';
|
|
4
|
+
export const KeyboardInput = 'KeyboardInput';
|
|
5
|
+
export const MouseInput = 'MouseInput';
|
|
6
|
+
export const CollisionEnter = 'CollisionEnter';
|
|
7
|
+
export const CollisionStay = 'CollisionStay';
|
|
8
|
+
export const CollisionLeave = 'CollisionLeave';
|
|
9
|
+
export const AddForce = 'AddForce';
|
|
10
|
+
export const AddImpulse = 'AddImpulse';
|
|
11
|
+
export const StopMovement = 'StopMovement';
|
package/build/contrib/systems/animator/condition-controllers/comparator-condition-controller.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Actor } from '../../../../engine/actor';
|
|
2
|
+
import type { ComparatorConditionProps } from '../../../components/animatable/comparator-condition-props';
|
|
3
|
+
import { ConditionController } from './condition-controller';
|
|
4
|
+
export declare class ComparatorConditionController implements ConditionController {
|
|
5
|
+
private actor;
|
|
6
|
+
private props;
|
|
7
|
+
constructor(props: ComparatorConditionProps, actor: Actor);
|
|
8
|
+
private getValue;
|
|
9
|
+
check(): boolean;
|
|
10
|
+
}
|
package/build/contrib/systems/animator/condition-controllers/comparator-condition-controller.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getValue as getComponentValue } from '../utils';
|
|
2
|
+
const operations = {
|
|
3
|
+
equals: (arg1, arg2) => arg1 === arg2,
|
|
4
|
+
notEquals: (arg1, arg2) => arg1 !== arg2,
|
|
5
|
+
greater: (arg1, arg2) => arg1 > arg2,
|
|
6
|
+
less: (arg1, arg2) => arg1 < arg2,
|
|
7
|
+
greaterOrEqual: (arg1, arg2) => arg1 >= arg2,
|
|
8
|
+
lessOrEqual: (arg1, arg2) => arg1 <= arg2,
|
|
9
|
+
};
|
|
10
|
+
export class ComparatorConditionController {
|
|
11
|
+
actor;
|
|
12
|
+
props;
|
|
13
|
+
constructor(props, actor) {
|
|
14
|
+
this.actor = actor;
|
|
15
|
+
this.props = props;
|
|
16
|
+
}
|
|
17
|
+
getValue(actor, arg) {
|
|
18
|
+
if (arg.type === 'componentValue') {
|
|
19
|
+
return getComponentValue(actor, arg.value);
|
|
20
|
+
}
|
|
21
|
+
return arg.value;
|
|
22
|
+
}
|
|
23
|
+
check() {
|
|
24
|
+
const { operation } = this.props;
|
|
25
|
+
if (!operations[operation]) {
|
|
26
|
+
throw new Error(`Unknown operation type: ${operation}`);
|
|
27
|
+
}
|
|
28
|
+
const arg1 = this.getValue(this.actor, this.props.arg1);
|
|
29
|
+
const arg2 = this.getValue(this.actor, this.props.arg2);
|
|
30
|
+
return operations[operation](arg1, arg2);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Actor } from '../../../../engine/actor';
|
|
2
|
+
import type { EventConditionProps } from '../../../components/animatable/event-condition-props';
|
|
3
|
+
import { ConditionController } from './condition-controller';
|
|
4
|
+
export declare class EventConditionController implements ConditionController {
|
|
5
|
+
private isEventFired;
|
|
6
|
+
constructor(props: EventConditionProps, actor: Actor);
|
|
7
|
+
check(): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class EventConditionController {
|
|
2
|
+
isEventFired;
|
|
3
|
+
constructor(props, actor) {
|
|
4
|
+
this.isEventFired = false;
|
|
5
|
+
const { eventType } = props;
|
|
6
|
+
const handleEvent = (event) => {
|
|
7
|
+
if (event.target !== actor) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
this.isEventFired = true;
|
|
11
|
+
actor.removeEventListener(eventType, handleEvent);
|
|
12
|
+
};
|
|
13
|
+
actor.addEventListener(eventType, handleEvent);
|
|
14
|
+
}
|
|
15
|
+
check() {
|
|
16
|
+
return this.isEventFired;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EventConditionController } from './event-condition-controller';
|
|
2
|
+
import { ComparatorConditionController } from './comparator-condition-controller';
|
|
3
|
+
export const conditionControllers = {
|
|
4
|
+
event: EventConditionController,
|
|
5
|
+
comparator: ComparatorConditionController,
|
|
6
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { System } from '../../../engine/system';
|
|
2
|
+
import type { SystemOptions, UpdateOptions } from '../../../engine/system';
|
|
3
|
+
export declare class Animator extends System {
|
|
4
|
+
private actorCollection;
|
|
5
|
+
private substatePickers;
|
|
6
|
+
private actorConditions;
|
|
7
|
+
constructor(options: SystemOptions);
|
|
8
|
+
mount(): void;
|
|
9
|
+
unmount(): void;
|
|
10
|
+
private handleActorRemove;
|
|
11
|
+
private setUpConditionControllers;
|
|
12
|
+
private updateFrame;
|
|
13
|
+
private pickSubstate;
|
|
14
|
+
update(options: UpdateOptions): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { System } from '../../../engine/system';
|
|
2
|
+
import { ActorCollection } from '../../../engine/actor';
|
|
3
|
+
import { Animatable } from '../../components/animatable';
|
|
4
|
+
import { RemoveActor } from '../../../engine/events';
|
|
5
|
+
import { conditionControllers } from './condition-controllers';
|
|
6
|
+
import { substatePickers } from './substate-pickers';
|
|
7
|
+
import { setValue } from './utils';
|
|
8
|
+
const FRAME_RATE = 100;
|
|
9
|
+
export class Animator extends System {
|
|
10
|
+
actorCollection;
|
|
11
|
+
substatePickers;
|
|
12
|
+
actorConditions;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super();
|
|
15
|
+
this.actorCollection = new ActorCollection(options.scene, {
|
|
16
|
+
components: [Animatable],
|
|
17
|
+
});
|
|
18
|
+
this.substatePickers = Object.keys(substatePickers)
|
|
19
|
+
.reduce((storage, key) => {
|
|
20
|
+
const SubstatePicker = substatePickers[key];
|
|
21
|
+
storage[key] = new SubstatePicker();
|
|
22
|
+
return storage;
|
|
23
|
+
}, {});
|
|
24
|
+
this.actorConditions = {};
|
|
25
|
+
}
|
|
26
|
+
mount() {
|
|
27
|
+
this.actorCollection.addEventListener(RemoveActor, this.handleActorRemove);
|
|
28
|
+
}
|
|
29
|
+
unmount() {
|
|
30
|
+
this.actorCollection.removeEventListener(RemoveActor, this.handleActorRemove);
|
|
31
|
+
}
|
|
32
|
+
handleActorRemove = (event) => {
|
|
33
|
+
delete this.actorConditions[event.actor.id];
|
|
34
|
+
};
|
|
35
|
+
setUpConditionControllers(actor) {
|
|
36
|
+
this.actorConditions[actor.id] = {};
|
|
37
|
+
const animatable = actor.getComponent(Animatable);
|
|
38
|
+
animatable.currentState?.transitions.forEach((transition) => {
|
|
39
|
+
this.actorConditions[actor.id][transition.id] ??= {};
|
|
40
|
+
const transitionMap = this.actorConditions[actor.id][transition.id];
|
|
41
|
+
transition.conditions.forEach((condition) => {
|
|
42
|
+
const ConditionController = conditionControllers[condition.type];
|
|
43
|
+
transitionMap[condition.id] = new ConditionController(condition.props, actor);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
updateFrame(actor, frame) {
|
|
48
|
+
Object.keys(frame).forEach((fieldName) => setValue(actor, frame[fieldName].path, frame[fieldName].value));
|
|
49
|
+
}
|
|
50
|
+
pickSubstate(actor, state) {
|
|
51
|
+
const substatePicker = this.substatePickers[state.pickMode];
|
|
52
|
+
return substatePicker.getSubstate(actor, state.substates, state.pickProps);
|
|
53
|
+
}
|
|
54
|
+
update(options) {
|
|
55
|
+
const { deltaTime } = options;
|
|
56
|
+
this.actorCollection.forEach((actor) => {
|
|
57
|
+
const animatable = actor.getComponent(Animatable);
|
|
58
|
+
if (animatable.currentState === void 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!this.actorConditions[actor.id]) {
|
|
62
|
+
this.setUpConditionControllers(actor);
|
|
63
|
+
}
|
|
64
|
+
let { timeline } = animatable.currentState;
|
|
65
|
+
if (animatable.currentState.substates) {
|
|
66
|
+
const substate = this.pickSubstate(actor, animatable.currentState);
|
|
67
|
+
timeline = substate.timeline;
|
|
68
|
+
}
|
|
69
|
+
const framesCount = timeline.frames.length;
|
|
70
|
+
const actualFrameRate = FRAME_RATE / animatable.currentState.speed;
|
|
71
|
+
const baseDuration = framesCount * actualFrameRate;
|
|
72
|
+
animatable.duration += deltaTime / baseDuration;
|
|
73
|
+
const currentFrame = animatable.duration < 1 || timeline.looped
|
|
74
|
+
? Math.trunc((animatable.duration % 1) * framesCount)
|
|
75
|
+
: framesCount - 1;
|
|
76
|
+
this.updateFrame(actor, timeline.frames[currentFrame]);
|
|
77
|
+
const nextTransition = animatable.currentState.transitions.find((transition) => {
|
|
78
|
+
if (transition.time && animatable.duration < transition.time) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return transition.conditions.every((condition) => {
|
|
82
|
+
return this.actorConditions[actor.id][transition.id][condition.id].check();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
if (nextTransition) {
|
|
86
|
+
animatable.setCurrentState(nextTransition.state);
|
|
87
|
+
animatable.duration = 0;
|
|
88
|
+
this.setUpConditionControllers(actor);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Animator.systemName = 'Animator';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Actor } from '../../../../engine/actor';
|
|
2
|
+
import type { Substate } from '../../../components/animatable/substate';
|
|
3
|
+
import type { OneDimensionalProps } from '../../../components/animatable/one-dimensional-props';
|
|
4
|
+
import type { Picker } from './picker';
|
|
5
|
+
export declare class OneDimensionalPicker implements Picker {
|
|
6
|
+
private getDistance;
|
|
7
|
+
getSubstate(actor: Actor, substates: Array<Substate>, props: OneDimensionalProps): Substate;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getValue } from '../utils';
|
|
2
|
+
export class OneDimensionalPicker {
|
|
3
|
+
getDistance(x1, x2) {
|
|
4
|
+
return Math.abs(x1 - x2);
|
|
5
|
+
}
|
|
6
|
+
getSubstate(actor, substates, props) {
|
|
7
|
+
if (!substates.length) {
|
|
8
|
+
throw new Error('Can\'t pick substate, because current state doesn\'t contain any substates');
|
|
9
|
+
}
|
|
10
|
+
if (substates.length === 1) {
|
|
11
|
+
return substates[0];
|
|
12
|
+
}
|
|
13
|
+
const x = getValue(actor, props.x);
|
|
14
|
+
let pickedSubstate = substates[0];
|
|
15
|
+
let minDistance = this.getDistance(x, pickedSubstate.x);
|
|
16
|
+
for (let i = 1; i < substates.length; i += 1) {
|
|
17
|
+
const distance = this.getDistance(x, substates[i].x);
|
|
18
|
+
if (distance < minDistance) {
|
|
19
|
+
pickedSubstate = substates[i];
|
|
20
|
+
minDistance = distance;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return pickedSubstate;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Actor } from '../../../../engine/actor';
|
|
2
|
+
import type { Substate } from '../../../components/animatable/substate';
|
|
3
|
+
import type { OneDimensionalProps } from '../../../components/animatable/one-dimensional-props';
|
|
4
|
+
import type { TwoDimensionalProps } from '../../../components/animatable/two-dimensional-props';
|
|
5
|
+
export interface Picker {
|
|
6
|
+
getSubstate(actor: Actor, substates: Array<Substate>, props: OneDimensionalProps | TwoDimensionalProps): Substate;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Actor } from '../../../../engine/actor';
|
|
2
|
+
import type { Substate } from '../../../components/animatable/substate';
|
|
3
|
+
import type { TwoDimensionalProps } from '../../../components/animatable/two-dimensional-props';
|
|
4
|
+
import { Picker } from './picker';
|
|
5
|
+
export declare class TwoDimensionalPicker implements Picker {
|
|
6
|
+
private getDistance;
|
|
7
|
+
getSubstate(actor: Actor, substates: Array<Substate>, props: TwoDimensionalProps): Substate;
|
|
8
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MathOps } from '../../../../engine/math-lib';
|
|
2
|
+
import { getValue } from '../utils';
|
|
3
|
+
export class TwoDimensionalPicker {
|
|
4
|
+
getDistance(x1, x2, y1, y2) {
|
|
5
|
+
return MathOps.getDistanceBetweenTwoPoints(x1, x2, y1, y2);
|
|
6
|
+
}
|
|
7
|
+
getSubstate(actor, substates, props) {
|
|
8
|
+
if (!substates.length) {
|
|
9
|
+
throw new Error('Can\'t pick substate, because current state doesn\'t contain any substates');
|
|
10
|
+
}
|
|
11
|
+
if (substates.length === 1) {
|
|
12
|
+
return substates[0];
|
|
13
|
+
}
|
|
14
|
+
const x = getValue(actor, props.x);
|
|
15
|
+
const y = getValue(actor, props.y);
|
|
16
|
+
let pickedSubstate = substates[0];
|
|
17
|
+
let minDistance = this.getDistance(x, pickedSubstate.x, y, pickedSubstate.y);
|
|
18
|
+
for (let i = 1; i < substates.length; i += 1) {
|
|
19
|
+
const distance = this.getDistance(x, substates[i].x, y, substates[i].y);
|
|
20
|
+
if (distance < minDistance) {
|
|
21
|
+
pickedSubstate = substates[i];
|
|
22
|
+
minDistance = distance;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return pickedSubstate;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Actor } from '../../../engine/actor';
|
|
2
|
+
const PATH_COMPONENTS = 'components';
|
|
3
|
+
const PATH_CHILDREN = 'children';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
|
+
const _getValue = (actor, path, pathDepth) => {
|
|
6
|
+
let soughtValue = actor;
|
|
7
|
+
for (let i = 0; i < pathDepth && soughtValue !== undefined; i += 1) {
|
|
8
|
+
if (soughtValue instanceof Actor && path[i] === PATH_CHILDREN) {
|
|
9
|
+
i += 1;
|
|
10
|
+
soughtValue = soughtValue.children.find((child) => child.name === path[i]);
|
|
11
|
+
}
|
|
12
|
+
else if (soughtValue instanceof Actor && path[i] === PATH_COMPONENTS) {
|
|
13
|
+
i += 1;
|
|
14
|
+
soughtValue = soughtValue.getComponent(path[i]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
soughtValue = soughtValue[path[i]];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return soughtValue;
|
|
21
|
+
};
|
|
22
|
+
export const getValue = (actor, path) => _getValue(actor, path, path.length);
|
|
23
|
+
export const setValue = (actor, path, value) => {
|
|
24
|
+
const soughtValue = _getValue(actor, path, path.length - 1);
|
|
25
|
+
if (!soughtValue) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (soughtValue instanceof Actor) {
|
|
29
|
+
throw new Error(`Can't set frame value for path: ${path.join('.')}. Setting value as actor property is restricted`);
|
|
30
|
+
}
|
|
31
|
+
soughtValue[path[path.length - 1]] = value;
|
|
32
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Actor, ActorCollection } from '../../../engine/actor';
|
|
2
|
+
interface CameraServiceOptions {
|
|
3
|
+
cameraCollection: ActorCollection;
|
|
4
|
+
onCameraUpdate: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class CameraService {
|
|
7
|
+
private cameraCollection;
|
|
8
|
+
private onCameraUpdate;
|
|
9
|
+
constructor({ cameraCollection, onCameraUpdate }: CameraServiceOptions);
|
|
10
|
+
setCurrentCamera(actor: Actor): void;
|
|
11
|
+
getCurrentCamera(): Actor | undefined;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Camera } from '../../components';
|
|
2
|
+
export class CameraService {
|
|
3
|
+
cameraCollection;
|
|
4
|
+
onCameraUpdate;
|
|
5
|
+
constructor({ cameraCollection, onCameraUpdate }) {
|
|
6
|
+
this.cameraCollection = cameraCollection;
|
|
7
|
+
this.onCameraUpdate = onCameraUpdate;
|
|
8
|
+
}
|
|
9
|
+
setCurrentCamera(actor) {
|
|
10
|
+
if (!actor.getComponent(Camera)) {
|
|
11
|
+
throw new Error(`Can't set current camera. Actor with id: ${actor.id} doesn't contain Camera component.`);
|
|
12
|
+
}
|
|
13
|
+
this.cameraCollection.forEach((cameraActor) => {
|
|
14
|
+
const camera = cameraActor.getComponent(Camera);
|
|
15
|
+
camera.current = actor.id === cameraActor.id;
|
|
16
|
+
});
|
|
17
|
+
this.onCameraUpdate();
|
|
18
|
+
}
|
|
19
|
+
getCurrentCamera() {
|
|
20
|
+
return this.cameraCollection.find((actor) => {
|
|
21
|
+
const camera = actor.getComponent(Camera);
|
|
22
|
+
return camera.current;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { System } from '../../../engine/system';
|
|
2
|
+
import type { SystemOptions } from '../../../engine/system';
|
|
3
|
+
export declare class CameraSystem extends System {
|
|
4
|
+
private actorCollection;
|
|
5
|
+
private scene;
|
|
6
|
+
private window;
|
|
7
|
+
private cameraService;
|
|
8
|
+
constructor(options: SystemOptions);
|
|
9
|
+
mount(): void;
|
|
10
|
+
unmount(): void;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use CameraService instead
|
|
13
|
+
*/
|
|
14
|
+
private handleSetCamera;
|
|
15
|
+
private handleCameraUpdate;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { System } from '../../../engine/system';
|
|
2
|
+
import { ActorCollection } from '../../../engine/actor';
|
|
3
|
+
import { Camera } from '../../components/camera';
|
|
4
|
+
import { getWindowNode } from '../../utils/get-window-node';
|
|
5
|
+
import { SetCamera } from '../../events';
|
|
6
|
+
import { CameraService } from './service';
|
|
7
|
+
export class CameraSystem extends System {
|
|
8
|
+
actorCollection;
|
|
9
|
+
scene;
|
|
10
|
+
window;
|
|
11
|
+
cameraService;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super();
|
|
14
|
+
const { windowNodeId, scene, } = options;
|
|
15
|
+
const windowNode = getWindowNode(windowNodeId);
|
|
16
|
+
this.actorCollection = new ActorCollection(scene, {
|
|
17
|
+
components: [
|
|
18
|
+
Camera,
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
this.scene = scene;
|
|
22
|
+
this.window = windowNode;
|
|
23
|
+
this.cameraService = new CameraService({
|
|
24
|
+
cameraCollection: this.actorCollection,
|
|
25
|
+
onCameraUpdate: this.handleCameraUpdate,
|
|
26
|
+
});
|
|
27
|
+
scene.addService(this.cameraService);
|
|
28
|
+
}
|
|
29
|
+
mount() {
|
|
30
|
+
this.handleCameraUpdate();
|
|
31
|
+
window.addEventListener('resize', this.handleCameraUpdate);
|
|
32
|
+
this.scene.addEventListener(SetCamera, this.handleSetCamera);
|
|
33
|
+
}
|
|
34
|
+
unmount() {
|
|
35
|
+
window.removeEventListener('resize', this.handleCameraUpdate);
|
|
36
|
+
this.scene.removeEventListener(SetCamera, this.handleSetCamera);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use CameraService instead
|
|
40
|
+
*/
|
|
41
|
+
handleSetCamera = (event) => {
|
|
42
|
+
const { actorId } = event;
|
|
43
|
+
const newCamera = this.actorCollection.getById(actorId);
|
|
44
|
+
if (!newCamera) {
|
|
45
|
+
throw new Error(`Could not set camera with id ${actorId} for the scene`);
|
|
46
|
+
}
|
|
47
|
+
this.cameraService.setCurrentCamera(newCamera);
|
|
48
|
+
this.handleCameraUpdate();
|
|
49
|
+
};
|
|
50
|
+
handleCameraUpdate = () => {
|
|
51
|
+
const width = this.window.innerWidth || this.window.clientWidth;
|
|
52
|
+
const height = this.window.innerHeight || this.window.clientHeight;
|
|
53
|
+
const camera = this.cameraService.getCurrentCamera();
|
|
54
|
+
if (!camera) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const cameraComponent = camera.getComponent(Camera);
|
|
58
|
+
const { windowSizeX, windowSizeY } = cameraComponent;
|
|
59
|
+
if (width !== windowSizeX || height !== windowSizeY) {
|
|
60
|
+
cameraComponent.windowSizeX = width;
|
|
61
|
+
cameraComponent.windowSizeY = height;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
CameraSystem.systemName = 'CameraSystem';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { System } from '../../../engine/system';
|
|
2
|
+
import type { SystemOptions, UpdateOptions } from '../../../engine/system';
|
|
3
|
+
export declare class GameStatsMeter extends System {
|
|
4
|
+
private scene;
|
|
5
|
+
private actorCollection;
|
|
6
|
+
private frequency;
|
|
7
|
+
private fps;
|
|
8
|
+
private time;
|
|
9
|
+
constructor(options: SystemOptions);
|
|
10
|
+
update(options: UpdateOptions): void;
|
|
11
|
+
}
|