1681-engine 0.0.0-stage → 0.5.8
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/CHANGELOG.md +304 -0
- package/LICENSE +21 -0
- package/README.md +164 -2
- package/dist/1681-engine.js +417 -0
- package/dist/1681-engine.js.map +1 -0
- package/dist/ambient/ColorGrade.js +41 -0
- package/dist/ambient/ColorGrade.js.map +1 -0
- package/dist/ambient/DayClock.js +57 -0
- package/dist/ambient/DayClock.js.map +1 -0
- package/dist/ambient/WeatherLayer.js +91 -0
- package/dist/ambient/WeatherLayer.js.map +1 -0
- package/dist/ambient/grade.js +13 -0
- package/dist/ambient/grade.js.map +1 -0
- package/dist/ambient/weather.js +52 -0
- package/dist/ambient/weather.js.map +1 -0
- package/dist/anim/AnimStateMachine.js +164 -0
- package/dist/anim/AnimStateMachine.js.map +1 -0
- package/dist/anim/Animator.js +67 -0
- package/dist/anim/Animator.js.map +1 -0
- package/dist/anim/animStateCompile.js +113 -0
- package/dist/anim/animStateCompile.js.map +1 -0
- package/dist/anim/animStateSystem.js +17 -0
- package/dist/anim/animStateSystem.js.map +1 -0
- package/dist/anim/animationSystem.js +15 -0
- package/dist/anim/animationSystem.js.map +1 -0
- package/dist/anim/asepriteSlices.js +22 -0
- package/dist/anim/asepriteSlices.js.map +1 -0
- package/dist/anim/asepriteTags.js +35 -0
- package/dist/anim/asepriteTags.js.map +1 -0
- package/dist/anim/parseAseprite.js +83 -0
- package/dist/anim/parseAseprite.js.map +1 -0
- package/dist/assets/AssetLoader.js +104 -0
- package/dist/assets/AssetLoader.js.map +1 -0
- package/dist/assets/loadAseprite.js +50 -0
- package/dist/assets/loadAseprite.js.map +1 -0
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js +31 -0
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js.map +1 -0
- package/dist/audio/Footsteps.js +26 -0
- package/dist/audio/Footsteps.js.map +1 -0
- package/dist/audio/MusicPlayer.js +78 -0
- package/dist/audio/MusicPlayer.js.map +1 -0
- package/dist/audio/SoundEngine.js +119 -0
- package/dist/audio/SoundEngine.js.map +1 -0
- package/dist/audio/cleanTake.js +30 -0
- package/dist/audio/cleanTake.js.map +1 -0
- package/dist/audio/music/ElementVoice.js +35 -0
- package/dist/audio/music/ElementVoice.js.map +1 -0
- package/dist/audio/music/GraphVoice.js +39 -0
- package/dist/audio/music/GraphVoice.js.map +1 -0
- package/dist/audio/music/MusicChannel.js +58 -0
- package/dist/audio/music/MusicChannel.js.map +1 -0
- package/dist/audio/music/musicVoice.js +13 -0
- package/dist/audio/music/musicVoice.js.map +1 -0
- package/dist/audio/sampleBank.js +82 -0
- package/dist/audio/sampleBank.js.map +1 -0
- package/dist/audio/soundTable.js +9 -0
- package/dist/audio/soundTable.js.map +1 -0
- package/dist/audio/synth.js +36 -0
- package/dist/audio/synth.js.map +1 -0
- package/dist/core/BitmapLabel.js +49 -0
- package/dist/core/BitmapLabel.js.map +1 -0
- package/dist/core/Camera.js +150 -0
- package/dist/core/Camera.js.map +1 -0
- package/dist/core/Clock.js +30 -0
- package/dist/core/Clock.js.map +1 -0
- package/dist/core/Graphics.js +69 -0
- package/dist/core/Graphics.js.map +1 -0
- package/dist/core/Group.js +29 -0
- package/dist/core/Group.js.map +1 -0
- package/dist/core/Image.js +51 -0
- package/dist/core/Image.js.map +1 -0
- package/dist/core/ObjectFactory.js +55 -0
- package/dist/core/ObjectFactory.js.map +1 -0
- package/dist/core/Pointer.js +58 -0
- package/dist/core/Pointer.js.map +1 -0
- package/dist/core/Rectangle.js +51 -0
- package/dist/core/Rectangle.js.map +1 -0
- package/dist/core/Stage.js +86 -0
- package/dist/core/Stage.js.map +1 -0
- package/dist/core/Text.js +22 -0
- package/dist/core/Text.js.map +1 -0
- package/dist/core/TextureRegistry.js +111 -0
- package/dist/core/TextureRegistry.js.map +1 -0
- package/dist/core/Timeline.js +211 -0
- package/dist/core/Timeline.js.map +1 -0
- package/dist/core/TimelineBuilder.js +73 -0
- package/dist/core/TimelineBuilder.js.map +1 -0
- package/dist/core/TimelineChild.js +84 -0
- package/dist/core/TimelineChild.js.map +1 -0
- package/dist/core/Tweener.js +136 -0
- package/dist/core/Tweener.js.map +1 -0
- package/dist/core/atlas.js +38 -0
- package/dist/core/atlas.js.map +1 -0
- package/dist/core/atlasPlan.js +22 -0
- package/dist/core/atlasPlan.js.map +1 -0
- package/dist/core/eases.js +21 -0
- package/dist/core/eases.js.map +1 -0
- package/dist/core/gameObject.js +115 -0
- package/dist/core/gameObject.js.map +1 -0
- package/dist/core/pixiPatches.js +18 -0
- package/dist/core/pixiPatches.js.map +1 -0
- package/dist/core/timelinePlace.js +24 -0
- package/dist/core/timelinePlace.js.map +1 -0
- package/dist/core/tweenProps.js +12 -0
- package/dist/core/tweenProps.js.map +1 -0
- package/dist/debug/DebugOverlay.js +94 -0
- package/dist/debug/DebugOverlay.js.map +1 -0
- package/dist/debug/DrawCallCounter.js +41 -0
- package/dist/debug/DrawCallCounter.js.map +1 -0
- package/dist/debug/ErrorLog.js +22 -0
- package/dist/debug/ErrorLog.js.map +1 -0
- package/dist/debug/FrameStats.js +42 -0
- package/dist/debug/FrameStats.js.map +1 -0
- package/dist/debug/inspectWorld.js +29 -0
- package/dist/debug/inspectWorld.js.map +1 -0
- package/dist/diagnostics/ErrorDeduper.js +27 -0
- package/dist/diagnostics/ErrorDeduper.js.map +1 -0
- package/dist/diagnostics/FrameSampler.js +42 -0
- package/dist/diagnostics/FrameSampler.js.map +1 -0
- package/dist/diagnostics/bootWatch.js +21 -0
- package/dist/diagnostics/bootWatch.js.map +1 -0
- package/dist/diagnostics/captureErrors.js +27 -0
- package/dist/diagnostics/captureErrors.js.map +1 -0
- package/dist/diagnostics/contextLoss.js +25 -0
- package/dist/diagnostics/contextLoss.js.map +1 -0
- package/dist/diagnostics/frameStats.js +31 -0
- package/dist/diagnostics/frameStats.js.map +1 -0
- package/dist/diagnostics/gpuInfo.js +22 -0
- package/dist/diagnostics/gpuInfo.js.map +1 -0
- package/dist/diagnostics/renderGuard.js +24 -0
- package/dist/diagnostics/renderGuard.js.map +1 -0
- package/dist/ecs/SparseSet.js +55 -0
- package/dist/ecs/SparseSet.js.map +1 -0
- package/dist/ecs/World.js +307 -0
- package/dist/ecs/World.js.map +1 -0
- package/dist/ecs/fields.js +26 -0
- package/dist/ecs/fields.js.map +1 -0
- package/dist/engine/Engine.js +82 -0
- package/dist/engine/Engine.js.map +1 -0
- package/dist/engine/FixedLoop.js +37 -0
- package/dist/engine/FixedLoop.js.map +1 -0
- package/dist/engine/Scene.js +79 -0
- package/dist/engine/Scene.js.map +1 -0
- package/dist/engine/SceneManager.js +73 -0
- package/dist/engine/SceneManager.js.map +1 -0
- package/dist/events/EventBus.js +42 -0
- package/dist/events/EventBus.js.map +1 -0
- package/dist/fx/FloatingText.js +72 -0
- package/dist/fx/FloatingText.js.map +1 -0
- package/dist/fx/hitStop.js +28 -0
- package/dist/fx/hitStop.js.map +1 -0
- package/dist/fx/viewCull.js +10 -0
- package/dist/fx/viewCull.js.map +1 -0
- package/dist/i18n/Translator.js +72 -0
- package/dist/i18n/Translator.js.map +1 -0
- package/dist/i18n/extractStrings.js +58 -0
- package/dist/i18n/extractStrings.js.map +1 -0
- package/dist/i18n/formatMessage.js +19 -0
- package/dist/i18n/formatMessage.js.map +1 -0
- package/dist/input/Actions.js +131 -0
- package/dist/input/Actions.js.map +1 -0
- package/dist/input/AimGesture.js +75 -0
- package/dist/input/AimGesture.js.map +1 -0
- package/dist/input/Keyboard.js +54 -0
- package/dist/input/Keyboard.js.map +1 -0
- package/dist/input/Keymap.js +171 -0
- package/dist/input/Keymap.js.map +1 -0
- package/dist/input/TargetLock.js +73 -0
- package/dist/input/TargetLock.js.map +1 -0
- package/dist/input/aimAxis.js +8 -0
- package/dist/input/aimAxis.js.map +1 -0
- package/dist/input/keyChord.js +29 -0
- package/dist/input/keyChord.js.map +1 -0
- package/dist/input/longPress.js +32 -0
- package/dist/input/longPress.js.map +1 -0
- package/dist/input/stickAxis.js +23 -0
- package/dist/input/stickAxis.js.map +1 -0
- package/dist/input/touchDetect.js +7 -0
- package/dist/input/touchDetect.js.map +1 -0
- package/dist/light/LightLayer.js +84 -0
- package/dist/light/LightLayer.js.map +1 -0
- package/dist/nav/MinHeap.js +39 -0
- package/dist/nav/MinHeap.js.map +1 -0
- package/dist/nav/findPath.js +78 -0
- package/dist/nav/findPath.js.map +1 -0
- package/dist/nav/navGrid.js +36 -0
- package/dist/nav/navGrid.js.map +1 -0
- package/dist/nav/nearestOpen.js +19 -0
- package/dist/nav/nearestOpen.js.map +1 -0
- package/dist/nav/straightenPath.js +51 -0
- package/dist/nav/straightenPath.js.map +1 -0
- package/dist/net/Connection.js +84 -0
- package/dist/net/Connection.js.map +1 -0
- package/dist/net/InterpolationBuffer.js +57 -0
- package/dist/net/InterpolationBuffer.js.map +1 -0
- package/dist/net/PredictedMover.js +61 -0
- package/dist/net/PredictedMover.js.map +1 -0
- package/dist/net/Room.js +92 -0
- package/dist/net/Room.js.map +1 -0
- package/dist/net/RoomHost.js +101 -0
- package/dist/net/RoomHost.js.map +1 -0
- package/dist/net/cadence.js +22 -0
- package/dist/net/cadence.js.map +1 -0
- package/dist/net/constants.js +11 -0
- package/dist/net/constants.js.map +1 -0
- package/dist/net/lobby/LobbyClient.js +124 -0
- package/dist/net/lobby/LobbyClient.js.map +1 -0
- package/dist/net/lobby/LobbyHost.js +366 -0
- package/dist/net/lobby/LobbyHost.js.map +1 -0
- package/dist/net/lobby/LobbyRooms.js +66 -0
- package/dist/net/lobby/LobbyRooms.js.map +1 -0
- package/dist/net/lobby/Matchmaker.js +106 -0
- package/dist/net/lobby/Matchmaker.js.map +1 -0
- package/dist/net/movement.js +83 -0
- package/dist/net/movement.js.map +1 -0
- package/dist/net/protocol.js +11 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/net/serverClock.js +22 -0
- package/dist/net/serverClock.js.map +1 -0
- package/dist/net/snapshotCodec.js +92 -0
- package/dist/net/snapshotCodec.js.map +1 -0
- package/dist/parallax/Parallax.js +32 -0
- package/dist/parallax/Parallax.js.map +1 -0
- package/dist/parallax/ParallaxLayer.js +70 -0
- package/dist/parallax/ParallaxLayer.js.map +1 -0
- package/dist/parallax/parallaxMath.js +27 -0
- package/dist/parallax/parallaxMath.js.map +1 -0
- package/dist/particles/Emitter.js +108 -0
- package/dist/particles/Emitter.js.map +1 -0
- package/dist/particles/ParticleBudget.js +32 -0
- package/dist/particles/ParticleBudget.js.map +1 -0
- package/dist/particles/ParticleSim.js +60 -0
- package/dist/particles/ParticleSim.js.map +1 -0
- package/dist/particles/particleCurves.js +48 -0
- package/dist/particles/particleCurves.js.map +1 -0
- package/dist/particles/particleSampling.js +30 -0
- package/dist/particles/particleSampling.js.map +1 -0
- package/dist/physics/Body.js +202 -0
- package/dist/physics/Body.js.map +1 -0
- package/dist/physics/BroadPhase.js +56 -0
- package/dist/physics/BroadPhase.js.map +1 -0
- package/dist/physics/Contact.js +76 -0
- package/dist/physics/Contact.js.map +1 -0
- package/dist/physics/ContactSolver.js +70 -0
- package/dist/physics/ContactSolver.js.map +1 -0
- package/dist/physics/PhysicsWorld.js +221 -0
- package/dist/physics/PhysicsWorld.js.map +1 -0
- package/dist/physics/SpatialHash.js +39 -0
- package/dist/physics/SpatialHash.js.map +1 -0
- package/dist/physics/collide.js +76 -0
- package/dist/physics/collide.js.map +1 -0
- package/dist/physics/collidePolygon.js +94 -0
- package/dist/physics/collidePolygon.js.map +1 -0
- package/dist/physics/contactReport.js +14 -0
- package/dist/physics/contactReport.js.map +1 -0
- package/dist/physics/drawColliders.js +31 -0
- package/dist/physics/drawColliders.js.map +1 -0
- package/dist/physics/physicsSystem.js +8 -0
- package/dist/physics/physicsSystem.js.map +1 -0
- package/dist/physics/polygon.js +80 -0
- package/dist/physics/polygon.js.map +1 -0
- package/dist/physics/raycast.js +62 -0
- package/dist/physics/raycast.js.map +1 -0
- package/dist/physics/syncToBody.js +19 -0
- package/dist/physics/syncToBody.js.map +1 -0
- package/dist/physics/tileBodies.js +59 -0
- package/dist/physics/tileBodies.js.map +1 -0
- package/dist/physics/types.js +8 -0
- package/dist/physics/types.js.map +1 -0
- package/dist/pixel/Darkness.js +166 -0
- package/dist/pixel/Darkness.js.map +1 -0
- package/dist/pixel/DitherVignette.js +57 -0
- package/dist/pixel/DitherVignette.js.map +1 -0
- package/dist/pixel/Evaporation.js +85 -0
- package/dist/pixel/Evaporation.js.map +1 -0
- package/dist/pixel/NightShade.js +34 -0
- package/dist/pixel/NightShade.js.map +1 -0
- package/dist/pixel/PixelLayer.js +211 -0
- package/dist/pixel/PixelLayer.js.map +1 -0
- package/dist/pixel/SwayProp.js +75 -0
- package/dist/pixel/SwayProp.js.map +1 -0
- package/dist/pixel/lights.js +44 -0
- package/dist/pixel/lights.js.map +1 -0
- package/dist/pixel/nineSlice.js +62 -0
- package/dist/pixel/nineSlice.js.map +1 -0
- package/dist/pixel/paintLayer.js +36 -0
- package/dist/pixel/paintLayer.js.map +1 -0
- package/dist/pixel/palette.js +57 -0
- package/dist/pixel/palette.js.map +1 -0
- package/dist/pixel/pixel.js +278 -0
- package/dist/pixel/pixel.js.map +1 -0
- package/dist/pixel/pixelPaint.js +194 -0
- package/dist/pixel/pixelPaint.js.map +1 -0
- package/dist/pixel/pixelTone.js +164 -0
- package/dist/pixel/pixelTone.js.map +1 -0
- package/dist/pixel/propKit.js +41 -0
- package/dist/pixel/propKit.js.map +1 -0
- package/dist/pixel/ramp.js +102 -0
- package/dist/pixel/ramp.js.map +1 -0
- package/dist/pixel/selout.js +35 -0
- package/dist/pixel/selout.js.map +1 -0
- package/dist/pixel/spritePixels.js +59 -0
- package/dist/pixel/spritePixels.js.map +1 -0
- package/dist/pixel/swayRig.js +87 -0
- package/dist/pixel/swayRig.js.map +1 -0
- package/dist/pixel/vignetteMask.js +24 -0
- package/dist/pixel/vignetteMask.js.map +1 -0
- package/dist/pixel/weatherArt.js +61 -0
- package/dist/pixel/weatherArt.js.map +1 -0
- package/dist/pixel.js +90 -0
- package/dist/pixel.js.map +1 -0
- package/dist/platform/touch.js +33 -0
- package/dist/platform/touch.js.map +1 -0
- package/dist/postfx/BloomFilter.js +65 -0
- package/dist/postfx/BloomFilter.js.map +1 -0
- package/dist/postfx/ChromaticAberrationFilter.js +25 -0
- package/dist/postfx/ChromaticAberrationFilter.js.map +1 -0
- package/dist/postfx/ColorAdjustFilter.js +76 -0
- package/dist/postfx/ColorAdjustFilter.js.map +1 -0
- package/dist/postfx/CrtFilter.js +42 -0
- package/dist/postfx/CrtFilter.js.map +1 -0
- package/dist/postfx/PixelateFilter.js +27 -0
- package/dist/postfx/PixelateFilter.js.map +1 -0
- package/dist/postfx/PostFx.js +123 -0
- package/dist/postfx/PostFx.js.map +1 -0
- package/dist/postfx/ShockwaveFilter.js +49 -0
- package/dist/postfx/ShockwaveFilter.js.map +1 -0
- package/dist/postfx/VignetteFilter.js +37 -0
- package/dist/postfx/VignetteFilter.js.map +1 -0
- package/dist/postfx/fxAnimator.js +38 -0
- package/dist/postfx/fxAnimator.js.map +1 -0
- package/dist/postfx/fxShader.js +128 -0
- package/dist/postfx/fxShader.js.map +1 -0
- package/dist/postfx.js +26 -0
- package/dist/postfx.js.map +1 -0
- package/dist/react/ChoiceDialog.js +51 -0
- package/dist/react/ChoiceDialog.js.map +1 -0
- package/dist/react/ConfirmDialog.js +53 -0
- package/dist/react/ConfirmDialog.js.map +1 -0
- package/dist/react/Glyph.js +63 -0
- package/dist/react/Glyph.js.map +1 -0
- package/dist/react/Modal.js +38 -0
- package/dist/react/Modal.js.map +1 -0
- package/dist/react/Panel.js +24 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/PixelImage.js +24 -0
- package/dist/react/PixelImage.js.map +1 -0
- package/dist/react/Select.js +99 -0
- package/dist/react/Select.js.map +1 -0
- package/dist/react/Slider.js +62 -0
- package/dist/react/Slider.js.map +1 -0
- package/dist/react/SplitPane.js +24 -0
- package/dist/react/SplitPane.js.map +1 -0
- package/dist/react/TabStrip.js +32 -0
- package/dist/react/TabStrip.js.map +1 -0
- package/dist/react/TitleTips.js +42 -0
- package/dist/react/TitleTips.js.map +1 -0
- package/dist/react/Tooltip.js +28 -0
- package/dist/react/Tooltip.js.map +1 -0
- package/dist/react/UiProvider.js +50 -0
- package/dist/react/UiProvider.js.map +1 -0
- package/dist/react/baseCss.js +222 -0
- package/dist/react/baseCss.js.map +1 -0
- package/dist/react/choiceStore.js +23 -0
- package/dist/react/choiceStore.js.map +1 -0
- package/dist/react/classNames.js +19 -0
- package/dist/react/classNames.js.map +1 -0
- package/dist/react/confirmStore.js +30 -0
- package/dist/react/confirmStore.js.map +1 -0
- package/dist/react/labels.js +18 -0
- package/dist/react/labels.js.map +1 -0
- package/dist/react/placement.js +49 -0
- package/dist/react/placement.js.map +1 -0
- package/dist/react/useFillSheet.js +23 -0
- package/dist/react/useFillSheet.js.map +1 -0
- package/dist/react/useFitToViewport.js +29 -0
- package/dist/react/useFitToViewport.js.map +1 -0
- package/dist/react/usePicked.js +13 -0
- package/dist/react/usePicked.js.map +1 -0
- package/dist/react/useStore.js +9 -0
- package/dist/react/useStore.js.map +1 -0
- package/dist/react/useViewport.js +17 -0
- package/dist/react/useViewport.js.map +1 -0
- package/dist/react.js +78 -0
- package/dist/react.js.map +1 -0
- package/dist/rig/PosePlayer.js +92 -0
- package/dist/rig/PosePlayer.js.map +1 -0
- package/dist/rig/RigView.js +125 -0
- package/dist/rig/RigView.js.map +1 -0
- package/dist/rig/Skeleton.js +31 -0
- package/dist/rig/Skeleton.js.map +1 -0
- package/dist/rig/humanoid.js +6 -0
- package/dist/rig/humanoid.js.map +1 -0
- package/dist/rig/humanoid.json.js +30 -0
- package/dist/rig/humanoid.json.js.map +1 -0
- package/dist/rig/humanoidPoses.js +30 -0
- package/dist/rig/humanoidPoses.js.map +1 -0
- package/dist/rig/poseMath.js +54 -0
- package/dist/rig/poseMath.js.map +1 -0
- package/dist/rig/poses.json.js +150 -0
- package/dist/rig/poses.json.js.map +1 -0
- package/dist/save/Autosaver.js +54 -0
- package/dist/save/Autosaver.js.map +1 -0
- package/dist/save/MemoryBackend.js +19 -0
- package/dist/save/MemoryBackend.js.map +1 -0
- package/dist/save/SaveStore.js +103 -0
- package/dist/save/SaveStore.js.map +1 -0
- package/dist/save/WebStorageBackend.js +27 -0
- package/dist/save/WebStorageBackend.js.map +1 -0
- package/dist/save/checksum.js +10 -0
- package/dist/save/checksum.js.map +1 -0
- package/dist/save/migrateSave.js +27 -0
- package/dist/save/migrateSave.js.map +1 -0
- package/dist/settings.js +27 -0
- package/dist/settings.js.map +1 -0
- package/dist/tilemap/TilemapView.js +69 -0
- package/dist/tilemap/TilemapView.js.map +1 -0
- package/dist/tilemap/collision.js +25 -0
- package/dist/tilemap/collision.js.map +1 -0
- package/dist/tilemap/tiled.js +138 -0
- package/dist/tilemap/tiled.js.map +1 -0
- package/dist/transitions/CrossfadeTransition.js +24 -0
- package/dist/transitions/CrossfadeTransition.js.map +1 -0
- package/dist/transitions/DitherWipeTransition.js +70 -0
- package/dist/transitions/DitherWipeTransition.js.map +1 -0
- package/dist/transitions/FadeTransition.js +34 -0
- package/dist/transitions/FadeTransition.js.map +1 -0
- package/dist/transitions/Letterbox.js +42 -0
- package/dist/transitions/Letterbox.js.map +1 -0
- package/dist/transitions/ditherMask.js +15 -0
- package/dist/transitions/ditherMask.js.map +1 -0
- package/dist/transitions/transitionTo.js +28 -0
- package/dist/transitions/transitionTo.js.map +1 -0
- package/dist/transitions/tweenDone.js +15 -0
- package/dist/transitions/tweenDone.js.map +1 -0
- package/dist/types/ambient/ColorGrade.d.ts +41 -0
- package/dist/types/ambient/ColorGrade.d.ts.map +1 -0
- package/dist/types/ambient/DayClock.d.ts +80 -0
- package/dist/types/ambient/DayClock.d.ts.map +1 -0
- package/dist/types/ambient/WeatherLayer.d.ts +78 -0
- package/dist/types/ambient/WeatherLayer.d.ts.map +1 -0
- package/dist/types/ambient/grade.d.ts +22 -0
- package/dist/types/ambient/grade.d.ts.map +1 -0
- package/dist/types/ambient/weather.d.ts +49 -0
- package/dist/types/ambient/weather.d.ts.map +1 -0
- package/dist/types/anim/AnimStateMachine.d.ts +80 -0
- package/dist/types/anim/AnimStateMachine.d.ts.map +1 -0
- package/dist/types/anim/Animator.d.ts +50 -0
- package/dist/types/anim/Animator.d.ts.map +1 -0
- package/dist/types/anim/animStateCompile.d.ts +52 -0
- package/dist/types/anim/animStateCompile.d.ts.map +1 -0
- package/dist/types/anim/animStateSystem.d.ts +10 -0
- package/dist/types/anim/animStateSystem.d.ts.map +1 -0
- package/dist/types/anim/animStateTypes.d.ts +50 -0
- package/dist/types/anim/animStateTypes.d.ts.map +1 -0
- package/dist/types/anim/animationSystem.d.ts +13 -0
- package/dist/types/anim/animationSystem.d.ts.map +1 -0
- package/dist/types/anim/asepriteSlices.d.ts +19 -0
- package/dist/types/anim/asepriteSlices.d.ts.map +1 -0
- package/dist/types/anim/asepriteTags.d.ts +16 -0
- package/dist/types/anim/asepriteTags.d.ts.map +1 -0
- package/dist/types/anim/asepriteTypes.d.ts +159 -0
- package/dist/types/anim/asepriteTypes.d.ts.map +1 -0
- package/dist/types/anim/parseAseprite.d.ts +21 -0
- package/dist/types/anim/parseAseprite.d.ts.map +1 -0
- package/dist/types/assets/AssetLoader.d.ts +85 -0
- package/dist/types/assets/AssetLoader.d.ts.map +1 -0
- package/dist/types/assets/loadAseprite.d.ts +27 -0
- package/dist/types/assets/loadAseprite.d.ts.map +1 -0
- package/dist/types/audio/Footsteps.d.ts +33 -0
- package/dist/types/audio/Footsteps.d.ts.map +1 -0
- package/dist/types/audio/MusicPlayer.d.ts +65 -0
- package/dist/types/audio/MusicPlayer.d.ts.map +1 -0
- package/dist/types/audio/SoundEngine.d.ts +42 -0
- package/dist/types/audio/SoundEngine.d.ts.map +1 -0
- package/dist/types/audio/cleanTake.d.ts +3 -0
- package/dist/types/audio/cleanTake.d.ts.map +1 -0
- package/dist/types/audio/music/ElementVoice.d.ts +14 -0
- package/dist/types/audio/music/ElementVoice.d.ts.map +1 -0
- package/dist/types/audio/music/GraphVoice.d.ts +22 -0
- package/dist/types/audio/music/GraphVoice.d.ts.map +1 -0
- package/dist/types/audio/music/MusicChannel.d.ts +35 -0
- package/dist/types/audio/music/MusicChannel.d.ts.map +1 -0
- package/dist/types/audio/music/musicVoice.d.ts +26 -0
- package/dist/types/audio/music/musicVoice.d.ts.map +1 -0
- package/dist/types/audio/sampleBank.d.ts +27 -0
- package/dist/types/audio/sampleBank.d.ts.map +1 -0
- package/dist/types/audio/soundTable.d.ts +14 -0
- package/dist/types/audio/soundTable.d.ts.map +1 -0
- package/dist/types/audio/synth.d.ts +34 -0
- package/dist/types/audio/synth.d.ts.map +1 -0
- package/dist/types/audio/takeCleanerWorker.d.ts +2 -0
- package/dist/types/audio/takeCleanerWorker.d.ts.map +1 -0
- package/dist/types/core/BitmapLabel.d.ts +36 -0
- package/dist/types/core/BitmapLabel.d.ts.map +1 -0
- package/dist/types/core/Camera.d.ts +115 -0
- package/dist/types/core/Camera.d.ts.map +1 -0
- package/dist/types/core/Clock.d.ts +11 -0
- package/dist/types/core/Clock.d.ts.map +1 -0
- package/dist/types/core/Graphics.d.ts +37 -0
- package/dist/types/core/Graphics.d.ts.map +1 -0
- package/dist/types/core/Group.d.ts +15 -0
- package/dist/types/core/Group.d.ts.map +1 -0
- package/dist/types/core/Image.d.ts +25 -0
- package/dist/types/core/Image.d.ts.map +1 -0
- package/dist/types/core/ObjectFactory.d.ts +34 -0
- package/dist/types/core/ObjectFactory.d.ts.map +1 -0
- package/dist/types/core/Pointer.d.ts +27 -0
- package/dist/types/core/Pointer.d.ts.map +1 -0
- package/dist/types/core/Rectangle.d.ts +26 -0
- package/dist/types/core/Rectangle.d.ts.map +1 -0
- package/dist/types/core/Stage.d.ts +58 -0
- package/dist/types/core/Stage.d.ts.map +1 -0
- package/dist/types/core/Text.d.ts +22 -0
- package/dist/types/core/Text.d.ts.map +1 -0
- package/dist/types/core/TextureRegistry.d.ts +51 -0
- package/dist/types/core/TextureRegistry.d.ts.map +1 -0
- package/dist/types/core/Timeline.d.ts +115 -0
- package/dist/types/core/Timeline.d.ts.map +1 -0
- package/dist/types/core/TimelineBuilder.d.ts +53 -0
- package/dist/types/core/TimelineBuilder.d.ts.map +1 -0
- package/dist/types/core/TimelineChild.d.ts +51 -0
- package/dist/types/core/TimelineChild.d.ts.map +1 -0
- package/dist/types/core/Tweener.d.ts +70 -0
- package/dist/types/core/Tweener.d.ts.map +1 -0
- package/dist/types/core/atlas.d.ts +16 -0
- package/dist/types/core/atlas.d.ts.map +1 -0
- package/dist/types/core/atlasPlan.d.ts +34 -0
- package/dist/types/core/atlasPlan.d.ts.map +1 -0
- package/dist/types/core/eases.d.ts +3 -0
- package/dist/types/core/eases.d.ts.map +1 -0
- package/dist/types/core/gameObject.d.ts +42 -0
- package/dist/types/core/gameObject.d.ts.map +1 -0
- package/dist/types/core/pixiPatches.d.ts +9 -0
- package/dist/types/core/pixiPatches.d.ts.map +1 -0
- package/dist/types/core/timelinePlace.d.ts +23 -0
- package/dist/types/core/timelinePlace.d.ts.map +1 -0
- package/dist/types/core/tweenProps.d.ts +8 -0
- package/dist/types/core/tweenProps.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +4 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/debug/DebugOverlay.d.ts +63 -0
- package/dist/types/debug/DebugOverlay.d.ts.map +1 -0
- package/dist/types/debug/DrawCallCounter.d.ts +20 -0
- package/dist/types/debug/DrawCallCounter.d.ts.map +1 -0
- package/dist/types/debug/ErrorLog.d.ts +20 -0
- package/dist/types/debug/ErrorLog.d.ts.map +1 -0
- package/dist/types/debug/FrameStats.d.ts +21 -0
- package/dist/types/debug/FrameStats.d.ts.map +1 -0
- package/dist/types/debug/inspectWorld.d.ts +14 -0
- package/dist/types/debug/inspectWorld.d.ts.map +1 -0
- package/dist/types/diagnostics/ErrorDeduper.d.ts +17 -0
- package/dist/types/diagnostics/ErrorDeduper.d.ts.map +1 -0
- package/dist/types/diagnostics/FrameSampler.d.ts +37 -0
- package/dist/types/diagnostics/FrameSampler.d.ts.map +1 -0
- package/dist/types/diagnostics/bootWatch.d.ts +25 -0
- package/dist/types/diagnostics/bootWatch.d.ts.map +1 -0
- package/dist/types/diagnostics/captureErrors.d.ts +24 -0
- package/dist/types/diagnostics/captureErrors.d.ts.map +1 -0
- package/dist/types/diagnostics/contextLoss.d.ts +35 -0
- package/dist/types/diagnostics/contextLoss.d.ts.map +1 -0
- package/dist/types/diagnostics/frameStats.d.ts +30 -0
- package/dist/types/diagnostics/frameStats.d.ts.map +1 -0
- package/dist/types/diagnostics/gpuInfo.d.ts +9 -0
- package/dist/types/diagnostics/gpuInfo.d.ts.map +1 -0
- package/dist/types/diagnostics/renderGuard.d.ts +12 -0
- package/dist/types/diagnostics/renderGuard.d.ts.map +1 -0
- package/dist/types/ecs/SparseSet.d.ts +25 -0
- package/dist/types/ecs/SparseSet.d.ts.map +1 -0
- package/dist/types/ecs/World.d.ts +137 -0
- package/dist/types/ecs/World.d.ts.map +1 -0
- package/dist/types/ecs/fields.d.ts +34 -0
- package/dist/types/ecs/fields.d.ts.map +1 -0
- package/dist/types/engine/Engine.d.ts +80 -0
- package/dist/types/engine/Engine.d.ts.map +1 -0
- package/dist/types/engine/FixedLoop.d.ts +32 -0
- package/dist/types/engine/FixedLoop.d.ts.map +1 -0
- package/dist/types/engine/Scene.d.ts +67 -0
- package/dist/types/engine/Scene.d.ts.map +1 -0
- package/dist/types/engine/SceneManager.d.ts +36 -0
- package/dist/types/engine/SceneManager.d.ts.map +1 -0
- package/dist/types/events/EventBus.d.ts +20 -0
- package/dist/types/events/EventBus.d.ts.map +1 -0
- package/dist/types/fx/FloatingText.d.ts +71 -0
- package/dist/types/fx/FloatingText.d.ts.map +1 -0
- package/dist/types/fx/hitStop.d.ts +20 -0
- package/dist/types/fx/hitStop.d.ts.map +1 -0
- package/dist/types/fx/viewCull.d.ts +14 -0
- package/dist/types/fx/viewCull.d.ts.map +1 -0
- package/dist/types/i18n/Translator.d.ts +52 -0
- package/dist/types/i18n/Translator.d.ts.map +1 -0
- package/dist/types/i18n/extractStrings.d.ts +25 -0
- package/dist/types/i18n/extractStrings.d.ts.map +1 -0
- package/dist/types/i18n/formatMessage.d.ts +10 -0
- package/dist/types/i18n/formatMessage.d.ts.map +1 -0
- package/dist/types/index.d.ts +149 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/input/Actions.d.ts +94 -0
- package/dist/types/input/Actions.d.ts.map +1 -0
- package/dist/types/input/AimGesture.d.ts +106 -0
- package/dist/types/input/AimGesture.d.ts.map +1 -0
- package/dist/types/input/Keyboard.d.ts +30 -0
- package/dist/types/input/Keyboard.d.ts.map +1 -0
- package/dist/types/input/Keymap.d.ts +85 -0
- package/dist/types/input/Keymap.d.ts.map +1 -0
- package/dist/types/input/TargetLock.d.ts +56 -0
- package/dist/types/input/TargetLock.d.ts.map +1 -0
- package/dist/types/input/aimAxis.d.ts +9 -0
- package/dist/types/input/aimAxis.d.ts.map +1 -0
- package/dist/types/input/keyChord.d.ts +15 -0
- package/dist/types/input/keyChord.d.ts.map +1 -0
- package/dist/types/input/longPress.d.ts +21 -0
- package/dist/types/input/longPress.d.ts.map +1 -0
- package/dist/types/input/stickAxis.d.ts +26 -0
- package/dist/types/input/stickAxis.d.ts.map +1 -0
- package/dist/types/input/touchDetect.d.ts +18 -0
- package/dist/types/input/touchDetect.d.ts.map +1 -0
- package/dist/types/light/LightLayer.d.ts +65 -0
- package/dist/types/light/LightLayer.d.ts.map +1 -0
- package/dist/types/nav/MinHeap.d.ts +15 -0
- package/dist/types/nav/MinHeap.d.ts.map +1 -0
- package/dist/types/nav/findPath.d.ts +38 -0
- package/dist/types/nav/findPath.d.ts.map +1 -0
- package/dist/types/nav/navGrid.d.ts +48 -0
- package/dist/types/nav/navGrid.d.ts.map +1 -0
- package/dist/types/nav/nearestOpen.d.ts +8 -0
- package/dist/types/nav/nearestOpen.d.ts.map +1 -0
- package/dist/types/nav/straightenPath.d.ts +13 -0
- package/dist/types/nav/straightenPath.d.ts.map +1 -0
- package/dist/types/net/Connection.d.ts +66 -0
- package/dist/types/net/Connection.d.ts.map +1 -0
- package/dist/types/net/InterpolationBuffer.d.ts +36 -0
- package/dist/types/net/InterpolationBuffer.d.ts.map +1 -0
- package/dist/types/net/PredictedMover.d.ts +43 -0
- package/dist/types/net/PredictedMover.d.ts.map +1 -0
- package/dist/types/net/Room.d.ts +69 -0
- package/dist/types/net/Room.d.ts.map +1 -0
- package/dist/types/net/RoomHost.d.ts +74 -0
- package/dist/types/net/RoomHost.d.ts.map +1 -0
- package/dist/types/net/cadence.d.ts +22 -0
- package/dist/types/net/cadence.d.ts.map +1 -0
- package/dist/types/net/constants.d.ts +24 -0
- package/dist/types/net/constants.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyClient.d.ts +107 -0
- package/dist/types/net/lobby/LobbyClient.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyHost.d.ts +147 -0
- package/dist/types/net/lobby/LobbyHost.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyRooms.d.ts +56 -0
- package/dist/types/net/lobby/LobbyRooms.d.ts.map +1 -0
- package/dist/types/net/lobby/Matchmaker.d.ts +57 -0
- package/dist/types/net/lobby/Matchmaker.d.ts.map +1 -0
- package/dist/types/net/lobby/index.d.ts +6 -0
- package/dist/types/net/lobby/index.d.ts.map +1 -0
- package/dist/types/net/lobby/lobbyProtocol.d.ts +143 -0
- package/dist/types/net/lobby/lobbyProtocol.d.ts.map +1 -0
- package/dist/types/net/movement.d.ts +50 -0
- package/dist/types/net/movement.d.ts.map +1 -0
- package/dist/types/net/protocol.d.ts +59 -0
- package/dist/types/net/protocol.d.ts.map +1 -0
- package/dist/types/net/serverClock.d.ts +14 -0
- package/dist/types/net/serverClock.d.ts.map +1 -0
- package/dist/types/net/snapshotCodec.d.ts +55 -0
- package/dist/types/net/snapshotCodec.d.ts.map +1 -0
- package/dist/types/parallax/Parallax.d.ts +37 -0
- package/dist/types/parallax/Parallax.d.ts.map +1 -0
- package/dist/types/parallax/ParallaxLayer.d.ts +80 -0
- package/dist/types/parallax/ParallaxLayer.d.ts.map +1 -0
- package/dist/types/parallax/parallaxMath.d.ts +50 -0
- package/dist/types/parallax/parallaxMath.d.ts.map +1 -0
- package/dist/types/particles/Emitter.d.ts +97 -0
- package/dist/types/particles/Emitter.d.ts.map +1 -0
- package/dist/types/particles/ParticleBudget.d.ts +28 -0
- package/dist/types/particles/ParticleBudget.d.ts.map +1 -0
- package/dist/types/particles/ParticleSim.d.ts +38 -0
- package/dist/types/particles/ParticleSim.d.ts.map +1 -0
- package/dist/types/particles/particleCurves.d.ts +21 -0
- package/dist/types/particles/particleCurves.d.ts.map +1 -0
- package/dist/types/particles/particleSampling.d.ts +20 -0
- package/dist/types/particles/particleSampling.d.ts.map +1 -0
- package/dist/types/physics/Body.d.ts +130 -0
- package/dist/types/physics/Body.d.ts.map +1 -0
- package/dist/types/physics/BroadPhase.d.ts +26 -0
- package/dist/types/physics/BroadPhase.d.ts.map +1 -0
- package/dist/types/physics/Contact.d.ts +62 -0
- package/dist/types/physics/Contact.d.ts.map +1 -0
- package/dist/types/physics/ContactSolver.d.ts +29 -0
- package/dist/types/physics/ContactSolver.d.ts.map +1 -0
- package/dist/types/physics/PhysicsWorld.d.ts +78 -0
- package/dist/types/physics/PhysicsWorld.d.ts.map +1 -0
- package/dist/types/physics/PhysicsWorldOptions.d.ts +24 -0
- package/dist/types/physics/PhysicsWorldOptions.d.ts.map +1 -0
- package/dist/types/physics/SpatialHash.d.ts +23 -0
- package/dist/types/physics/SpatialHash.d.ts.map +1 -0
- package/dist/types/physics/collide.d.ts +27 -0
- package/dist/types/physics/collide.d.ts.map +1 -0
- package/dist/types/physics/collidePolygon.d.ts +14 -0
- package/dist/types/physics/collidePolygon.d.ts.map +1 -0
- package/dist/types/physics/contactReport.d.ts +8 -0
- package/dist/types/physics/contactReport.d.ts.map +1 -0
- package/dist/types/physics/drawColliders.d.ts +43 -0
- package/dist/types/physics/drawColliders.d.ts.map +1 -0
- package/dist/types/physics/physicsSystem.d.ts +5 -0
- package/dist/types/physics/physicsSystem.d.ts.map +1 -0
- package/dist/types/physics/polygon.d.ts +28 -0
- package/dist/types/physics/polygon.d.ts.map +1 -0
- package/dist/types/physics/raycast.d.ts +19 -0
- package/dist/types/physics/raycast.d.ts.map +1 -0
- package/dist/types/physics/syncToBody.d.ts +16 -0
- package/dist/types/physics/syncToBody.d.ts.map +1 -0
- package/dist/types/physics/tileBodies.d.ts +36 -0
- package/dist/types/physics/tileBodies.d.ts.map +1 -0
- package/dist/types/physics/types.d.ts +116 -0
- package/dist/types/physics/types.d.ts.map +1 -0
- package/dist/types/pixel/Darkness.d.ts +78 -0
- package/dist/types/pixel/Darkness.d.ts.map +1 -0
- package/dist/types/pixel/DitherVignette.d.ts +35 -0
- package/dist/types/pixel/DitherVignette.d.ts.map +1 -0
- package/dist/types/pixel/Evaporation.d.ts +30 -0
- package/dist/types/pixel/Evaporation.d.ts.map +1 -0
- package/dist/types/pixel/NightShade.d.ts +38 -0
- package/dist/types/pixel/NightShade.d.ts.map +1 -0
- package/dist/types/pixel/PixelLayer.d.ts +85 -0
- package/dist/types/pixel/PixelLayer.d.ts.map +1 -0
- package/dist/types/pixel/SwayProp.d.ts +52 -0
- package/dist/types/pixel/SwayProp.d.ts.map +1 -0
- package/dist/types/pixel/index.d.ts +31 -0
- package/dist/types/pixel/index.d.ts.map +1 -0
- package/dist/types/pixel/lights.d.ts +34 -0
- package/dist/types/pixel/lights.d.ts.map +1 -0
- package/dist/types/pixel/nineSlice.d.ts +71 -0
- package/dist/types/pixel/nineSlice.d.ts.map +1 -0
- package/dist/types/pixel/paintLayer.d.ts +35 -0
- package/dist/types/pixel/paintLayer.d.ts.map +1 -0
- package/dist/types/pixel/palette.d.ts +58 -0
- package/dist/types/pixel/palette.d.ts.map +1 -0
- package/dist/types/pixel/pixel.d.ts +80 -0
- package/dist/types/pixel/pixel.d.ts.map +1 -0
- package/dist/types/pixel/pixelPaint.d.ts +43 -0
- package/dist/types/pixel/pixelPaint.d.ts.map +1 -0
- package/dist/types/pixel/pixelTone.d.ts +51 -0
- package/dist/types/pixel/pixelTone.d.ts.map +1 -0
- package/dist/types/pixel/propKit.d.ts +26 -0
- package/dist/types/pixel/propKit.d.ts.map +1 -0
- package/dist/types/pixel/ramp.d.ts +57 -0
- package/dist/types/pixel/ramp.d.ts.map +1 -0
- package/dist/types/pixel/selout.d.ts +3 -0
- package/dist/types/pixel/selout.d.ts.map +1 -0
- package/dist/types/pixel/spritePixels.d.ts +29 -0
- package/dist/types/pixel/spritePixels.d.ts.map +1 -0
- package/dist/types/pixel/swayRig.d.ts +72 -0
- package/dist/types/pixel/swayRig.d.ts.map +1 -0
- package/dist/types/pixel/vignetteMask.d.ts +16 -0
- package/dist/types/pixel/vignetteMask.d.ts.map +1 -0
- package/dist/types/pixel/weatherArt.d.ts +29 -0
- package/dist/types/pixel/weatherArt.d.ts.map +1 -0
- package/dist/types/platform/touch.d.ts +10 -0
- package/dist/types/platform/touch.d.ts.map +1 -0
- package/dist/types/postfx/BloomFilter.d.ts +33 -0
- package/dist/types/postfx/BloomFilter.d.ts.map +1 -0
- package/dist/types/postfx/ChromaticAberrationFilter.d.ts +11 -0
- package/dist/types/postfx/ChromaticAberrationFilter.d.ts.map +1 -0
- package/dist/types/postfx/ColorAdjustFilter.d.ts +32 -0
- package/dist/types/postfx/ColorAdjustFilter.d.ts.map +1 -0
- package/dist/types/postfx/CrtFilter.d.ts +16 -0
- package/dist/types/postfx/CrtFilter.d.ts.map +1 -0
- package/dist/types/postfx/PixelateFilter.d.ts +8 -0
- package/dist/types/postfx/PixelateFilter.d.ts.map +1 -0
- package/dist/types/postfx/PostFx.d.ts +92 -0
- package/dist/types/postfx/PostFx.d.ts.map +1 -0
- package/dist/types/postfx/ShockwaveFilter.d.ts +20 -0
- package/dist/types/postfx/ShockwaveFilter.d.ts.map +1 -0
- package/dist/types/postfx/VignetteFilter.d.ts +19 -0
- package/dist/types/postfx/VignetteFilter.d.ts.map +1 -0
- package/dist/types/postfx/fxAnimator.d.ts +32 -0
- package/dist/types/postfx/fxAnimator.d.ts.map +1 -0
- package/dist/types/postfx/fxShader.d.ts +49 -0
- package/dist/types/postfx/fxShader.d.ts.map +1 -0
- package/dist/types/postfx/index.d.ts +11 -0
- package/dist/types/postfx/index.d.ts.map +1 -0
- package/dist/types/react/ChoiceDialog.d.ts +8 -0
- package/dist/types/react/ChoiceDialog.d.ts.map +1 -0
- package/dist/types/react/ConfirmDialog.d.ts +9 -0
- package/dist/types/react/ConfirmDialog.d.ts.map +1 -0
- package/dist/types/react/Glyph.d.ts +54 -0
- package/dist/types/react/Glyph.d.ts.map +1 -0
- package/dist/types/react/Modal.d.ts +22 -0
- package/dist/types/react/Modal.d.ts.map +1 -0
- package/dist/types/react/Panel.d.ts +29 -0
- package/dist/types/react/Panel.d.ts.map +1 -0
- package/dist/types/react/PixelImage.d.ts +19 -0
- package/dist/types/react/PixelImage.d.ts.map +1 -0
- package/dist/types/react/Select.d.ts +27 -0
- package/dist/types/react/Select.d.ts.map +1 -0
- package/dist/types/react/Slider.d.ts +24 -0
- package/dist/types/react/Slider.d.ts.map +1 -0
- package/dist/types/react/SplitPane.d.ts +26 -0
- package/dist/types/react/SplitPane.d.ts.map +1 -0
- package/dist/types/react/TabStrip.d.ts +31 -0
- package/dist/types/react/TabStrip.d.ts.map +1 -0
- package/dist/types/react/TitleTips.d.ts +15 -0
- package/dist/types/react/TitleTips.d.ts.map +1 -0
- package/dist/types/react/Tooltip.d.ts +22 -0
- package/dist/types/react/Tooltip.d.ts.map +1 -0
- package/dist/types/react/UiProvider.d.ts +52 -0
- package/dist/types/react/UiProvider.d.ts.map +1 -0
- package/dist/types/react/baseCss.d.ts +27 -0
- package/dist/types/react/baseCss.d.ts.map +1 -0
- package/dist/types/react/choiceStore.d.ts +34 -0
- package/dist/types/react/choiceStore.d.ts.map +1 -0
- package/dist/types/react/classNames.d.ts +12 -0
- package/dist/types/react/classNames.d.ts.map +1 -0
- package/dist/types/react/confirmStore.d.ts +30 -0
- package/dist/types/react/confirmStore.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +33 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/react/labels.d.ts +24 -0
- package/dist/types/react/labels.d.ts.map +1 -0
- package/dist/types/react/placement.d.ts +59 -0
- package/dist/types/react/placement.d.ts.map +1 -0
- package/dist/types/react/useFillSheet.d.ts +9 -0
- package/dist/types/react/useFillSheet.d.ts.map +1 -0
- package/dist/types/react/useFitToViewport.d.ts +20 -0
- package/dist/types/react/useFitToViewport.d.ts.map +1 -0
- package/dist/types/react/usePicked.d.ts +9 -0
- package/dist/types/react/usePicked.d.ts.map +1 -0
- package/dist/types/react/useStore.d.ts +8 -0
- package/dist/types/react/useStore.d.ts.map +1 -0
- package/dist/types/react/useViewport.d.ts +4 -0
- package/dist/types/react/useViewport.d.ts.map +1 -0
- package/dist/types/rig/PosePlayer.d.ts +64 -0
- package/dist/types/rig/PosePlayer.d.ts.map +1 -0
- package/dist/types/rig/RigView.d.ts +68 -0
- package/dist/types/rig/RigView.d.ts.map +1 -0
- package/dist/types/rig/Skeleton.d.ts +14 -0
- package/dist/types/rig/Skeleton.d.ts.map +1 -0
- package/dist/types/rig/humanoid.d.ts +4 -0
- package/dist/types/rig/humanoid.d.ts.map +1 -0
- package/dist/types/rig/humanoidPoses.d.ts +117 -0
- package/dist/types/rig/humanoidPoses.d.ts.map +1 -0
- package/dist/types/rig/poseMath.d.ts +14 -0
- package/dist/types/rig/poseMath.d.ts.map +1 -0
- package/dist/types/rig/rigTypes.d.ts +82 -0
- package/dist/types/rig/rigTypes.d.ts.map +1 -0
- package/dist/types/save/Autosaver.d.ts +43 -0
- package/dist/types/save/Autosaver.d.ts.map +1 -0
- package/dist/types/save/MemoryBackend.d.ts +10 -0
- package/dist/types/save/MemoryBackend.d.ts.map +1 -0
- package/dist/types/save/SaveBackend.d.ts +14 -0
- package/dist/types/save/SaveBackend.d.ts.map +1 -0
- package/dist/types/save/SaveStore.d.ts +73 -0
- package/dist/types/save/SaveStore.d.ts.map +1 -0
- package/dist/types/save/WebStorageBackend.d.ts +14 -0
- package/dist/types/save/WebStorageBackend.d.ts.map +1 -0
- package/dist/types/save/checksum.d.ts +7 -0
- package/dist/types/save/checksum.d.ts.map +1 -0
- package/dist/types/save/migrateSave.d.ts +17 -0
- package/dist/types/save/migrateSave.d.ts.map +1 -0
- package/dist/types/settings.d.ts +25 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/tilemap/TilemapView.d.ts +42 -0
- package/dist/types/tilemap/TilemapView.d.ts.map +1 -0
- package/dist/types/tilemap/collision.d.ts +16 -0
- package/dist/types/tilemap/collision.d.ts.map +1 -0
- package/dist/types/tilemap/tiled.d.ts +104 -0
- package/dist/types/tilemap/tiled.d.ts.map +1 -0
- package/dist/types/transitions/CrossfadeTransition.d.ts +20 -0
- package/dist/types/transitions/CrossfadeTransition.d.ts.map +1 -0
- package/dist/types/transitions/DitherWipeTransition.d.ts +35 -0
- package/dist/types/transitions/DitherWipeTransition.d.ts.map +1 -0
- package/dist/types/transitions/FadeTransition.d.ts +20 -0
- package/dist/types/transitions/FadeTransition.d.ts.map +1 -0
- package/dist/types/transitions/Letterbox.d.ts +33 -0
- package/dist/types/transitions/Letterbox.d.ts.map +1 -0
- package/dist/types/transitions/Transition.d.ts +22 -0
- package/dist/types/transitions/Transition.d.ts.map +1 -0
- package/dist/types/transitions/ditherMask.d.ts +13 -0
- package/dist/types/transitions/ditherMask.d.ts.map +1 -0
- package/dist/types/transitions/transitionTo.d.ts +16 -0
- package/dist/types/transitions/transitionTo.d.ts.map +1 -0
- package/dist/types/transitions/tweenDone.d.ts +5 -0
- package/dist/types/transitions/tweenDone.d.ts.map +1 -0
- package/dist/types/ui/Bar.d.ts +41 -0
- package/dist/types/ui/Bar.d.ts.map +1 -0
- package/dist/types/ui/Button.d.ts +47 -0
- package/dist/types/ui/Button.d.ts.map +1 -0
- package/dist/types/ui/Dialog.d.ts +47 -0
- package/dist/types/ui/Dialog.d.ts.map +1 -0
- package/dist/types/ui/FocusManager.d.ts +53 -0
- package/dist/types/ui/FocusManager.d.ts.map +1 -0
- package/dist/types/ui/Label.d.ts +24 -0
- package/dist/types/ui/Label.d.ts.map +1 -0
- package/dist/types/ui/List.d.ts +23 -0
- package/dist/types/ui/List.d.ts.map +1 -0
- package/dist/types/ui/Panel.d.ts +38 -0
- package/dist/types/ui/Panel.d.ts.map +1 -0
- package/dist/types/ui/ScrollView.d.ts +56 -0
- package/dist/types/ui/ScrollView.d.ts.map +1 -0
- package/dist/types/ui/Slider.d.ts +47 -0
- package/dist/types/ui/Slider.d.ts.map +1 -0
- package/dist/types/ui/Stack.d.ts +16 -0
- package/dist/types/ui/Stack.d.ts.map +1 -0
- package/dist/types/ui/Toggle.d.ts +31 -0
- package/dist/types/ui/Toggle.d.ts.map +1 -0
- package/dist/types/ui/UiHost.d.ts +18 -0
- package/dist/types/ui/UiHost.d.ts.map +1 -0
- package/dist/types/ui/UiPointerGate.d.ts +17 -0
- package/dist/types/ui/UiPointerGate.d.ts.map +1 -0
- package/dist/types/ui/UiRoot.d.ts +73 -0
- package/dist/types/ui/UiRoot.d.ts.map +1 -0
- package/dist/types/ui/Widget.d.ts +56 -0
- package/dist/types/ui/Widget.d.ts.map +1 -0
- package/dist/types/ui/dom/DomOverlay.d.ts +52 -0
- package/dist/types/ui/dom/DomOverlay.d.ts.map +1 -0
- package/dist/types/ui/dom/DomWorldAnchors.d.ts +50 -0
- package/dist/types/ui/dom/DomWorldAnchors.d.ts.map +1 -0
- package/dist/types/ui/dom/InputShield.d.ts +20 -0
- package/dist/types/ui/dom/InputShield.d.ts.map +1 -0
- package/dist/types/ui/dom/createStore.d.ts +22 -0
- package/dist/types/ui/dom/createStore.d.ts.map +1 -0
- package/dist/types/ui/dom/shieldDecision.d.ts +34 -0
- package/dist/types/ui/dom/shieldDecision.d.ts.map +1 -0
- package/dist/types/ui/dom/worldToScreen.d.ts +24 -0
- package/dist/types/ui/dom/worldToScreen.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +38 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/layout/anchor.d.ts +9 -0
- package/dist/types/ui/layout/anchor.d.ts.map +1 -0
- package/dist/types/ui/layout/barDrain.d.ts +25 -0
- package/dist/types/ui/layout/barDrain.d.ts.map +1 -0
- package/dist/types/ui/layout/fitToViewport.d.ts +32 -0
- package/dist/types/ui/layout/fitToViewport.d.ts.map +1 -0
- package/dist/types/ui/layout/focusNav.d.ts +13 -0
- package/dist/types/ui/layout/focusNav.d.ts.map +1 -0
- package/dist/types/ui/layout/geometry.d.ts +35 -0
- package/dist/types/ui/layout/geometry.d.ts.map +1 -0
- package/dist/types/ui/layout/listWidth.d.ts +13 -0
- package/dist/types/ui/layout/listWidth.d.ts.map +1 -0
- package/dist/types/ui/layout/placeTooltip.d.ts +23 -0
- package/dist/types/ui/layout/placeTooltip.d.ts.map +1 -0
- package/dist/types/ui/layout/scroll.d.ts +17 -0
- package/dist/types/ui/layout/scroll.d.ts.map +1 -0
- package/dist/types/ui/layout/slider.d.ts +7 -0
- package/dist/types/ui/layout/slider.d.ts.map +1 -0
- package/dist/types/ui/layout/stack.d.ts +26 -0
- package/dist/types/ui/layout/stack.d.ts.map +1 -0
- package/dist/types/ui/layout/wrapRow.d.ts +6 -0
- package/dist/types/ui/layout/wrapRow.d.ts.map +1 -0
- package/dist/ui/Bar.js +54 -0
- package/dist/ui/Bar.js.map +1 -0
- package/dist/ui/Button.js +58 -0
- package/dist/ui/Button.js.map +1 -0
- package/dist/ui/Dialog.js +56 -0
- package/dist/ui/Dialog.js.map +1 -0
- package/dist/ui/FocusManager.js +97 -0
- package/dist/ui/FocusManager.js.map +1 -0
- package/dist/ui/Label.js +36 -0
- package/dist/ui/Label.js.map +1 -0
- package/dist/ui/List.js +45 -0
- package/dist/ui/List.js.map +1 -0
- package/dist/ui/Panel.js +38 -0
- package/dist/ui/Panel.js.map +1 -0
- package/dist/ui/ScrollView.js +96 -0
- package/dist/ui/ScrollView.js.map +1 -0
- package/dist/ui/Slider.js +55 -0
- package/dist/ui/Slider.js.map +1 -0
- package/dist/ui/Stack.js +28 -0
- package/dist/ui/Stack.js.map +1 -0
- package/dist/ui/Toggle.js +37 -0
- package/dist/ui/Toggle.js.map +1 -0
- package/dist/ui/UiHost.js +9 -0
- package/dist/ui/UiHost.js.map +1 -0
- package/dist/ui/UiPointerGate.js +25 -0
- package/dist/ui/UiPointerGate.js.map +1 -0
- package/dist/ui/UiRoot.js +93 -0
- package/dist/ui/UiRoot.js.map +1 -0
- package/dist/ui/Widget.js +90 -0
- package/dist/ui/Widget.js.map +1 -0
- package/dist/ui/dom/DomOverlay.js +59 -0
- package/dist/ui/dom/DomOverlay.js.map +1 -0
- package/dist/ui/dom/DomWorldAnchors.js +59 -0
- package/dist/ui/dom/DomWorldAnchors.js.map +1 -0
- package/dist/ui/dom/InputShield.js +27 -0
- package/dist/ui/dom/InputShield.js.map +1 -0
- package/dist/ui/dom/createStore.js +42 -0
- package/dist/ui/dom/createStore.js.map +1 -0
- package/dist/ui/dom/shieldDecision.js +36 -0
- package/dist/ui/dom/shieldDecision.js.map +1 -0
- package/dist/ui/dom/worldToScreen.js +11 -0
- package/dist/ui/dom/worldToScreen.js.map +1 -0
- package/dist/ui/layout/anchor.js +20 -0
- package/dist/ui/layout/anchor.js.map +1 -0
- package/dist/ui/layout/barDrain.js +25 -0
- package/dist/ui/layout/barDrain.js.map +1 -0
- package/dist/ui/layout/fitToViewport.js +17 -0
- package/dist/ui/layout/fitToViewport.js.map +1 -0
- package/dist/ui/layout/focusNav.js +42 -0
- package/dist/ui/layout/focusNav.js.map +1 -0
- package/dist/ui/layout/geometry.js +21 -0
- package/dist/ui/layout/geometry.js.map +1 -0
- package/dist/ui/layout/listWidth.js +10 -0
- package/dist/ui/layout/listWidth.js.map +1 -0
- package/dist/ui/layout/placeTooltip.js +28 -0
- package/dist/ui/layout/placeTooltip.js.map +1 -0
- package/dist/ui/layout/scroll.js +24 -0
- package/dist/ui/layout/scroll.js.map +1 -0
- package/dist/ui/layout/slider.js +20 -0
- package/dist/ui/layout/slider.js.map +1 -0
- package/dist/ui/layout/stack.js +27 -0
- package/dist/ui/layout/stack.js.map +1 -0
- package/dist/ui/layout/wrapRow.js +13 -0
- package/dist/ui/layout/wrapRow.js.map +1 -0
- package/dist/ui.js +85 -0
- package/dist/ui.js.map +1 -0
- package/package.json +115 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const o = {
|
|
2
|
+
Shift: ["ShiftLeft", "ShiftRight"],
|
|
3
|
+
Ctrl: ["ControlLeft", "ControlRight"],
|
|
4
|
+
Alt: ["AltLeft", "AltRight"],
|
|
5
|
+
Meta: ["MetaLeft", "MetaRight"]
|
|
6
|
+
};
|
|
7
|
+
function l(e) {
|
|
8
|
+
const t = e.split("+");
|
|
9
|
+
if (t.length < 2) return null;
|
|
10
|
+
const r = t[t.length - 1];
|
|
11
|
+
if (!r) return null;
|
|
12
|
+
const n = [];
|
|
13
|
+
for (const i of t.slice(0, -1)) {
|
|
14
|
+
const f = o[i];
|
|
15
|
+
if (!f) return null;
|
|
16
|
+
n.push(f);
|
|
17
|
+
}
|
|
18
|
+
return { code: r, modifiers: n };
|
|
19
|
+
}
|
|
20
|
+
function s(e, t) {
|
|
21
|
+
if (!t(e.code)) return !1;
|
|
22
|
+
for (const [r, n] of e.modifiers) if (!t(r) && !t(n)) return !1;
|
|
23
|
+
return !0;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
s as chordHeld,
|
|
27
|
+
l as parseChord
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=keyChord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyChord.js","sources":["../../src/input/keyChord.ts"],"sourcesContent":["/**\n * A key binding with modifiers: `Shift+Tab`, `Ctrl+KeyS`, `Ctrl+Shift+KeyZ`. The last part is the key's\n * `KeyboardEvent.code`; before it, any of `Shift`, `Ctrl`, `Alt`, `Meta`, either side of the keyboard counting.\n * A chord matches while its key and every modifier it names are held; modifiers it does not name are not looked at.\n */\nexport interface KeyChord {\n code: string;\n /** The modifiers' key codes, each a pair: either one held counts. */\n modifiers: readonly (readonly [string, string])[];\n}\n\nconst MODIFIERS: Readonly<Record<string, readonly [string, string]>> = {\n Shift: ['ShiftLeft', 'ShiftRight'],\n Ctrl: ['ControlLeft', 'ControlRight'],\n Alt: ['AltLeft', 'AltRight'],\n Meta: ['MetaLeft', 'MetaRight'],\n};\n\n/** The chord a binding names, or null for a plain key (no `+`) or a malformed one (an unknown modifier). */\nexport function parseChord(binding: string): KeyChord | null {\n const parts = binding.split('+');\n if (parts.length < 2) return null;\n const code = parts[parts.length - 1]!;\n if (!code) return null;\n const modifiers: (readonly [string, string])[] = [];\n for (const name of parts.slice(0, -1)) {\n const pair = MODIFIERS[name];\n if (!pair) return null;\n modifiers.push(pair);\n }\n return { code, modifiers };\n}\n\n/** Whether `chord` is held, given which keys are down. */\nexport function chordHeld(chord: KeyChord, down: (code: string) => boolean): boolean {\n if (!down(chord.code)) return false;\n for (const [left, right] of chord.modifiers) if (!down(left) && !down(right)) return false;\n return true;\n}\n"],"names":["MODIFIERS","parseChord","binding","parts","code","modifiers","name","pair","chordHeld","chord","down","left","right"],"mappings":"AAWA,MAAMA,IAAiE;AAAA,EACrE,OAAO,CAAC,aAAa,YAAY;AAAA,EACjC,MAAM,CAAC,eAAe,cAAc;AAAA,EACpC,KAAK,CAAC,WAAW,UAAU;AAAA,EAC3B,MAAM,CAAC,YAAY,WAAW;AAChC;AAGO,SAASC,EAAWC,GAAkC;AAC3D,QAAMC,IAAQD,EAAQ,MAAM,GAAG;AAC/B,MAAIC,EAAM,SAAS,EAAG,QAAO;AAC7B,QAAMC,IAAOD,EAAMA,EAAM,SAAS,CAAC;AACnC,MAAI,CAACC,EAAM,QAAO;AAClB,QAAMC,IAA2C,CAAA;AACjD,aAAWC,KAAQH,EAAM,MAAM,GAAG,EAAE,GAAG;AACrC,UAAMI,IAAOP,EAAUM,CAAI;AAC3B,QAAI,CAACC,EAAM,QAAO;AAClB,IAAAF,EAAU,KAAKE,CAAI;AAAA,EACrB;AACA,SAAO,EAAE,MAAAH,GAAM,WAAAC,EAAA;AACjB;AAGO,SAASG,EAAUC,GAAiBC,GAA0C;AACnF,MAAI,CAACA,EAAKD,EAAM,IAAI,EAAG,QAAO;AAC9B,aAAW,CAACE,GAAMC,CAAK,KAAKH,EAAM,UAAW,KAAI,CAACC,EAAKC,CAAI,KAAK,CAACD,EAAKE,CAAK,EAAG,QAAO;AACrF,SAAO;AACT;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
constructor(s = 480, i = 10) {
|
|
3
|
+
this.ms = s, this.slop = i;
|
|
4
|
+
}
|
|
5
|
+
ms;
|
|
6
|
+
slop;
|
|
7
|
+
finger = null;
|
|
8
|
+
done = !1;
|
|
9
|
+
down(s, i, n, t) {
|
|
10
|
+
if (this.finger) {
|
|
11
|
+
this.finger = null, this.done = !0;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.finger = { id: s, x: i, y: n, at: t }, this.done = !1;
|
|
15
|
+
}
|
|
16
|
+
move(s, i, n) {
|
|
17
|
+
const t = this.finger;
|
|
18
|
+
t && t.id === s && Math.hypot(i - t.x, n - t.y) > this.slop && (this.finger = null);
|
|
19
|
+
}
|
|
20
|
+
up(s) {
|
|
21
|
+
this.finger?.id === s && (this.finger = null), this.finger || (this.done = !1);
|
|
22
|
+
}
|
|
23
|
+
/** Where the press is, the first time this is asked at or after `ms`; null otherwise. */
|
|
24
|
+
fire(s) {
|
|
25
|
+
const i = this.finger;
|
|
26
|
+
return !i || this.done || s - i.at < this.ms ? null : (this.done = !0, { x: i.x, y: i.y });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
r as LongPress
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=longPress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longPress.js","sources":["../../src/input/longPress.ts"],"sourcesContent":["/**\n * A long press, as pure timing so it can be tested: a finger that stays down `ms` without moving more than `slop`\n * CSS px fires once, where it went down. A second finger, a move past the slop or a lift before the time is up is\n * not a long press — a tap stays a tap. The caller owns the clock (`fire(now)` from a timer or a frame).\n */\nexport class LongPress {\n private finger: { id: number; x: number; y: number; at: number } | null = null;\n private done = false;\n\n constructor(\n readonly ms = 480,\n readonly slop = 10,\n ) {}\n\n down(id: number, x: number, y: number, now: number): void {\n // a second finger means a pinch or the other thumb, never a press on one body\n if (this.finger) {\n this.finger = null;\n this.done = true;\n return;\n }\n this.finger = { id, x, y, at: now };\n this.done = false;\n }\n\n move(id: number, x: number, y: number): void {\n const f = this.finger;\n if (f && f.id === id && Math.hypot(x - f.x, y - f.y) > this.slop) this.finger = null;\n }\n\n up(id: number): void {\n if (this.finger?.id === id) this.finger = null;\n if (!this.finger) this.done = false;\n }\n\n /** Where the press is, the first time this is asked at or after `ms`; null otherwise. */\n fire(now: number): { x: number; y: number } | null {\n const f = this.finger;\n if (!f || this.done || now - f.at < this.ms) return null;\n this.done = true;\n return { x: f.x, y: f.y };\n }\n}\n"],"names":["LongPress","ms","slop","id","x","y","now","f"],"mappings":"AAKO,MAAMA,EAAU;AAAA,EAIrB,YACWC,IAAK,KACLC,IAAO,IAChB;AAFS,SAAA,KAAAD,GACA,KAAA,OAAAC;AAAA,EACR;AAAA,EAFQ;AAAA,EACA;AAAA,EALH,SAAkE;AAAA,EAClE,OAAO;AAAA,EAOf,KAAKC,GAAYC,GAAWC,GAAWC,GAAmB;AAExD,QAAI,KAAK,QAAQ;AACf,WAAK,SAAS,MACd,KAAK,OAAO;AACZ;AAAA,IACF;AACA,SAAK,SAAS,EAAE,IAAAH,GAAI,GAAAC,GAAG,GAAAC,GAAG,IAAIC,EAAA,GAC9B,KAAK,OAAO;AAAA,EACd;AAAA,EAEA,KAAKH,GAAYC,GAAWC,GAAiB;AAC3C,UAAME,IAAI,KAAK;AACf,IAAIA,KAAKA,EAAE,OAAOJ,KAAM,KAAK,MAAMC,IAAIG,EAAE,GAAGF,IAAIE,EAAE,CAAC,IAAI,KAAK,cAAW,SAAS;AAAA,EAClF;AAAA,EAEA,GAAGJ,GAAkB;AACnB,IAAI,KAAK,QAAQ,OAAOA,WAAS,SAAS,OACrC,KAAK,WAAQ,KAAK,OAAO;AAAA,EAChC;AAAA;AAAA,EAGA,KAAKG,GAA8C;AACjD,UAAMC,IAAI,KAAK;AACf,WAAI,CAACA,KAAK,KAAK,QAAQD,IAAMC,EAAE,KAAK,KAAK,KAAW,QACpD,KAAK,OAAO,IACL,EAAE,GAAGA,EAAE,GAAG,GAAGA,EAAE,EAAA;AAAA,EACxB;AACF;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const a = 0.28;
|
|
2
|
+
function h(t, n, r) {
|
|
3
|
+
if (r <= 0) return { x: 0, y: 0 };
|
|
4
|
+
const o = Math.hypot(t, n);
|
|
5
|
+
if (o === 0) return { x: 0, y: 0 };
|
|
6
|
+
const c = o > r ? 1 / o : 1 / r;
|
|
7
|
+
return { x: t * c, y: n * c };
|
|
8
|
+
}
|
|
9
|
+
function s(t, n = 0.28) {
|
|
10
|
+
return Math.hypot(t.x, t.y) >= n;
|
|
11
|
+
}
|
|
12
|
+
function i(t, n = 0.28) {
|
|
13
|
+
if (!s(t, n)) return { dx: 0, dy: 0 };
|
|
14
|
+
const o = Math.round(Math.atan2(t.y, t.x) / (Math.PI / 4)) * (Math.PI / 4), c = (e) => Math.abs(e) < 1e-9 ? 0 : Math.sign(e);
|
|
15
|
+
return { dx: c(Math.cos(o)), dy: c(Math.sin(o)) };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
a as STICK_DEAD_ZONE,
|
|
19
|
+
s as stickActive,
|
|
20
|
+
i as stickToAxis,
|
|
21
|
+
h as stickVector
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=stickAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stickAxis.js","sources":["../../src/input/stickAxis.ts"],"sourcesContent":["/**\n * The virtual joystick's arithmetic, kept pure so it can be tested. The stick hands the game the **same** axis\n * the keyboard does — `stepMover` clamps every step to -1/0/1 on each axis (movement is eight-way, and the server\n * reads it the same way), so an analog stick would only be rounded there anyway. The rounding happens here instead,\n * by eight 45° sectors, so a thumb held a little off the horizontal walks straight rather than flickering between\n * east and north-east.\n */\n\n/** Below this share of the stick's radius the thumb is resting: no movement, and the aim falls back (touchAim.ts). */\nexport const STICK_DEAD_ZONE = 0.28;\n\nexport interface StickVector {\n x: number;\n y: number;\n}\n\n/** The thumb's offset from where the stick was planted, as a vector of length at most 1 (radius = full tilt). */\nexport function stickVector(dx: number, dy: number, radius: number): StickVector {\n if (radius <= 0) return { x: 0, y: 0 };\n const len = Math.hypot(dx, dy);\n if (len === 0) return { x: 0, y: 0 };\n const k = len > radius ? 1 / len : 1 / radius;\n return { x: dx * k, y: dy * k };\n}\n\n/** True when the stick is tilted past the dead zone. */\nexport function stickActive(v: StickVector, deadZone = STICK_DEAD_ZONE): boolean {\n return Math.hypot(v.x, v.y) >= deadZone;\n}\n\n/**\n * The keyboard-shaped axis for a stick vector: each of dx, dy is -1, 0 or 1 (screen y grows downward, as the\n * keyboard's \"down\" does), nothing inside the dead zone, and the nearest of the eight directions otherwise.\n */\nexport function stickToAxis(v: StickVector, deadZone = STICK_DEAD_ZONE): { dx: number; dy: number } {\n if (!stickActive(v, deadZone)) return { dx: 0, dy: 0 };\n const sector = Math.round(Math.atan2(v.y, v.x) / (Math.PI / 4));\n const angle = sector * (Math.PI / 4);\n const round = (n: number) => (Math.abs(n) < 1e-9 ? 0 : Math.sign(n));\n return { dx: round(Math.cos(angle)), dy: round(Math.sin(angle)) };\n}\n"],"names":["STICK_DEAD_ZONE","stickVector","dx","dy","radius","len","k","stickActive","v","deadZone","stickToAxis","angle","round","n"],"mappings":"AASO,MAAMA,IAAkB;AAQxB,SAASC,EAAYC,GAAYC,GAAYC,GAA6B;AAC/E,MAAIA,KAAU,EAAG,QAAO,EAAE,GAAG,GAAG,GAAG,EAAA;AACnC,QAAMC,IAAM,KAAK,MAAMH,GAAIC,CAAE;AAC7B,MAAIE,MAAQ,EAAG,QAAO,EAAE,GAAG,GAAG,GAAG,EAAA;AACjC,QAAMC,IAAID,IAAMD,IAAS,IAAIC,IAAM,IAAID;AACvC,SAAO,EAAE,GAAGF,IAAKI,GAAG,GAAGH,IAAKG,EAAA;AAC9B;AAGO,SAASC,EAAYC,GAAgBC,IAAW,MAA0B;AAC/E,SAAO,KAAK,MAAMD,EAAE,GAAGA,EAAE,CAAC,KAAKC;AACjC;AAMO,SAASC,EAAYF,GAAgBC,IAAW,MAA6C;AAClG,MAAI,CAACF,EAAYC,GAAGC,CAAQ,UAAU,EAAE,IAAI,GAAG,IAAI,EAAA;AAEnD,QAAME,IADS,KAAK,MAAM,KAAK,MAAMH,EAAE,GAAGA,EAAE,CAAC,KAAK,KAAK,KAAK,EAAE,KACtC,KAAK,KAAK,IAC5BI,IAAQ,CAACC,MAAe,KAAK,IAAIA,CAAC,IAAI,OAAO,IAAI,KAAK,KAAKA,CAAC;AAClE,SAAO,EAAE,IAAID,EAAM,KAAK,IAAID,CAAK,CAAC,GAAG,IAAIC,EAAM,KAAK,IAAID,CAAK,CAAC,EAAA;AAChE;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touchDetect.js","sources":["../../src/input/touchDetect.ts"],"sourcesContent":["/** What decides whether the touch controls are shown; read off the browser by `isTouchUi` (`platform/touch.ts`). */\nexport interface TouchEnv {\n /** Running inside a native shell (`setNativeShell`: Capacitor, a kiosk…). */\n native: boolean;\n /** `(pointer: coarse)` matches: the **primary** pointer is a finger. */\n coarse: boolean;\n /** `navigator.maxTouchPoints`. */\n touchPoints: number;\n /** `?touch=1|0` in the URL or `localStorage` (`setTouchOverrideKey`), for trying the controls on a desktop browser. */\n override: string | null;\n}\n\n/**\n * Touch controls only where a finger is the main way in: the native app always, a browser whose primary pointer\n * is coarse and that reports touch points (a phone or tablet), never a desktop — a laptop with a touch screen\n * still has a fine primary pointer and keeps its mouse and keyboard.\n */\nexport function detectTouch(env: TouchEnv): boolean {\n if (env.override === '1' || env.override === 'on') return true;\n if (env.override === '0' || env.override === 'off') return false;\n if (env.native) return true;\n return env.coarse && env.touchPoints > 0;\n}\n"],"names":["detectTouch","env"],"mappings":"AAiBO,SAASA,EAAYC,GAAwB;AAClD,SAAIA,EAAI,aAAa,OAAOA,EAAI,aAAa,OAAa,KACtDA,EAAI,aAAa,OAAOA,EAAI,aAAa,QAAc,KACvDA,EAAI,SAAe,KAChBA,EAAI,UAAUA,EAAI,cAAc;AACzC;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { RenderTexture as M, Sprite as c, Container as w, Texture as f } from "pixi.js";
|
|
2
|
+
let o = null;
|
|
3
|
+
function m() {
|
|
4
|
+
if (o) return o;
|
|
5
|
+
const h = 256, t = document.createElement("canvas");
|
|
6
|
+
t.width = t.height = h;
|
|
7
|
+
const s = t.getContext("2d");
|
|
8
|
+
if (!s) return f.EMPTY;
|
|
9
|
+
const e = s.createRadialGradient(h / 2, h / 2, 0, h / 2, h / 2, h / 2);
|
|
10
|
+
return e.addColorStop(0, "rgba(255,255,255,1)"), e.addColorStop(0.35, "rgba(255,255,255,0.75)"), e.addColorStop(0.7, "rgba(255,255,255,0.25)"), e.addColorStop(1, "rgba(255,255,255,0)"), s.fillStyle = e, s.fillRect(0, 0, h, h), o = f.from(t), o.source.scaleMode = "linear", o;
|
|
11
|
+
}
|
|
12
|
+
class x {
|
|
13
|
+
constructor(t, s = {}) {
|
|
14
|
+
this.stage = t, this.ambient = s.ambient ?? 658468, this.darkness = s.darkness ?? 0.85, this.tint = s.tint ?? 0.35, this.squash = s.squash ?? 1, this.scratch.addChild(this.sheet, this.holes), this.rt = M.create({ width: 1, height: 1 }), this.view = new c(this.rt), this.washes.blendMode = "add", t.screen.addChild(this.view, this.washes), this.unsubscribe = t.onResize(() => this.fit()), this.fit();
|
|
15
|
+
}
|
|
16
|
+
stage;
|
|
17
|
+
lights = /* @__PURE__ */ new Set();
|
|
18
|
+
scratch = new w();
|
|
19
|
+
sheet = new c(f.WHITE);
|
|
20
|
+
holes = new w();
|
|
21
|
+
washes = new w();
|
|
22
|
+
view;
|
|
23
|
+
rt;
|
|
24
|
+
pool = [];
|
|
25
|
+
ambient;
|
|
26
|
+
darkness;
|
|
27
|
+
tint;
|
|
28
|
+
squash;
|
|
29
|
+
unsubscribe;
|
|
30
|
+
add(t) {
|
|
31
|
+
return this.lights.add(t), t;
|
|
32
|
+
}
|
|
33
|
+
remove(t) {
|
|
34
|
+
this.lights.delete(t);
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.lights.clear();
|
|
38
|
+
}
|
|
39
|
+
/** Changes the dark: its colour and how dark (a day/night cycle eases these). */
|
|
40
|
+
setAmbient(t, s) {
|
|
41
|
+
this.ambient = t, this.darkness = Math.min(1, Math.max(0, s));
|
|
42
|
+
}
|
|
43
|
+
/** Redraws the dark with this frame's lights. Call once a frame, after the camera moved. */
|
|
44
|
+
update(t = performance.now()) {
|
|
45
|
+
const s = this.darkness > 4e-3;
|
|
46
|
+
if (this.view.visible = s, this.washes.visible = s, !s) return;
|
|
47
|
+
const e = this.stage.cameras.main, a = e.zoom;
|
|
48
|
+
this.sheet.tint = this.ambient, this.sheet.alpha = this.darkness;
|
|
49
|
+
let b = 0;
|
|
50
|
+
for (const i of this.lights) {
|
|
51
|
+
if (i.on === !1 || i.radius <= 0) continue;
|
|
52
|
+
const d = (i.x - e.scrollX) * a, u = (i.y - e.scrollY) * a, p = i.flicker ? 1 + Math.sin(t / 97 + i.x) * Math.sin(t / 53 + i.y) * i.flicker : 1, r = i.radius * a * p;
|
|
53
|
+
if (d < -r || u < -r || d > e.width + r || u > e.height + r) continue;
|
|
54
|
+
const n = this.sprites(b++), g = Math.min(1, Math.max(0, i.intensity ?? 1));
|
|
55
|
+
for (const l of [n.hole, n.wash])
|
|
56
|
+
l.visible = !0, l.position.set(d, u), l.width = r * 2, l.height = r * 2 * this.squash;
|
|
57
|
+
n.hole.alpha = g, n.wash.tint = i.color ?? 16773340, n.wash.alpha = g * this.tint;
|
|
58
|
+
}
|
|
59
|
+
for (let i = b; i < this.pool.length; i++)
|
|
60
|
+
this.pool[i].hole.visible = !1, this.pool[i].wash.visible = !1;
|
|
61
|
+
this.stage.app.renderer.render({ container: this.scratch, target: this.rt, clear: !0 });
|
|
62
|
+
}
|
|
63
|
+
destroy() {
|
|
64
|
+
this.unsubscribe(), this.view.destroy(), this.washes.destroy({ children: !0 }), this.scratch.destroy({ children: !0 }), this.rt.destroy(!0), this.lights.clear();
|
|
65
|
+
}
|
|
66
|
+
sprites(t) {
|
|
67
|
+
let s = this.pool[t];
|
|
68
|
+
if (!s) {
|
|
69
|
+
const e = new c(m());
|
|
70
|
+
e.anchor.set(0.5), e.blendMode = "erase";
|
|
71
|
+
const a = new c(m());
|
|
72
|
+
a.anchor.set(0.5), this.holes.addChild(e), this.washes.addChild(a), s = { hole: e, wash: a }, this.pool.push(s);
|
|
73
|
+
}
|
|
74
|
+
return s;
|
|
75
|
+
}
|
|
76
|
+
fit() {
|
|
77
|
+
const t = Math.max(1, Math.ceil(this.stage.width)), s = Math.max(1, Math.ceil(this.stage.height));
|
|
78
|
+
this.rt.resize(t, s), this.sheet.width = t, this.sheet.height = s;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
x as LightLayer
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=LightLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightLayer.js","sources":["../../src/light/LightLayer.ts"],"sourcesContent":["import { Container, RenderTexture, Sprite, Texture } from 'pixi.js';\nimport type { Stage } from '../core/Stage';\n\n/** A light in the world. Change its fields any time (follow a body by writing `x`/`y` each frame). */\nexport interface Light {\n x: number;\n y: number;\n /** World px. */\n radius: number;\n /** The colour it casts on what it lights (default warm white). */\n color?: number;\n /** 0–1: how much of the dark it takes away, and how strong its colour (default 1). */\n intensity?: number;\n /** Radius wobble, 0–1 (a torch ≈ 0.08). */\n flicker?: number;\n /** A light off is kept but not drawn. */\n on?: boolean;\n}\n\nexport interface LightLayerOptions {\n /** Colour of the dark (default deep blue). */\n ambient?: number;\n /** 0 no dark at all, 1 black where nothing is lit (default 0.85). */\n darkness?: number;\n /** How strongly lights tint what they light, 0–1 (default 0.35). */\n tint?: number;\n /** A light's height over its width: the ground is seen at a slant (default 1, round; a 3/4 view ≈ 0.85). */\n squash?: number;\n}\n\nlet gradient: Texture | null = null;\n\n/** One soft radial falloff, white with alpha, shared by every light. */\nfunction falloff(): Texture {\n if (gradient) return gradient;\n const size = 256;\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = size;\n const ctx = canvas.getContext('2d');\n if (!ctx) return Texture.EMPTY;\n const g = ctx.createRadialGradient(size / 2, size / 2, 0, size / 2, size / 2, size / 2);\n // a bright core and a long, eased tail: reads as light, not as a disc\n g.addColorStop(0, 'rgba(255,255,255,1)');\n g.addColorStop(0.35, 'rgba(255,255,255,0.75)');\n g.addColorStop(0.7, 'rgba(255,255,255,0.25)');\n g.addColorStop(1, 'rgba(255,255,255,0)');\n ctx.fillStyle = g;\n ctx.fillRect(0, 0, size, size);\n gradient = Texture.from(canvas);\n gradient.source.scaleMode = 'linear';\n return gradient;\n}\n\n/**\n * Smooth darkness with lights cut out of it, for art that is not pixel art (the pixel module has its own dithered\n * `Darkness`). The dark is a screen-sized texture: each light erases a soft hole in it, and lays its colour over what\n * shows through. It sits on the screen layer, over the world and under the HUD you add after it.\n *\n * ```ts\n * const night = new LightLayer(stage, { darkness: 0.9 });\n * const torch = night.add({ x: 100, y: 80, radius: 90, color: 0xffb060, flicker: 0.08 });\n * // each frame: torch.x = hero.x; night.update(now);\n * ```\n */\nexport class LightLayer {\n private readonly lights = new Set<Light>();\n private readonly scratch = new Container();\n private readonly sheet = new Sprite(Texture.WHITE);\n private readonly holes = new Container();\n private readonly washes = new Container();\n private readonly view: Sprite;\n private rt: RenderTexture;\n private readonly pool: { hole: Sprite; wash: Sprite }[] = [];\n private ambient: number;\n private darkness: number;\n private readonly tint: number;\n private readonly squash: number;\n private readonly unsubscribe: () => void;\n\n constructor(\n private readonly stage: Stage,\n options: LightLayerOptions = {},\n ) {\n this.ambient = options.ambient ?? 0x0a0c24;\n this.darkness = options.darkness ?? 0.85;\n this.tint = options.tint ?? 0.35;\n this.squash = options.squash ?? 1;\n this.scratch.addChild(this.sheet, this.holes);\n this.rt = RenderTexture.create({ width: 1, height: 1 });\n this.view = new Sprite(this.rt);\n // the colour washes sit over the dark, added to what they light\n this.washes.blendMode = 'add';\n stage.screen.addChild(this.view, this.washes);\n this.unsubscribe = stage.onResize(() => this.fit());\n this.fit();\n }\n\n add(light: Light): Light {\n this.lights.add(light);\n return light;\n }\n\n remove(light: Light): void {\n this.lights.delete(light);\n }\n\n clear(): void {\n this.lights.clear();\n }\n\n /** Changes the dark: its colour and how dark (a day/night cycle eases these). */\n setAmbient(color: number, darkness: number): void {\n this.ambient = color;\n this.darkness = Math.min(1, Math.max(0, darkness));\n }\n\n /** Redraws the dark with this frame's lights. Call once a frame, after the camera moved. */\n update(now = performance.now()): void {\n const on = this.darkness > 0.004;\n this.view.visible = on;\n this.washes.visible = on;\n if (!on) return;\n const cam = this.stage.cameras.main;\n const z = cam.zoom;\n this.sheet.tint = this.ambient;\n this.sheet.alpha = this.darkness;\n let used = 0;\n for (const l of this.lights) {\n if (l.on === false || l.radius <= 0) continue;\n const sx = (l.x - cam.scrollX) * z;\n const sy = (l.y - cam.scrollY) * z;\n const wobble = l.flicker ? 1 + Math.sin(now / 97 + l.x) * Math.sin(now / 53 + l.y) * l.flicker : 1;\n const r = l.radius * z * wobble;\n // off screen by more than its radius: nothing of it shows\n if (sx < -r || sy < -r || sx > cam.width + r || sy > cam.height + r) continue;\n const s = this.sprites(used++);\n const intensity = Math.min(1, Math.max(0, l.intensity ?? 1));\n for (const sprite of [s.hole, s.wash]) {\n sprite.visible = true;\n sprite.position.set(sx, sy);\n sprite.width = r * 2;\n sprite.height = r * 2 * this.squash;\n }\n s.hole.alpha = intensity;\n s.wash.tint = l.color ?? 0xfff0dc;\n s.wash.alpha = intensity * this.tint;\n }\n for (let i = used; i < this.pool.length; i++) {\n this.pool[i]!.hole.visible = false;\n this.pool[i]!.wash.visible = false;\n }\n this.stage.app.renderer.render({ container: this.scratch, target: this.rt, clear: true });\n }\n\n destroy(): void {\n this.unsubscribe();\n this.view.destroy();\n this.washes.destroy({ children: true });\n this.scratch.destroy({ children: true });\n this.rt.destroy(true);\n this.lights.clear();\n }\n\n private sprites(i: number): { hole: Sprite; wash: Sprite } {\n let s = this.pool[i];\n if (!s) {\n const hole = new Sprite(falloff());\n hole.anchor.set(0.5);\n hole.blendMode = 'erase';\n const wash = new Sprite(falloff());\n wash.anchor.set(0.5);\n this.holes.addChild(hole);\n this.washes.addChild(wash);\n s = { hole, wash };\n this.pool.push(s);\n }\n return s;\n }\n\n private fit(): void {\n const w = Math.max(1, Math.ceil(this.stage.width));\n const h = Math.max(1, Math.ceil(this.stage.height));\n this.rt.resize(w, h);\n this.sheet.width = w;\n this.sheet.height = h;\n }\n}\n"],"names":["gradient","falloff","size","canvas","ctx","Texture","g","LightLayer","stage","options","RenderTexture","Sprite","Container","light","color","darkness","now","on","cam","z","used","l","sx","sy","wobble","s","intensity","sprite","i","hole","wash","w","h"],"mappings":";AA8BA,IAAIA,IAA2B;AAG/B,SAASC,IAAmB;AAC1B,MAAID,EAAU,QAAOA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,CAAC;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AAAA,EAEQ,MAAY;AAClB,UAAMC,IAAI,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,MAAM,KAAK,CAAC,GAC3CC,IAAI,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,MAAM,MAAM,CAAC;AAClD,SAAK,GAAG,OAAOD,GAAGC,CAAC,GACnB,KAAK,MAAM,QAAQD,GACnB,KAAK,MAAM,SAASC;AAAA,EACtB;AACF;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class c {
|
|
2
|
+
items = [];
|
|
3
|
+
prio = [];
|
|
4
|
+
get size() {
|
|
5
|
+
return this.items.length;
|
|
6
|
+
}
|
|
7
|
+
push(s, e) {
|
|
8
|
+
const h = this.items, o = this.prio;
|
|
9
|
+
h.push(s), o.push(e);
|
|
10
|
+
let i = h.length - 1;
|
|
11
|
+
for (; i > 0; ) {
|
|
12
|
+
const t = i - 1 >> 1;
|
|
13
|
+
if (o[t] <= o[i]) break;
|
|
14
|
+
[h[t], h[i]] = [h[i], h[t]], [o[t], o[i]] = [o[i], o[t]], i = t;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** The index with the lowest priority, removed. Only call while `size > 0`. */
|
|
18
|
+
pop() {
|
|
19
|
+
const s = this.items, e = this.prio, h = s[0], o = s.pop(), i = e.pop();
|
|
20
|
+
if (s.length > 0) {
|
|
21
|
+
s[0] = o, e[0] = i;
|
|
22
|
+
let t = 0;
|
|
23
|
+
for (; ; ) {
|
|
24
|
+
const p = t * 2 + 1, l = p + 1;
|
|
25
|
+
let n = t;
|
|
26
|
+
if (p < s.length && e[p] < e[n] && (n = p), l < s.length && e[l] < e[n] && (n = l), n === t) break;
|
|
27
|
+
[s[t], s[n]] = [s[n], s[t]], [e[t], e[n]] = [e[n], e[t]], t = n;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return h;
|
|
31
|
+
}
|
|
32
|
+
clear() {
|
|
33
|
+
this.items.length = 0, this.prio.length = 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
c as MinHeap
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=MinHeap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinHeap.js","sources":["../../src/nav/MinHeap.ts"],"sourcesContent":["/**\n * A binary min-heap of (index, priority) pairs, kept as two parallel arrays so a search over a big grid pushes\n * numbers, not objects. A stale entry (pushed again at a lower priority) is left in and skipped by the caller's\n * closed set, which is cheaper than a decrease-key.\n */\nexport class MinHeap {\n private items: number[] = [];\n private prio: number[] = [];\n\n get size(): number {\n return this.items.length;\n }\n\n push(index: number, priority: number): void {\n const a = this.items;\n const p = this.prio;\n a.push(index);\n p.push(priority);\n let c = a.length - 1;\n while (c > 0) {\n const u = (c - 1) >> 1;\n if (p[u]! <= p[c]!) break;\n [a[u], a[c]] = [a[c]!, a[u]!];\n [p[u], p[c]] = [p[c]!, p[u]!];\n c = u;\n }\n }\n\n /** The index with the lowest priority, removed. Only call while `size > 0`. */\n pop(): number {\n const a = this.items;\n const p = this.prio;\n const top = a[0]!;\n const lastI = a.pop()!;\n const lastF = p.pop()!;\n if (a.length > 0) {\n a[0] = lastI;\n p[0] = lastF;\n let u = 0;\n for (;;) {\n const l = u * 2 + 1;\n const r = l + 1;\n let s = u;\n if (l < a.length && p[l]! < p[s]!) s = l;\n if (r < a.length && p[r]! < p[s]!) s = r;\n if (s === u) break;\n [a[u], a[s]] = [a[s]!, a[u]!];\n [p[u], p[s]] = [p[s]!, p[u]!];\n u = s;\n }\n }\n return top;\n }\n\n clear(): void {\n this.items.length = 0;\n this.prio.length = 0;\n }\n}\n"],"names":["MinHeap","index","priority","a","p","c","u","top","lastI","lastF","l","r","s"],"mappings":"AAKO,MAAMA,EAAQ;AAAA,EACX,QAAkB,CAAA;AAAA,EAClB,OAAiB,CAAA;AAAA,EAEzB,IAAI,OAAe;AACjB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AEQ,CAAC,GAAIR,EAAEE,CAAC,CAAE,GAC5BA,IAAIM;AAAA,MACN;AAAA,IACF;AACA,WAAOL;AAAA,EACT;AAAA,EAEA,QAAc;AACZ,SAAK,MAAM,SAAS,GACpB,KAAK,KAAK,SAAS;AAAA,EACrB;AACF;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { MinHeap as z } from "./MinHeap.js";
|
|
2
|
+
import { isOpen as C, NAV_STEPS as N, canStep as P } from "./navGrid.js";
|
|
3
|
+
import { nearestOpen as T } from "./nearestOpen.js";
|
|
4
|
+
function U(t, n) {
|
|
5
|
+
const e = Math.abs(t), c = Math.abs(n);
|
|
6
|
+
return e + c + (Math.SQRT2 - 2) * Math.min(e, c);
|
|
7
|
+
}
|
|
8
|
+
function W(t) {
|
|
9
|
+
if ("test" in t) return { test: t.test, estimate: t.estimate ?? (() => 0) };
|
|
10
|
+
const n = t.reach ?? 0;
|
|
11
|
+
return {
|
|
12
|
+
test: (e, c) => Math.hypot(e - t.x, c - t.y) <= n + 1e-9,
|
|
13
|
+
// less the goal's own radius: never more than the real remaining cost
|
|
14
|
+
estimate: (e, c) => Math.max(0, U(t.x - e, t.y - c) - n)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function Q(t, n, e, c = {}) {
|
|
18
|
+
const { cost: f, endOnly: S, maxNodes: w = 14e3 } = c, s = C(t, n.x, n.y) ? n : T(t, n.x, n.y);
|
|
19
|
+
if (!s) return null;
|
|
20
|
+
const i = W(e);
|
|
21
|
+
if (i.test(s.x, s.y)) return [{ x: s.x, y: s.y }];
|
|
22
|
+
const r = t.width, m = r * t.height, y = new Float64Array(m).fill(1 / 0), M = new Int32Array(m).fill(-1), I = new Uint8Array(m), u = new z(), h = s.y * r + s.x;
|
|
23
|
+
y[h] = 0, u.push(h, i.estimate(s.x, s.y));
|
|
24
|
+
let x = 0;
|
|
25
|
+
for (; u.size > 0 && x < w; ) {
|
|
26
|
+
const o = u.pop();
|
|
27
|
+
if (I[o]) continue;
|
|
28
|
+
I[o] = 1, x++;
|
|
29
|
+
const l = o % r, O = o / r | 0;
|
|
30
|
+
if (i.test(l, O)) {
|
|
31
|
+
const p = [];
|
|
32
|
+
for (let a = o; a !== -1; a = M[a]) p.push({ x: a % r, y: a / r | 0 });
|
|
33
|
+
return p.reverse();
|
|
34
|
+
}
|
|
35
|
+
for (const [p, a, A] of N) {
|
|
36
|
+
if (!P(t, l, O, p, a, S, i.test)) continue;
|
|
37
|
+
const d = l + p, b = O + a, F = b * r + d;
|
|
38
|
+
if (I[F]) continue;
|
|
39
|
+
const v = y[o] + A + (f ? f(d, b) : 0);
|
|
40
|
+
v >= y[F] || (y[F] = v, M[F] = o, u.push(F, v + i.estimate(d, b)));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function R(t, n, e = {}) {
|
|
46
|
+
const { cost: c, endOnly: f, maxCost: S = 1 / 0 } = e, w = t.width, s = w * t.height, i = new Float32Array(s).fill(1 / 0), r = C(t, n.x, n.y) ? n : T(t, n.x, n.y);
|
|
47
|
+
if (!r) return i;
|
|
48
|
+
const m = new Uint8Array(s), y = new z(), M = r.y * w + r.x;
|
|
49
|
+
i[M] = 0, y.push(M, 0);
|
|
50
|
+
const I = () => !0;
|
|
51
|
+
for (; y.size > 0; ) {
|
|
52
|
+
const u = y.pop();
|
|
53
|
+
if (m[u]) continue;
|
|
54
|
+
m[u] = 1;
|
|
55
|
+
const h = u % w, x = u / w | 0;
|
|
56
|
+
if (!(u !== M && f?.(h, x)))
|
|
57
|
+
for (const [o, l, O] of N) {
|
|
58
|
+
if (!P(t, h, x, o, l, f, I) || f && o !== 0 && l !== 0 && (f(h + o, x) || f(h, x + l))) continue;
|
|
59
|
+
const p = h + o, a = x + l, A = a * w + p;
|
|
60
|
+
if (m[A]) continue;
|
|
61
|
+
const d = i[u] + O + (c ? c(p, a) : 0);
|
|
62
|
+
d >= i[A] || d > S || (i[A] = d, y.push(A, d));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return i;
|
|
66
|
+
}
|
|
67
|
+
function V(t) {
|
|
68
|
+
let n = 0;
|
|
69
|
+
for (let e = 0; e < t.length; e++) t[e] !== 1 / 0 && n++;
|
|
70
|
+
return n;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
Q as findPath,
|
|
74
|
+
R as floodFill,
|
|
75
|
+
U as octile,
|
|
76
|
+
V as reachedCount
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=findPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPath.js","sources":["../../src/nav/findPath.ts"],"sourcesContent":["import { MinHeap } from './MinHeap';\nimport { canStep, isOpen, NAV_STEPS, type NavGrid, type NavOptions, type TilePoint } from './navGrid';\nimport { nearestOpen } from './nearestOpen';\n\n/**\n * Where a path ends. A point goal is met anywhere within `reach` tiles of its tile (centre to centre; 0 = that tile\n * only): aiming at an exact tile sent auto-walks into a spot inside a hut and left them shuffling against its wall a\n * step from where they were already close enough. A custom goal names its own tiles, with an `estimate` of the\n * tiles left that must never be more than the real cost (0, the default, makes the search a plain Dijkstra).\n */\nexport type NavGoal = { x: number; y: number; reach?: number } | { test: (tx: number, ty: number) => boolean; estimate?: (tx: number, ty: number) => number };\n\nexport interface FindPathOptions extends NavOptions {\n /** Tiles settled before giving up, so a goal walled off on a big map cannot stall a frame. */\n maxNodes?: number;\n}\n\n/** Octile distance: the cost of the cheapest eight-way walk over open ground. */\nexport function octile(dx: number, dy: number): number {\n const ax = Math.abs(dx);\n const ay = Math.abs(dy);\n return ax + ay + (Math.SQRT2 - 2) * Math.min(ax, ay);\n}\n\nfunction goalOf(goal: NavGoal): { test: (x: number, y: number) => boolean; estimate: (x: number, y: number) => number } {\n if ('test' in goal) return { test: goal.test, estimate: goal.estimate ?? (() => 0) };\n const r = goal.reach ?? 0;\n return {\n test: (x, y) => Math.hypot(x - goal.x, y - goal.y) <= r + 1e-9,\n // less the goal's own radius: never more than the real remaining cost\n estimate: (x, y) => Math.max(0, octile(goal.x - x, goal.y - y) - r),\n };\n}\n\n/**\n * A* over the grid: the tiles from `from` to the goal, both included, or null when there is no way through. A start\n * on a wall is moved to the nearest open tile. The path is the cheapest by `cost`, but among equally cheap ones it\n * is whichever the heap settled on — often a staircase; `straightenPath` irons that out.\n */\nexport function findPath(g: NavGrid, from: TilePoint, to: NavGoal, options: FindPathOptions = {}): TilePoint[] | null {\n const { cost, endOnly, maxNodes = 14_000 } = options;\n const start = isOpen(g, from.x, from.y) ? from : nearestOpen(g, from.x, from.y);\n if (!start) return null;\n const goal = goalOf(to);\n if (goal.test(start.x, start.y)) return [{ x: start.x, y: start.y }];\n\n const W = g.width;\n const n = W * g.height;\n const best = new Float64Array(n).fill(Infinity);\n const cameFrom = new Int32Array(n).fill(-1);\n const closed = new Uint8Array(n);\n const heap = new MinHeap();\n const s = start.y * W + start.x;\n best[s] = 0;\n heap.push(s, goal.estimate(start.x, start.y));\n let visited = 0;\n while (heap.size > 0 && visited < maxNodes) {\n const i = heap.pop();\n if (closed[i]) continue;\n closed[i] = 1;\n visited++;\n const cx = i % W;\n const cy = (i / W) | 0;\n if (goal.test(cx, cy)) {\n const out: TilePoint[] = [];\n for (let k = i; k !== -1; k = cameFrom[k]!) out.push({ x: k % W, y: (k / W) | 0 });\n return out.reverse();\n }\n for (const [dx, dy, step] of NAV_STEPS) {\n if (!canStep(g, cx, cy, dx, dy, endOnly, goal.test)) continue;\n const nx = cx + dx;\n const ny = cy + dy;\n const ni = ny * W + nx;\n if (closed[ni]) continue;\n const tentative = best[i]! + step + (cost ? cost(nx, ny) : 0);\n if (tentative >= best[ni]!) continue;\n best[ni] = tentative;\n cameFrom[ni] = i;\n heap.push(ni, tentative + goal.estimate(nx, ny));\n }\n }\n return null;\n}\n\n/**\n * Walking cost from one tile to every tile of the grid (row-major, `Infinity` where unreachable), by the same steps\n * and costs `findPath` takes — for weighing several destinations by real distance rather than by a straight line. An\n * end-only tile gets a cost (it can be stepped onto) but nothing is reached through it. `maxCost` stops the spread.\n */\nexport function floodFill(g: NavGrid, from: TilePoint, options: NavOptions & { maxCost?: number } = {}): Float32Array {\n const { cost, endOnly, maxCost = Infinity } = options;\n const W = g.width;\n const n = W * g.height;\n const out = new Float32Array(n).fill(Infinity);\n const start = isOpen(g, from.x, from.y) ? from : nearestOpen(g, from.x, from.y);\n if (!start) return out;\n const closed = new Uint8Array(n);\n const heap = new MinHeap();\n const s = start.y * W + start.x;\n out[s] = 0;\n heap.push(s, 0);\n // every end-only tile counts as a goal here, so it is reached; the check below keeps it from being passed through\n const always = () => true;\n while (heap.size > 0) {\n const i = heap.pop();\n if (closed[i]) continue;\n closed[i] = 1;\n const cx = i % W;\n const cy = (i / W) | 0;\n if (i !== s && endOnly?.(cx, cy)) continue;\n for (const [dx, dy, step] of NAV_STEPS) {\n if (!canStep(g, cx, cy, dx, dy, endOnly, always)) continue;\n // a diagonal may still not brush past an end-only tile\n if (endOnly && dx !== 0 && dy !== 0 && (endOnly(cx + dx, cy) || endOnly(cx, cy + dy))) continue;\n const nx = cx + dx;\n const ny = cy + dy;\n const ni = ny * W + nx;\n if (closed[ni]) continue;\n const c = out[i]! + step + (cost ? cost(nx, ny) : 0);\n if (c >= out[ni]! || c > maxCost) continue;\n out[ni] = c;\n heap.push(ni, c);\n }\n }\n return out;\n}\n\n/** How many tiles a flood reached: a quick test that a change to the ground walled nothing off. */\nexport function reachedCount(costs: Float32Array): number {\n let n = 0;\n for (let i = 0; i < costs.length; i++) if (costs[i] !== Infinity) n++;\n return n;\n}\n"],"names":["octile","dx","dy","ax","ay","goalOf","goal","r","x","y","findPath","g","from","to","options","cost","endOnly","maxNodes","start","isOpen","nearestOpen","W","n","best","cameFrom","closed","heap","MinHeap","s","visited","i","cx","cy","out","k","step","NAV_STEPS","canStep","nx","ny","ni","tentative","floodFill","maxCost","always","c","reachedCount","costs"],"mappings":";;;AAkBO,SAASA,EAAO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,EAAK,KAAKc,GAAIK,CAAC;AAAA,MACjB;AAAA,EACF;AACA,SAAOZ;AACT;AAGO,SAASa,EAAaC,GAA6B;AACxD,MAAI,IAAI;AACR,WAASjB,IAAI,GAAGA,IAAIiB,EAAM,QAAQjB,IAAK,CAAIiB,EAAMjB,CAAC,MAAM,SAAU;AAClE,SAAO;AACT;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isSolidTile as s } from "../net/movement.js";
|
|
2
|
+
function S(r, n, t) {
|
|
3
|
+
return { width: r, height: n, walkable: t };
|
|
4
|
+
}
|
|
5
|
+
function T(r) {
|
|
6
|
+
return { width: r.width, height: r.height, walkable: (n, t) => !s(r, n, t) };
|
|
7
|
+
}
|
|
8
|
+
function e(r, n, t) {
|
|
9
|
+
return n >= 0 && t >= 0 && n < r.width && t < r.height && r.walkable(n, t);
|
|
10
|
+
}
|
|
11
|
+
function w(r, n = 1.4) {
|
|
12
|
+
return (t, i) => !e(r, t + 1, i) || !e(r, t - 1, i) || !e(r, t, i + 1) || !e(r, t, i - 1) ? n : 0;
|
|
13
|
+
}
|
|
14
|
+
const p = [
|
|
15
|
+
[1, 0, 1],
|
|
16
|
+
[-1, 0, 1],
|
|
17
|
+
[0, 1, 1],
|
|
18
|
+
[0, -1, 1],
|
|
19
|
+
[1, 1, Math.SQRT2],
|
|
20
|
+
[1, -1, Math.SQRT2],
|
|
21
|
+
[-1, 1, Math.SQRT2],
|
|
22
|
+
[-1, -1, Math.SQRT2]
|
|
23
|
+
];
|
|
24
|
+
function M(r, n, t, i, a, f, u) {
|
|
25
|
+
const o = n + i, h = t + a;
|
|
26
|
+
return !(!e(r, o, h) || f && f(o, h) && !u(o, h) || i !== 0 && a !== 0 && (!e(r, n + i, t) || !e(r, n, t + a) || f && (f(n + i, t) && !u(n + i, t) || f(n, t + a) && !u(n, t + a))));
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
p as NAV_STEPS,
|
|
30
|
+
M as canStep,
|
|
31
|
+
e as isOpen,
|
|
32
|
+
S as navGrid,
|
|
33
|
+
T as navGridFromCollision,
|
|
34
|
+
w as nearWallCost
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=navGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navGrid.js","sources":["../../src/nav/navGrid.ts"],"sourcesContent":["import { isSolidTile, type CollisionGrid } from '../net/movement';\n\n/** A tile coordinate. */\nexport interface TilePoint {\n x: number;\n y: number;\n}\n\n/**\n * The ground a search walks: a width, a height and whether a body may stand on a tile. `walkable` is never asked\n * about a tile outside the grid, so a game's own test needs no bounds check.\n */\nexport interface NavGrid {\n readonly width: number;\n readonly height: number;\n walkable(tx: number, ty: number): boolean;\n}\n\n/** What a search may be told beyond the grid, shared by `findPath`, `floodFill` and `straightenPath`. */\nexport interface NavOptions {\n /**\n * Extra cost of stepping onto a tile, on top of the step itself (1 straight, √2 diagonal). Must not be negative,\n * or A* stops being exact. `nearWallCost` is one: it keeps a route off the edges of a clearing.\n */\n cost?: (tx: number, ty: number) => number;\n /**\n * Tiles a path may end on but never pass through or brush past diagonally: a door that throws a body onto another\n * map, a trap, a ledge. A start standing on one may still leave it.\n */\n endOnly?: (tx: number, ty: number) => boolean;\n}\n\n/** A grid over any walkability test. */\nexport function navGrid(width: number, height: number, walkable: (tx: number, ty: number) => boolean): NavGrid {\n return { width, height, walkable };\n}\n\n/** The engine's own collision grid as ground to search: a tile a body cannot stand on is a wall. */\nexport function navGridFromCollision(grid: CollisionGrid): NavGrid {\n return { width: grid.width, height: grid.height, walkable: (tx, ty) => !isSolidTile(grid, tx, ty) };\n}\n\n/** Inside the grid and walkable. */\nexport function isOpen(g: NavGrid, tx: number, ty: number): boolean {\n return tx >= 0 && ty >= 0 && tx < g.width && ty < g.height && g.walkable(tx, ty);\n}\n\n/**\n * A `cost` that charges `extra` for a tile with a wall beside it (four-way), so a route prefers the middle of a\n * clearing to the gap between two obstacles — the narrow way is where an auto-walking body wedges itself. 1.4 was\n * high enough to go round a thicket and low enough to still take a gate.\n */\nexport function nearWallCost(g: NavGrid, extra = 1.4): (tx: number, ty: number) => number {\n return (x, y) => (!isOpen(g, x + 1, y) || !isOpen(g, x - 1, y) || !isOpen(g, x, y + 1) || !isOpen(g, x, y - 1) ? extra : 0);\n}\n\n/** Eight-way steps; the diagonals cost √2 so a path does not zig-zag where a straight line would do. */\nexport const NAV_STEPS: readonly (readonly [number, number, number])[] = [\n [1, 0, 1],\n [-1, 0, 1],\n [0, 1, 1],\n [0, -1, 1],\n [1, 1, Math.SQRT2],\n [1, -1, Math.SQRT2],\n [-1, 1, Math.SQRT2],\n [-1, -1, Math.SQRT2],\n];\n\n/**\n * May a body step from (cx, cy) by (dx, dy)? The tile must be open and, when it is end-only, be the goal; a diagonal\n * may not cut the corner between two walls, nor brush an end-only tile on the way past.\n */\nexport function canStep(\n g: NavGrid,\n cx: number,\n cy: number,\n dx: number,\n dy: number,\n endOnly: ((tx: number, ty: number) => boolean) | undefined,\n isGoal: (tx: number, ty: number) => boolean,\n): boolean {\n const nx = cx + dx;\n const ny = cy + dy;\n if (!isOpen(g, nx, ny)) return false;\n if (endOnly && endOnly(nx, ny) && !isGoal(nx, ny)) return false;\n if (dx !== 0 && dy !== 0) {\n if (!isOpen(g, cx + dx, cy) || !isOpen(g, cx, cy + dy)) return false;\n if (endOnly && ((endOnly(cx + dx, cy) && !isGoal(cx + dx, cy)) || (endOnly(cx, cy + dy) && !isGoal(cx, cy + dy)))) return false;\n }\n return true;\n}\n"],"names":["navGrid","width","height","walkable","navGridFromCollision","grid","tx","ty","isSolidTile","isOpen","g","nearWallCost","extra","x","y","NAV_STEPS","canStep","cx","cy","dx","dy","endOnly","isGoal","nx","ny"],"mappings":";AAiCO,SAASA,EAAQC,GAAeC,GAAgBC,GAAwD;AAC7G,SAAO,EAAE,OAAAF,GAAO,QAAAC,GAAQ,UAAAC,EAAA;AAC1B;AAGO,SAASC,EAAqBC,GAA8B;AACjE,SAAO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EAAQJ,IAAKE,GAAID,CAAE,KAAK,CAACI,EAAOL,IAAKE,GAAID,CAAE,KAAOG,EAAQJ,GAAIC,IAAKE,CAAE,KAAK,CAACE,EAAOL,GAAIC,IAAKE,CAAE;AAGlH;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isOpen as b } from "./navGrid.js";
|
|
2
|
+
function c(s, f, i, u = 12, l = (e, t) => b(s, e, t)) {
|
|
3
|
+
if (l(f, i)) return { x: f, y: i };
|
|
4
|
+
for (let e = 1; e <= u; e++) {
|
|
5
|
+
let t = null, o = 1 / 0;
|
|
6
|
+
for (let n = -e; n <= e; n++)
|
|
7
|
+
for (let r = -e; r <= e; r++) {
|
|
8
|
+
if (Math.max(Math.abs(r), Math.abs(n)) !== e || !l(f + r, i + n)) continue;
|
|
9
|
+
const a = r * r + n * n;
|
|
10
|
+
a < o && (o = a, t = { x: f + r, y: i + n });
|
|
11
|
+
}
|
|
12
|
+
if (t) return t;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
c as nearestOpen
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=nearestOpen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nearestOpen.js","sources":["../../src/nav/nearestOpen.ts"],"sourcesContent":["import { isOpen, type NavGrid, type TilePoint } from './navGrid';\n\n/**\n * The open tile nearest to (tx, ty) within `maxRadius` rings, or null: a start or a goal inside a rock still gets a\n * route. `ok` narrows what counts (an open tile that is not a door, say). On each ring the closest tile wins, not\n * the first scanned — scanning order once always picked the ring's top-left corner.\n */\nexport function nearestOpen(\n g: NavGrid,\n tx: number,\n ty: number,\n maxRadius = 12,\n ok: (x: number, y: number) => boolean = (x, y) => isOpen(g, x, y),\n): TilePoint | null {\n if (ok(tx, ty)) return { x: tx, y: ty };\n for (let r = 1; r <= maxRadius; r++) {\n let best: TilePoint | null = null;\n let bestD = Infinity;\n for (let dy = -r; dy <= r; dy++)\n for (let dx = -r; dx <= r; dx++) {\n if (Math.max(Math.abs(dx), Math.abs(dy)) !== r || !ok(tx + dx, ty + dy)) continue;\n const d = dx * dx + dy * dy;\n if (d < bestD) {\n bestD = d;\n best = { x: tx + dx, y: ty + dy };\n }\n }\n if (best) return best;\n }\n return null;\n}\n"],"names":["nearestOpen","g","tx","ty","maxRadius","ok","x","y","isOpen","r","best","bestD","dy","dx","d"],"mappings":";AAOO,SAASA,EACdC,GACAC,GACAC,GACAC,IAAY,IACZC,IAAwC,CAACC,GAAGC,MAAMC,EAAOP,GAAGK,GAAGC,CAAC,GAC9C;AAClB,MAAIF,EAAGH,GAAIC,CAAE,UAAU,EAAE,GAAGD,GAAI,GAAGC,EAAA;AACnC,WAASM,IAAI,GAAGA,KAAKL,GAAWK,KAAK;AACnC,QAAIC,IAAyB,MACzBC,IAAQ;AACZ,aAASC,IAAK,CAACH,GAAGG,KAAMH,GAAGG;AACzB,eAASC,IAAK,CAACJ,GAAGI,KAAMJ,GAAGI,KAAM;AAC/B,YAAI,KAAK,IAAI,KAAK,IAAIA,CAAE,GAAG,KAAK,IAAID,CAAE,CAAC,MAAMH,KAAK,CAACJ,EAAGH,IAAKW,GAAIV,IAAKS,CAAE,EAAG;AACzE,cAAME,IAAID,IAAKA,IAAKD,IAAKA;AACzB,QAAIE,IAAIH,MACNA,IAAQG,GACRJ,IAAO,EAAE,GAAGR,IAAKW,GAAI,GAAGV,IAAKS,EAAA;AAAA,MAEjC;AACF,QAAIF,EAAM,QAAOA;AAAA,EACnB;AACA,SAAO;AACT;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { canStep as S } from "./navGrid.js";
|
|
2
|
+
const T = 48;
|
|
3
|
+
function C(o, t, l = {}) {
|
|
4
|
+
if (t.length < 3) return t.slice();
|
|
5
|
+
const u = l.cost, i = (n, s, c) => (c ? Math.SQRT2 : 1) + (u ? u(n, s) : 0), r = [0];
|
|
6
|
+
for (let n = 1; n < t.length; n++) {
|
|
7
|
+
const s = t[n - 1], c = t[n];
|
|
8
|
+
r.push(r[n - 1] + i(c.x, c.y, s.x !== c.x && s.y !== c.y));
|
|
9
|
+
}
|
|
10
|
+
const b = t[t.length - 1], f = [t[0]];
|
|
11
|
+
let e = 0;
|
|
12
|
+
for (; e < t.length - 1; ) {
|
|
13
|
+
let n = !1;
|
|
14
|
+
for (let s = Math.min(t.length - 1, e + T); s >= e + 2 && !n; s--) {
|
|
15
|
+
const c = r[s] - r[e] + 1e-6;
|
|
16
|
+
for (const h of [!0, !1]) {
|
|
17
|
+
const g = W(o, t[e], t[s], h, l.endOnly, b, c, i);
|
|
18
|
+
if (g) {
|
|
19
|
+
f.push(...g), e = s, n = !0;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n || f.push(t[++e]);
|
|
25
|
+
}
|
|
26
|
+
return f;
|
|
27
|
+
}
|
|
28
|
+
function W(o, t, l, u, i, r, b, f) {
|
|
29
|
+
const e = l.x - t.x, n = l.y - t.y, s = Math.min(Math.abs(e), Math.abs(n)), c = Math.max(Math.abs(e), Math.abs(n)) - s, h = [Math.sign(e), Math.sign(n)], g = Math.abs(e) > Math.abs(n) ? [Math.sign(e), 0] : [0, Math.sign(n)], w = u ? [[h, s], [g, c]] : [[g, c], [h, s]], O = (x, y) => x === r.x && y === r.y, d = [];
|
|
30
|
+
let a = t.x, M = t.y, m = 0;
|
|
31
|
+
for (const [[x, y], P] of w)
|
|
32
|
+
for (let k = 0; k < P; k++) {
|
|
33
|
+
if (!S(o, a, M, x, y, i, O) || (a += x, M += y, m += f(a, M, x !== 0 && y !== 0), m > b)) return null;
|
|
34
|
+
d.push({ x: a, y: M });
|
|
35
|
+
}
|
|
36
|
+
return d;
|
|
37
|
+
}
|
|
38
|
+
function D(o) {
|
|
39
|
+
if (o.length < 3) return o.slice();
|
|
40
|
+
const t = [o[0]];
|
|
41
|
+
for (let l = 1; l < o.length - 1; l++) {
|
|
42
|
+
const u = t[t.length - 1], i = o[l], r = o[l + 1];
|
|
43
|
+
(i.x - u.x) * (r.y - i.y) !== (i.y - u.y) * (r.x - i.x) && t.push(i);
|
|
44
|
+
}
|
|
45
|
+
return t.push(o[o.length - 1]), t;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
D as simplifyPath,
|
|
49
|
+
C as straightenPath
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=straightenPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"straightenPath.js","sources":["../../src/nav/straightenPath.ts"],"sourcesContent":["import { canStep, type NavGrid, type NavOptions, type TilePoint } from './navGrid';\n\n/** How many tiles ahead `straightenPath` looks for a straighter way: enough for a long staircase, cheap per re-solve. */\nconst WINDOW = 48;\n\n/**\n * The same route with fewer turns. An eight-way search finds many equally short paths and hands back whichever its\n * heap settled on, often a staircase — diagonal, straight, diagonal, straight — and a body walking one turns on every\n * tile. Each stretch that can be is replaced with the plainest equal way through it: one diagonal run and one straight\n * run. A replacement must cost no more than the stretch did (by the same `cost`, so it never trades the middle of a\n * clearing for the edge of a wall), step only where the search could, and touch no end-only tile short of the end.\n * Pass the options the path was found with.\n */\nexport function straightenPath(g: NavGrid, path: readonly TilePoint[], options: NavOptions = {}): TilePoint[] {\n if (path.length < 3) return path.slice();\n const extra = options.cost;\n const stepCost = (x: number, y: number, diagonal: boolean) => (diagonal ? Math.SQRT2 : 1) + (extra ? extra(x, y) : 0);\n const upTo = [0];\n for (let k = 1; k < path.length; k++) {\n const a = path[k - 1]!;\n const b = path[k]!;\n upTo.push(upTo[k - 1]! + stepCost(b.x, b.y, a.x !== b.x && a.y !== b.y));\n }\n const last = path[path.length - 1]!;\n const out: TilePoint[] = [path[0]!];\n let i = 0;\n while (i < path.length - 1) {\n let taken = false;\n for (let j = Math.min(path.length - 1, i + WINDOW); j >= i + 2 && !taken; j--) {\n const budget = upTo[j]! - upTo[i]! + 1e-6;\n for (const diagonalFirst of [true, false]) {\n const legs = twoLegs(g, path[i]!, path[j]!, diagonalFirst, options.endOnly, last, budget, stepCost);\n if (!legs) continue;\n out.push(...legs);\n i = j;\n taken = true;\n break;\n }\n }\n if (!taken) out.push(path[++i]!);\n }\n return out;\n}\n\n/** The tiles after `a` up to `b` along one diagonal run and one straight run, or null when that way is shut or dearer. */\nfunction twoLegs(\n g: NavGrid,\n a: TilePoint,\n b: TilePoint,\n diagonalFirst: boolean,\n endOnly: ((tx: number, ty: number) => boolean) | undefined,\n last: TilePoint,\n budget: number,\n stepCost: (x: number, y: number, diagonal: boolean) => number,\n): TilePoint[] | null {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const diag = Math.min(Math.abs(dx), Math.abs(dy));\n const straight = Math.max(Math.abs(dx), Math.abs(dy)) - diag;\n const d: [number, number] = [Math.sign(dx), Math.sign(dy)];\n const s: [number, number] = Math.abs(dx) > Math.abs(dy) ? [Math.sign(dx), 0] : [0, Math.sign(dy)];\n const runs: [[number, number], number][] = diagonalFirst ? [[d, diag], [s, straight]] : [[s, straight], [d, diag]];\n // only the path's own last tile may be end-only\n const isEnd = (x: number, y: number) => x === last.x && y === last.y;\n const tiles: TilePoint[] = [];\n let x = a.x;\n let y = a.y;\n let cost = 0;\n for (const [[sx, sy], n] of runs) {\n for (let k = 0; k < n; k++) {\n if (!canStep(g, x, y, sx, sy, endOnly, isEnd)) return null;\n x += sx;\n y += sy;\n cost += stepCost(x, y, sx !== 0 && sy !== 0);\n if (cost > budget) return null;\n tiles.push({ x, y });\n }\n }\n return tiles;\n}\n\n/** Drops the tiles a straight line already covers, so a trail is drawn as a few long legs rather than tile by tile. */\nexport function simplifyPath(path: readonly TilePoint[]): TilePoint[] {\n if (path.length < 3) return path.slice();\n const out: TilePoint[] = [path[0]!];\n for (let i = 1; i < path.length - 1; i++) {\n const a = out[out.length - 1]!;\n const b = path[i]!;\n const c = path[i + 1]!;\n if ((b.x - a.x) * (c.y - b.y) !== (b.y - a.y) * (c.x - b.x)) out.push(b);\n }\n out.push(path[path.length - 1]!);\n return out;\n}\n"],"names":["WINDOW","straightenPath","g","path","options","extra","stepCost","x","y","diagonal","upTo","k","a","b","last","out","i","taken","j","budget","diagonalFirst","legs","twoLegs","endOnly","dx","dy","diag","straight","d","s","runs","isEnd","tiles","cost","sx","sy","n","canStep","simplifyPath","c"],"mappings":";AAGA,MAAMA,IAAS;AAUR,SAASC,EAAeC,GAAYC,GAA4BC,IAAsB,CAAA,GAAiB;AAC5G,MAAID,EAAK,SAAS,EAAG,QAAOA,EAAK,MAAA;AACjC,QAAME,IAAQD,EAAQ,MAChBE,IAAW,CAACC,GAAWC,GAAWC,OAAuBA,IAAW,KAAK,QAAQ,MAAMJ,IAAQA,EAAME,GAAGC,CAAC,IAAI,IAC7GE,IAAO,CAAC,CAAC;AACf,WAASC,IAAI,GAAGA,IAAIR,EAAK,QAAQQ,KAAK;AACpC,UAAMC,IAAIT,EAAKQ,IAAI,CAAC,GACdE,IAAIV,EAAKQ,CAAC;AAChB,IAAAD,EAAK,KAAKA,EAAKC,IAAI,CAAC,IAAKL,EAASO,EAAE,GAAGA,EAAE,GAAGD,EAAE,MAAMC,EAAE,KAAKD,EAAE,MAAMC,EAAE,CAAC,CAAC;AAAA,EACzE;AACA,QAAMC,IAAOX,EAAKA,EAAK,SAAS,CAAC,GAC3BY,IAAmB,CAACZ,EAAK,CAAC,CAAE;AAClC,MAAIa,IAAI;AACR,SAAOA,IAAIb,EAAK,SAAS,KAAG;AAC1B,QAAIc,IAAQ;AACZ,aAASC,IAAI,KAAK,IAAIf,EAAK,SAAS,GAAGa,IAAIhB,CAAM,GAAGkB,KAAKF,IAAI,KAAK,CAACC,GAAOC,KAAK;AAC7E,YAAMC,IAAST,EAAKQ,CAAC,IAAKR,EAAKM,CAAC,IAAK;AACrC,iBAAWI,KAAiB,CAAC,IAAM,EAAK,GAAG;AACzC,cAAMC,IAAOC,EAAQpB,GAAGC,EAAKa,CAAC,GAAIb,EAA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GAAIC,GAAIZ,GAASQ,CAAK,MAC5CxB,KAAK2B,GACL1B,KAAK2B,GACLF,KAAQ3B,EAASC,GAAGC,GAAG0B,MAAO,KAAKC,MAAO,CAAC,GACvCF,IAAOd,GAAQ,QAAO;AAC1B,MAAAa,EAAM,KAAK,EAAE,GAAAzB,GAAG,GAAAC,EAAA,CAAG;AAAA,IACrB;AAEF,SAAOwB;AACT;AAGO,SAASM,EAAanC,GAAyC;AACpE,MAAIA,EAAK,SAAS,EAAG,QAAOA,EAAK,MAAA;AACjC,QAAMY,IAAmB,CAACZ,EAAK,CAAC,CAAE;AAClC,WAASa,IAAI,GAAGA,IAAIb,EAAK,SAAS,GAAGa,KAAK;AACxC,UAAMJ,IAAIG,EAAIA,EAAI,SAAS,CAAC,GACtBF,IAAIV,EAAKa,CAAC,GACVuB,IAAIpC,EAAKa,IAAI,CAAC;AACpB,KAAKH,EAAE,IAAID,EAAE,MAAM2B,EAAE,IAAI1B,EAAE,QAAQA,EAAE,IAAID,EAAE,MAAM2B,EAAE,IAAI1B,EAAE,MAAIE,EAAI,KAAKF,CAAC;AAAA,EACzE;AACA,SAAAE,EAAI,KAAKZ,EAAKA,EAAK,SAAS,CAAC,CAAE,GACxBY;AACT;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { EventBus as o } from "../events/EventBus.js";
|
|
2
|
+
import { noteServerTime as r } from "./serverClock.js";
|
|
3
|
+
import { decodeSnapshotFrame as h } from "./snapshotCodec.js";
|
|
4
|
+
class m {
|
|
5
|
+
constructor(e, t = {}) {
|
|
6
|
+
this.url = e, this.options = t;
|
|
7
|
+
}
|
|
8
|
+
url;
|
|
9
|
+
options;
|
|
10
|
+
events = new o();
|
|
11
|
+
/** The last measured round trip, ms. */
|
|
12
|
+
rtt = 0;
|
|
13
|
+
socket = null;
|
|
14
|
+
batch = null;
|
|
15
|
+
closedByUs = !1;
|
|
16
|
+
attempt = 0;
|
|
17
|
+
pingTimer = null;
|
|
18
|
+
retryTimer = null;
|
|
19
|
+
get open() {
|
|
20
|
+
return this.socket?.readyState === 1;
|
|
21
|
+
}
|
|
22
|
+
connect() {
|
|
23
|
+
this.closedByUs = !1;
|
|
24
|
+
const e = this.options.WebSocket ?? globalThis.WebSocket;
|
|
25
|
+
if (!e) throw new Error("Connection: no WebSocket in this environment");
|
|
26
|
+
const t = new e(this.url);
|
|
27
|
+
return t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
|
|
28
|
+
this.attempt = 0, this.send({ t: "hello", data: this.options.hello?.() }), this.ping(), this.pingTimer = setInterval(() => this.ping(), this.options.pingMs ?? 1e3), this.events.emit("open", void 0);
|
|
29
|
+
}, t.onmessage = (s) => this.receive(s.data), t.onclose = (s) => {
|
|
30
|
+
this.pingTimer && clearInterval(this.pingTimer), this.pingTimer = null, this.socket = null;
|
|
31
|
+
const i = !this.closedByUs && this.options.reconnect !== !1;
|
|
32
|
+
if (this.events.emit("close", { code: s.code, reason: s.reason, willRetry: i }), i) {
|
|
33
|
+
const n = Math.min(this.options.maxBackoffMs ?? 1e4, 250 * 2 ** this.attempt++);
|
|
34
|
+
this.retryTimer = setTimeout(() => this.connect(), n);
|
|
35
|
+
}
|
|
36
|
+
}, this;
|
|
37
|
+
}
|
|
38
|
+
/** Sends a message now (dropped while closed: input is resent by the prediction's own state, not by the socket). */
|
|
39
|
+
send(e) {
|
|
40
|
+
this.socket?.readyState === 1 && this.socket.send(JSON.stringify(e));
|
|
41
|
+
}
|
|
42
|
+
/** Adds one input step to this frame's batch; `flush` sends it. Steps must come in sequence order. */
|
|
43
|
+
queueInput(e, t) {
|
|
44
|
+
this.batch || (this.batch = { seq: e, steps: [] }), this.batch.steps.push([t[0], t[1], t[2]]);
|
|
45
|
+
}
|
|
46
|
+
/** Sends this frame's input steps as one message. Call once a frame. */
|
|
47
|
+
flush() {
|
|
48
|
+
this.batch && (this.send({ t: "input", seq: this.batch.seq, steps: this.batch.steps }), this.batch = null);
|
|
49
|
+
}
|
|
50
|
+
close() {
|
|
51
|
+
this.closedByUs = !0, this.retryTimer && clearTimeout(this.retryTimer), this.pingTimer && clearInterval(this.pingTimer), this.socket?.close(), this.socket = null;
|
|
52
|
+
}
|
|
53
|
+
ping() {
|
|
54
|
+
this.send({ t: "ping", c: Date.now() });
|
|
55
|
+
}
|
|
56
|
+
receive(e) {
|
|
57
|
+
let t;
|
|
58
|
+
try {
|
|
59
|
+
t = typeof e == "string" ? JSON.parse(e) : h(e);
|
|
60
|
+
} catch (s) {
|
|
61
|
+
console.error("[net] could not read a message", s);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
switch (t.t) {
|
|
65
|
+
case "pong": {
|
|
66
|
+
const s = t;
|
|
67
|
+
this.rtt = Date.now() - s.c, r(s.st, this.rtt);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
case "welcome":
|
|
71
|
+
this.events.emit("welcome", t);
|
|
72
|
+
return;
|
|
73
|
+
case "snap":
|
|
74
|
+
this.events.emit("snapshot", t);
|
|
75
|
+
return;
|
|
76
|
+
default:
|
|
77
|
+
this.events.emit("message", t);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
m as Connection
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=Connection.js.map
|