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 @@
|
|
|
1
|
+
{"version":3,"file":"Matchmaker.js","sources":["../../../src/net/lobby/Matchmaker.ts"],"sourcesContent":["/** A mode the matchmaker fills: `teams` sides of `teamSize` players. */\nexport interface MatchMode {\n id: string;\n teams: number;\n teamSize: number;\n /** Rating difference allowed at once (default 100), widened by `widenPerSecond` (default 10) up to `maxWindow` (default 600). */\n window?: number;\n widenPerSecond?: number;\n maxWindow?: number;\n}\n\n/** One group waiting together: a player alone, or a party that must not be split. */\nexport interface Ticket {\n id: string;\n mode: string;\n members: readonly number[];\n /** The group's rating (the game's own: Elo, a level, a power score). */\n rating: number;\n /** When it joined the queue (ms): the oldest waits least. */\n since: number;\n}\n\nexport interface FoundMatch {\n mode: string;\n tickets: Ticket[];\n /** Each team's player ids, in the order the teams are numbered. */\n teams: number[][];\n}\n\n/**\n * The matchmaking queue, pure: tickets in, matches out, no clock of its own and no sockets. Each `find(now)` takes\n * the oldest ticket of a mode as the anchor, gathers the groups within its rating window (and each within theirs,\n * so a newcomer is not thrown in with veterans because a veteran waited), and fills the teams from the closest\n * ratings first, never splitting a party; the teams are then balanced by rating. A window grows with the wait, so\n * anyone is matched in the end; a ticket nothing fits waits for the next call.\n */\nexport class Matchmaker {\n private readonly modes = new Map<string, MatchMode>();\n private readonly tickets = new Map<string, Ticket>();\n\n constructor(modes: readonly MatchMode[]) {\n for (const m of modes) {\n if (!(m.teams >= 1 && m.teamSize >= 1)) throw new Error(`Matchmaker: mode ${m.id} needs at least one team of one`);\n this.modes.set(m.id, m);\n }\n }\n\n get size(): number {\n return this.tickets.size;\n }\n\n mode(id: string): MatchMode | undefined {\n return this.modes.get(id);\n }\n\n /** Adds a ticket (replacing one of the same id); throws on an unknown mode or a group too big for a team. */\n add(ticket: Ticket): void {\n const m = this.modes.get(ticket.mode);\n if (!m) throw new Error(`Matchmaker: no mode ${ticket.mode}`);\n if (ticket.members.length < 1 || ticket.members.length > m.teamSize) throw new Error(`Matchmaker: a group of ${ticket.members.length} does not fit a team of ${m.teamSize}`);\n this.tickets.set(ticket.id, ticket);\n }\n\n remove(id: string): Ticket | undefined {\n const t = this.tickets.get(id);\n this.tickets.delete(id);\n return t;\n }\n\n get(id: string): Ticket | undefined {\n return this.tickets.get(id);\n }\n\n /** The tickets waiting for a mode, oldest first. */\n waiting(mode: string): Ticket[] {\n return [...this.tickets.values()].filter((t) => t.mode === mode).sort((a, b) => a.since - b.since);\n }\n\n /** How far a ticket's rating window reaches now. */\n windowOf(t: Ticket, now: number): number {\n const m = this.modes.get(t.mode)!;\n const waited = Math.max(0, now - t.since) / 1000;\n return Math.min(m.maxWindow ?? 600, (m.window ?? 100) + (m.widenPerSecond ?? 10) * waited);\n }\n\n /** Every match that can be made now; their tickets leave the queue. */\n find(now: number): FoundMatch[] {\n const out: FoundMatch[] = [];\n for (const mode of this.modes.values()) {\n const need = mode.teams * mode.teamSize;\n let progress = true;\n while (progress) {\n progress = false;\n const queue = this.waiting(mode.id);\n for (const anchor of queue) {\n const match = this.tryAnchor(anchor, queue, mode, need, now);\n if (!match) continue;\n for (const t of match.tickets) this.tickets.delete(t.id);\n out.push(match);\n progress = true;\n break;\n }\n }\n }\n return out;\n }\n\n private tryAnchor(anchor: Ticket, queue: Ticket[], mode: MatchMode, need: number, now: number): FoundMatch | null {\n const wa = this.windowOf(anchor, now);\n const near = queue\n .filter((t) => t !== anchor && Math.abs(t.rating - anchor.rating) <= Math.min(wa, this.windowOf(t, now)))\n .sort((a, b) => Math.abs(a.rating - anchor.rating) - Math.abs(b.rating - anchor.rating) || a.since - b.since);\n const picked = pickGroups([anchor], near, need);\n if (!picked) return null;\n const teams = balanceTeams(picked, mode.teams, mode.teamSize);\n if (!teams) return null;\n return { mode: mode.id, tickets: picked, teams };\n }\n}\n\n/** Groups from `pool` (closest first) added to `start` until they hold exactly `need` players; a small search, not greedy, so a party of three is not shut out by two singles taken first. */\nfunction pickGroups(start: Ticket[], pool: Ticket[], need: number): Ticket[] | null {\n const have = start.reduce((n, t) => n + t.members.length, 0);\n if (have === need) return start;\n if (have > need) return null;\n const chosen: Ticket[] = [];\n let budget = 2000;\n const search = (from: number, left: number): boolean => {\n if (left === 0) return true;\n if (--budget < 0) return false;\n for (let i = from; i < pool.length; i++) {\n const t = pool[i]!;\n if (t.members.length > left) continue;\n chosen.push(t);\n if (search(i + 1, left - t.members.length)) return true;\n chosen.pop();\n }\n return false;\n };\n return search(0, need - have) ? [...start, ...chosen] : null;\n}\n\n/**\n * Splits groups into `teams` of exactly `size` players, parties whole, ratings as even as it can: the largest groups\n * first, each into the team with room whose rating total is lowest. Returns null when the sizes cannot be packed.\n */\nexport function balanceTeams(groups: readonly Ticket[], teams: number, size: number): number[][] | null {\n const sorted = [...groups].sort((a, b) => b.members.length - a.members.length || b.rating - a.rating);\n const sides = Array.from({ length: teams }, () => ({ ids: [] as number[], weight: 0 }));\n const place = (i: number): boolean => {\n if (i === sorted.length) return true;\n const g = sorted[i]!;\n const order = [...sides.keys()].sort((a, b) => sides[a]!.weight - sides[b]!.weight || sides[a]!.ids.length - sides[b]!.ids.length);\n for (const s of order) {\n const side = sides[s]!;\n if (side.ids.length + g.members.length > size) continue;\n side.ids.push(...g.members);\n side.weight += g.rating * g.members.length;\n if (place(i + 1)) return true;\n side.ids.length -= g.members.length;\n side.weight -= g.rating * g.members.length;\n }\n return false;\n };\n return place(0) ? sides.map((s) => s.ids) : null;\n}\n"],"names":["Matchmaker","modes","m","id","ticket","mode","a","b","t","now","waited","out","need","progress","queue","anchor","match","wa","near","picked","pickGroups","teams","balanceTeams","start","pool","have","n","chosen","budget","search","from","left","i","groups","size","sorted","sides","place","g","order","s","side"],"mappings":"AAoCO,MAAMA,EAAW;AAAA,EACL,4BAAY,IAAA;AAAA,EACZ,8BAAc,IAAA;AAAA,EAE/B,YAAYC,GAA6B;AACvC,eAAWC,KAAKD,GAAO;AACrB,UAAI,EAAEC,EAAE,SAAS,KAAKA,EAAE,YAAY,GAAI,OAAM,IAAI,MAAM,oBAAoBA,EAAE,EAAE,iCAAiC;AACjH,WAAK,MAAM,IAAIA,EAAE,IAAIA,CAAC;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA,EAEA,KAAKC,GAAmC;AACtC,WAAO,KAAK,MAAM,IAAIA,CAAE;AAAA,EAC1B;AAAA;AAAA,EAGA,IAAIC,GAAsB;AACxB,UAAMF,IAAI,KAAK,MAAM,IAAIE,EAAO,IAAI;AACpC,QAAI,CAACF,EAAG,OAAM,IAAI,MAAM,uBAAuBE,EAAO,IAAI,EAAE;AAC5D,QAAIA,EAAO,QAAQ,SAAS,KAAKA,EAAO,QAAQ,SAASF,EAAE,gBAAgB,IAAI,MAAM,0BAA0BE,EAAO,QAAQ,MAAM,2BAA2BF,EAAE,QAAQ,EAAE;AAC3K,SAAK,QAAQ,IAAIE,EAAO,IAAIA,CAAM;AAAA,EACpC;AAAA,EAEA,OAAOD,GAAgC;AACrC,UAAM,IAAI,KAAK,QAAQ,IAAIA,CAAE;AAC7B,gBAAK,QAAQ,OAAOA,CAAE,GACf;AAAA,EACT;AAAA,EAEA,IAAIA,GAAgC;AAClC,WAAO,KAAK,QAAQ,IAAIA,CAAE;AAAA,EAC5B;AAAA;AAAA,EAGA,QAAQE,GAAwB;AAC9B,WA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AASD,EAAE,QAAQ,UAAUC,EAAE,SAASD,EAAE,MAAM,GAC9F8B,IAAQ,MAAM,KAAK,EAAE,QAAQf,EAAA,GAAS,OAAO,EAAE,KAAK,CAAA,GAAgB,QAAQ,IAAI,GAChFgB,IAAQ,CAACL,MAAuB;AACpC,QAAIA,MAAMG,EAAO,OAAQ,QAAO;AAChC,UAAMG,IAAIH,EAAOH,CAAC,GACZO,IAAQ,CAAC,GAAGH,EAAM,KAAA,CAAM,EAAE,KAAK,CAAC,GAAG7B,MAAM6B,EAAM,CAAC,EAAG,SAASA,EAAM7B,CAAC,EAAG,UAAU6B,EAAM,CAAC,EAAG,IAAI,SAASA,EAAM7B,CAAC,EAAG,IAAI,MAAM;AACjI,eAAWiC,KAAKD,GAAO;AACrB,YAAME,IAAOL,EAAMI,CAAC;AACpB,UAAI,EAAAC,EAAK,IAAI,SAASH,EAAE,QAAQ,SAASJ,IAGzC;AAAA,YAFAO,EAAK,IAAI,KAAK,GAAGH,EAAE,OAAO,GAC1BG,EAAK,UAAUH,EAAE,SAASA,EAAE,QAAQ,QAChCD,EAAML,IAAI,CAAC,EAAG,QAAO;AACzB,QAAAS,EAAK,IAAI,UAAUH,EAAE,QAAQ,QAC7BG,EAAK,UAAUH,EAAE,SAASA,EAAE,QAAQ;AAAA;AAAA,IACtC;AACA,WAAO;AAAA,EACT;AACA,SAAOD,EAAM,CAAC,IAAID,EAAM,IAAI,CAACI,MAAMA,EAAE,GAAG,IAAI;AAC9C;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BODY_HALF_WIDTH as D, BODY_HALF_HEIGHT as M, COLLISION_EPSILON as y, INPUT_FLAG_DASH as x, INPUT_STEP_DT as H } from "./constants.js";
|
|
2
|
+
const u = 0.7071067811865476;
|
|
3
|
+
function W(t, e, o, h, f = {}) {
|
|
4
|
+
if (h.length !== t * e)
|
|
5
|
+
throw new Error(`collision string length ${h.length} != ${t}x${e}`);
|
|
6
|
+
const n = new Uint8Array(t * e);
|
|
7
|
+
for (let c = 0; c < n.length; c++) n[c] = h.charCodeAt(c) === 49 ? 1 : 0;
|
|
8
|
+
const { ground: r } = f, s = new Set(f.shotOverTiles ?? []);
|
|
9
|
+
let l;
|
|
10
|
+
if (r && r.length === n.length && s.size) {
|
|
11
|
+
l = new Uint8Array(n.length);
|
|
12
|
+
for (let c = 0; c < n.length; c++) l[c] = n[c] && s.has(r[c]) ? 1 : 0;
|
|
13
|
+
}
|
|
14
|
+
const a = f.bodyHalfWidth ?? D, d = f.bodyHalfHeight ?? M;
|
|
15
|
+
return l ? { width: t, height: e, tileSize: o, solid: n, shotOver: l, bodyHalfWidth: a, bodyHalfHeight: d } : { width: t, height: e, tileSize: o, solid: n, bodyHalfWidth: a, bodyHalfHeight: d };
|
|
16
|
+
}
|
|
17
|
+
function A(t, e, o) {
|
|
18
|
+
return i(t, e, o) ? t.shotOver?.[o * t.width + e] !== 1 : !1;
|
|
19
|
+
}
|
|
20
|
+
function C(t, e) {
|
|
21
|
+
return { x: t, y: e, lastDx: 1, lastDy: 0, dashLeft: 0, dashCd: 0, dashDx: 1, dashDy: 0 };
|
|
22
|
+
}
|
|
23
|
+
function i(t, e, o) {
|
|
24
|
+
return e < 0 || o < 0 || e >= t.width || o >= t.height ? !0 : t.solid[o * t.width + e] === 1;
|
|
25
|
+
}
|
|
26
|
+
function O(t, e, o) {
|
|
27
|
+
const h = t.tileSize, f = Math.floor((e - t.bodyHalfWidth) / h), n = Math.floor((e + t.bodyHalfWidth) / h), r = Math.floor((o - t.bodyHalfHeight) / h), s = Math.floor((o + t.bodyHalfHeight) / h);
|
|
28
|
+
for (let l = r; l <= s; l++)
|
|
29
|
+
for (let a = f; a <= n; a++)
|
|
30
|
+
if (i(t, a, l)) return !0;
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
function L(t, e, o, h) {
|
|
34
|
+
if (h === 0) return e;
|
|
35
|
+
const f = t.tileSize, n = e + h, r = Math.floor((o - t.bodyHalfHeight) / f), s = Math.floor((o + t.bodyHalfHeight) / f);
|
|
36
|
+
if (h > 0) {
|
|
37
|
+
const l = Math.floor((n + t.bodyHalfWidth) / f);
|
|
38
|
+
for (let a = r; a <= s; a++)
|
|
39
|
+
if (i(t, l, a)) return l * f - t.bodyHalfWidth - y;
|
|
40
|
+
} else {
|
|
41
|
+
const l = Math.floor((n - t.bodyHalfWidth) / f);
|
|
42
|
+
for (let a = r; a <= s; a++)
|
|
43
|
+
if (i(t, l, a)) return (l + 1) * f + t.bodyHalfWidth + y;
|
|
44
|
+
}
|
|
45
|
+
return n;
|
|
46
|
+
}
|
|
47
|
+
function S(t, e, o, h) {
|
|
48
|
+
if (h === 0) return o;
|
|
49
|
+
const f = t.tileSize, n = o + h, r = Math.floor((e - t.bodyHalfWidth) / f), s = Math.floor((e + t.bodyHalfWidth) / f);
|
|
50
|
+
if (h > 0) {
|
|
51
|
+
const l = Math.floor((n + t.bodyHalfHeight) / f);
|
|
52
|
+
for (let a = r; a <= s; a++)
|
|
53
|
+
if (i(t, a, l)) return l * f - t.bodyHalfHeight - y;
|
|
54
|
+
} else {
|
|
55
|
+
const l = Math.floor((n - t.bodyHalfHeight) / f);
|
|
56
|
+
for (let a = r; a <= s; a++)
|
|
57
|
+
if (i(t, a, l)) return (l + 1) * f + t.bodyHalfHeight + y;
|
|
58
|
+
}
|
|
59
|
+
return n;
|
|
60
|
+
}
|
|
61
|
+
function b(t) {
|
|
62
|
+
return t > 0 ? 1 : t < 0 ? -1 : 0;
|
|
63
|
+
}
|
|
64
|
+
function _(t, e, o, h) {
|
|
65
|
+
t.dashCd > 0 && t.dashCd--;
|
|
66
|
+
const f = t.dashLeft > 0;
|
|
67
|
+
let n = o.canMove && !f ? b(e[0]) : 0, r = o.canMove && !f ? b(e[1]) : 0;
|
|
68
|
+
n !== 0 && r !== 0 && (n = n * u, r = r * u), (n !== 0 || r !== 0) && (t.lastDx = n, t.lastDy = r), (e[2] & x) !== 0 && o.canDash && o.canMove && t.dashLeft === 0 && t.dashCd === 0 && (t.dashLeft = o.dashSteps, t.dashCd = o.dashCooldownSteps, t.dashDx = t.lastDx, t.dashDy = t.lastDy);
|
|
69
|
+
let s, l;
|
|
70
|
+
t.dashLeft > 0 ? (s = t.dashDx * o.dashSpeed, l = t.dashDy * o.dashSpeed, t.dashLeft--) : (s = n * o.speed, l = r * o.speed), t.x = L(h, t.x, t.y, s * H), t.y = S(h, t.x, t.y, l * H);
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
u as DIAGONAL,
|
|
74
|
+
A as blocksShot,
|
|
75
|
+
O as bodyCollides,
|
|
76
|
+
W as createCollisionGrid,
|
|
77
|
+
C as createMover,
|
|
78
|
+
i as isSolidTile,
|
|
79
|
+
L as moveX,
|
|
80
|
+
S as moveY,
|
|
81
|
+
_ as stepMover
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=movement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movement.js","sources":["../../src/net/movement.ts"],"sourcesContent":["import {\n BODY_HALF_HEIGHT,\n BODY_HALF_WIDTH,\n COLLISION_EPSILON,\n INPUT_FLAG_DASH,\n INPUT_STEP_DT,\n type InputStep,\n type MovementParams,\n} from './constants';\n\n/*\n * Deterministic player movement simulation.\n *\n * The server runs this exact algorithm (or a port of it) as the authority;\n * the client runs it for prediction and replays unacknowledged steps after every snapshot.\n * Keep the operation order identical on both sides so floating point results match bit for bit.\n */\n\n/** 1/sqrt(2), written as a literal so every port uses the exact same double. */\nexport const DIAGONAL = 0.7071067811865476;\n\nexport interface CollisionGrid {\n readonly width: number;\n readonly height: number;\n readonly tileSize: number;\n /** 1 = solid, row-major. */\n readonly solid: Uint8Array;\n /** 1 = a solid tile a shot flies over (`shotOverTiles`), row-major; absent when the ground was not given. */\n readonly shotOver?: Uint8Array;\n /** Half the moving body's collision box, px. */\n readonly bodyHalfWidth: number;\n readonly bodyHalfHeight: number;\n}\n\nexport interface CollisionGridOptions {\n /** The tile id of every cell, row-major; needed only for `shotOverTiles`. */\n ground?: readonly number[];\n /** Tile ids nothing walks but a shot flies over (water, lava…): solid for bodies, open for shots. */\n shotOverTiles?: Iterable<number>;\n /** Half the moving body's collision box, px (default `BODY_HALF_WIDTH` × `BODY_HALF_HEIGHT`, a 10×6 foot box). */\n bodyHalfWidth?: number;\n bodyHalfHeight?: number;\n}\n\nexport interface MoverState {\n x: number;\n y: number;\n /** Last non-zero movement direction (normalized), used for dashing while idle. */\n lastDx: number;\n lastDy: number;\n dashLeft: number;\n dashCd: number;\n dashDx: number;\n dashDy: number;\n}\n\n/** A grid from a string of '0'/'1' per cell (row-major, '1' solid). */\nexport function createCollisionGrid(width: number, height: number, tileSize: number, solid: string, options: CollisionGridOptions = {}): CollisionGrid {\n if (solid.length !== width * height) {\n throw new Error(`collision string length ${solid.length} != ${width}x${height}`);\n }\n const bytes = new Uint8Array(width * height);\n for (let i = 0; i < bytes.length; i++) bytes[i] = solid.charCodeAt(i) === 49 ? 1 : 0;\n const { ground } = options;\n const over = new Set(options.shotOverTiles ?? []);\n let shotOver: Uint8Array | undefined;\n if (ground && ground.length === bytes.length && over.size) {\n shotOver = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) shotOver[i] = bytes[i] && over.has(ground[i]!) ? 1 : 0;\n }\n const bodyHalfWidth = options.bodyHalfWidth ?? BODY_HALF_WIDTH;\n const bodyHalfHeight = options.bodyHalfHeight ?? BODY_HALF_HEIGHT;\n return shotOver ? { width, height, tileSize, solid: bytes, shotOver, bodyHalfWidth, bodyHalfHeight } : { width, height, tileSize, solid: bytes, bodyHalfWidth, bodyHalfHeight };\n}\n\n/** Whether a shot in flight stops on this tile: solid, and not ground a shot flies over (`shotOverTiles`). */\nexport function blocksShot(grid: CollisionGrid, tx: number, ty: number): boolean {\n if (!isSolidTile(grid, tx, ty)) return false;\n return grid.shotOver?.[ty * grid.width + tx] !== 1;\n}\n\nexport function createMover(x: number, y: number): MoverState {\n return { x, y, lastDx: 1, lastDy: 0, dashLeft: 0, dashCd: 0, dashDx: 1, dashDy: 0 };\n}\n\nexport function isSolidTile(grid: CollisionGrid, tx: number, ty: number): boolean {\n if (tx < 0 || ty < 0 || tx >= grid.width || ty >= grid.height) return true;\n return grid.solid[ty * grid.width + tx] === 1;\n}\n\n/** True if the body box centered at (x, y) overlaps a solid tile. */\nexport function bodyCollides(grid: CollisionGrid, x: number, y: number): boolean {\n const ts = grid.tileSize;\n const x0 = Math.floor((x - grid.bodyHalfWidth) / ts);\n const x1 = Math.floor((x + grid.bodyHalfWidth) / ts);\n const y0 = Math.floor((y - grid.bodyHalfHeight) / ts);\n const y1 = Math.floor((y + grid.bodyHalfHeight) / ts);\n for (let ty = y0; ty <= y1; ty++) {\n for (let tx = x0; tx <= x1; tx++) {\n if (isSolidTile(grid, tx, ty)) return true;\n }\n }\n return false;\n}\n\n/** Moves along X by dx, stopping flush against the first solid tile column. */\nexport function moveX(grid: CollisionGrid, x: number, y: number, dx: number): number {\n if (dx === 0) return x;\n const ts = grid.tileSize;\n const nx = x + dx;\n const y0 = Math.floor((y - grid.bodyHalfHeight) / ts);\n const y1 = Math.floor((y + grid.bodyHalfHeight) / ts);\n if (dx > 0) {\n const tx = Math.floor((nx + grid.bodyHalfWidth) / ts);\n for (let ty = y0; ty <= y1; ty++) {\n if (isSolidTile(grid, tx, ty)) return tx * ts - grid.bodyHalfWidth - COLLISION_EPSILON;\n }\n } else {\n const tx = Math.floor((nx - grid.bodyHalfWidth) / ts);\n for (let ty = y0; ty <= y1; ty++) {\n if (isSolidTile(grid, tx, ty)) return (tx + 1) * ts + grid.bodyHalfWidth + COLLISION_EPSILON;\n }\n }\n return nx;\n}\n\n/** Moves along Y by dy, stopping flush against the first solid tile row. */\nexport function moveY(grid: CollisionGrid, x: number, y: number, dy: number): number {\n if (dy === 0) return y;\n const ts = grid.tileSize;\n const ny = y + dy;\n const x0 = Math.floor((x - grid.bodyHalfWidth) / ts);\n const x1 = Math.floor((x + grid.bodyHalfWidth) / ts);\n if (dy > 0) {\n const ty = Math.floor((ny + grid.bodyHalfHeight) / ts);\n for (let tx = x0; tx <= x1; tx++) {\n if (isSolidTile(grid, tx, ty)) return ty * ts - grid.bodyHalfHeight - COLLISION_EPSILON;\n }\n } else {\n const ty = Math.floor((ny - grid.bodyHalfHeight) / ts);\n for (let tx = x0; tx <= x1; tx++) {\n if (isSolidTile(grid, tx, ty)) return (ty + 1) * ts + grid.bodyHalfHeight + COLLISION_EPSILON;\n }\n }\n return ny;\n}\n\nfunction clampAxis(v: number): number {\n return v > 0 ? 1 : v < 0 ? -1 : 0;\n}\n\n/** Advances the mover by one fixed input step. Mutates `s`. */\nexport function stepMover(s: MoverState, step: InputStep, p: MovementParams, grid: CollisionGrid): void {\n if (s.dashCd > 0) s.dashCd--;\n\n // A dodge roll is committed: while it runs, input neither steers it nor aims the next one.\n const rolling = s.dashLeft > 0;\n let mx = p.canMove && !rolling ? clampAxis(step[0]) : 0;\n let my = p.canMove && !rolling ? clampAxis(step[1]) : 0;\n if (mx !== 0 && my !== 0) {\n mx = mx * DIAGONAL;\n my = my * DIAGONAL;\n }\n if (mx !== 0 || my !== 0) {\n s.lastDx = mx;\n s.lastDy = my;\n }\n\n if ((step[2] & INPUT_FLAG_DASH) !== 0 && p.canDash && p.canMove && s.dashLeft === 0 && s.dashCd === 0) {\n s.dashLeft = p.dashSteps;\n s.dashCd = p.dashCooldownSteps;\n s.dashDx = s.lastDx;\n s.dashDy = s.lastDy;\n }\n\n let vx: number;\n let vy: number;\n if (s.dashLeft > 0) {\n vx = s.dashDx * p.dashSpeed;\n vy = s.dashDy * p.dashSpeed;\n s.dashLeft--;\n } else {\n vx = mx * p.speed;\n vy = my * p.speed;\n }\n\n s.x = moveX(grid, s.x, s.y, vx * INPUT_STEP_DT);\n s.y = moveY(grid, s.x, s.y, vy * INPUT_STEP_DT);\n}\n"],"names":["DIAGONAL","createCollisionGrid","width","height","tileSize","solid","options","bytes","i","ground","over","shotOver","bodyHalfWidth","BODY_HALF_WIDTH","bodyHalfHeight","BODY_HALF_HEIGHT","blocksShot","grid","tx","ty","isSolidTile","createMover","x","y","bodyCollides","ts","x0","x1","y0","y1","moveX","dx","nx","COLLISION_EPSILON","moveY","dy","ny","clampAxis","v","stepMover","s","step","p","rolling","mx","my","INPUT_FLAG_DASH","vx","vy","INPUT_STEP_DT"],"mappings":";AAmBO,MAAMA,IAAW;AAsCjB,SAASC,EAAoBC,GAAeC,GAAgBC,GAAkBC,GAAeC,IAAgC,IAAmB;AACrJ,MAAID,EAAM,WAAWH,IAAQC;AAC3B,UAAM,IAAI,MAAM,2BAA2BE,EAAM,MAAM,OAAOH,CAAK,IAAIC,CAAM,EAAE;AAEjF,QAAMI,IAAQ,IAAI,WAAWL,IAAQC,CAAM;AAC3C,WAASK,IAAI,GAAGA,IAAID,EAAM,QAAQC,IAAK,CAAAD,EAAMC,CAAC,IAAIH,EAAM,WAAWG,CAAC,MAAM,KAAK,IAAI;AACnF,QAAM,EAAE,QAAAC,MAAWH,GACbI,IAAO,IAAI,IAAIJ,EAAQ,iBAAiB,CAAA,CAAE;AAChD,MAAIK;AACJ,MAAIF,KAAUA,EAAO,WAAWF,EAAM,UAAUG,EAAK,MAAM;AACzD,IAAAC,IAAW,IAAI,WAAWJ,EAAM,MAAM;AACtC,aAASC,IAAI,GAAGA,IAAID,EAAM,QAAQC,OAAcA,CAAC,IAAID,EAAMC,CAAC,KAAKE,EAAK,IAAID,EAAOD,CAAC,CAAE,IAAI,IAAI;AAAA,EAC9F;AACA,QAAMI,IAAgBN,EAAQ,iBAAiBO,GACzCC,IAAiBR,EAAQ,kBAAkBS;AACjD,SAAOJ,IAAW,EAAE,OAAAT,GAAO,QAAAC,GAAQ,UAAAC,GAAU,OAAOG,GAAO,UAAAI,GAAU,eAAAC,GAAe,gBAAAE,MAAmB,EAAE,OAAAZ,GAAO,QAAAC,GAAQ,UAAAC,GAAU,OAAOG,GAAO,eAAAK,GAAe,gBAAAE,EAAA;AACjK;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GAAmBzB,GAA2B;AACtG,EAAIuB,EAAE,SAAS,KAAGA,EAAE;AAGpB,QAAMG,IAAUH,EAAE,WAAW;AAC7B,MAAII,IAAKF,EAAE,WAAW,CAACC,IAAUN,EAAUI,EAAK,CAAC,CAAC,IAAI,GAClDI,IAAKH,EAAE,WAAW,CAACC,IAAUN,EAAUI,EAAK,CAAC,CAAC,IAAI;AACtD,EAAIG,MAAO,KAAKC,MAAO,MACrBD,IAAKA,IAAK5C,GACV6C,IAAKA,IAAK7C,KAER4C,MAAO,KAAKC,MAAO,OACrBL,EAAE,SAASI,GACXJ,EAAE,SAASK,KAGRJ,EAAK,CAAC,IAAIK,OAAqB,KAAKJ,EAAE,WAAWA,EAAE,WAAWF,EAAE,aAAa,KAAKA,EAAE,WAAW,MAClGA,EAAE,WAAWE,EAAE,WACfF,EAAE,SAASE,EAAE,mBACbF,EAAE,SAASA,EAAE,QACbA,EAAE,SAASA,EAAE;AAGf,MAAIO,GACAC;AACJ,EAAIR,EAAE,WAAW,KACfO,IAAKP,EAAE,SAASE,EAAE,WAClBM,IAAKR,EAAE,SAASE,EAAE,WAClBF,EAAE,eAEFO,IAAKH,IAAKF,EAAE,OACZM,IAAKH,IAAKH,EAAE,QAGdF,EAAE,IAAIV,EAAMb,GAAMuB,EAAE,GAAGA,EAAE,GAAGO,IAAKE,CAAa,GAC9CT,EAAE,IAAIN,EAAMjB,GAAMuB,EAAE,GAAGA,EAAE,GAAGQ,IAAKC,CAAa;AAChD;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function d(a) {
|
|
2
|
+
return [a.x, a.y, a.lastDx, a.lastDy, a.dashLeft, a.dashCd, a.dashDx, a.dashDy];
|
|
3
|
+
}
|
|
4
|
+
function r(a, s) {
|
|
5
|
+
return [s.x, s.y, s.lastDx, s.lastDy, s.dashLeft, s.dashCd, s.dashDx, s.dashDy] = a, s;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
r as moverFromWire,
|
|
9
|
+
d as moverToWire
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sources":["../../src/net/protocol.ts"],"sourcesContent":["import type { EntityUpdate, InputStep } from './constants';\nimport type { MoverState } from './movement';\n\n/*\n * The engine's netcode messages. JSON, but for snapshots that carry body updates, which travel as one binary frame\n * (`encodeSnapshotFrame`). A game adds its own messages beside these: anything with a `t` the engine does not know\n * is handed to the game untouched.\n */\n\n/** Client → server. */\nexport type ClientMessage =\n /** Asks to join; `data` is the game's own (a name, a character). */\n | { t: 'hello'; data?: unknown }\n /** Input steps `seq`, `seq + 1`, … taken since the last send. */\n | { t: 'input'; seq: number; steps: InputStep[] }\n /** A ping carrying the client's own clock, answered by a pong. */\n | { t: 'ping'; c: number };\n\n/** Server → client. */\nexport type ServerMessage =\n | { t: 'welcome'; id: number; tick: number; stepRate: number; snapRate: number }\n | { t: 'pong'; c: number; st: number }\n | Snapshot;\n\n/** A body's whole mover, so a client can rewind to it exactly: x, y, lastDx, lastDy, dashLeft, dashCd, dashDx, dashDy. */\nexport type MoverWire = [number, number, number, number, number, number, number, number];\n\n/** A body coming into view: its id and the game's own description of it (what it looks like). */\nexport interface SpawnInfo {\n id: number;\n data?: unknown;\n}\n\nexport interface Snapshot {\n t: 'snap';\n /** The server's step count when it was taken. */\n tick: number;\n /** The server's wall time when it was taken (ms since the epoch), for interpolation. */\n time: number;\n /** The last input step of this client the server has applied (-1 before any). */\n ack: number;\n /** This client's own body, whole, as of `ack`. */\n me?: MoverWire;\n /** Bodies that came into view. */\n sp?: SpawnInfo[];\n /** Bodies that left view. */\n rm?: number[];\n /** Every body in view: [id, x, y, aim, anim, hp, flags]. */\n up?: EntityUpdate[];\n}\n\nexport function moverToWire(m: MoverState): MoverWire {\n return [m.x, m.y, m.lastDx, m.lastDy, m.dashLeft, m.dashCd, m.dashDx, m.dashDy];\n}\n\nexport function moverFromWire(w: MoverWire, into: MoverState): MoverState {\n [into.x, into.y, into.lastDx, into.lastDy, into.dashLeft, into.dashCd, into.dashDx, into.dashDy] = w;\n return into;\n}\n"],"names":["moverToWire","m","moverFromWire","w","into"],"mappings":"AAmDO,SAASA,EAAYC,GAA0B;AACpD,SAAO,CAACA,EAAE,GAAGA,EAAE,GAAGA,EAAE,QAAQA,EAAE,QAAQA,EAAE,UAAUA,EAAE,QAAQA,EAAE,QAAQA,EAAE,MAAM;AAChF;AAEO,SAASC,EAAcC,GAAcC,GAA8B;AACxE,UAACA,EAAK,GAAGA,EAAK,GAAGA,EAAK,QAAQA,EAAK,QAAQA,EAAK,UAAUA,EAAK,QAAQA,EAAK,QAAQA,EAAK,MAAM,IAAID,GAC5FC;AACT;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const u = 2e3;
|
|
2
|
+
let n = 0, i = 1 / 0, f = 0, r = !1;
|
|
3
|
+
function S() {
|
|
4
|
+
return Date.now() + n;
|
|
5
|
+
}
|
|
6
|
+
function _() {
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
function c(o, e, t = Date.now()) {
|
|
10
|
+
!Number.isFinite(o) || !Number.isFinite(e) || e < 0 || e > 2e3 || r && e > i && t - f < 6e4 || (n = o + e / 2 - t, i = e, f = t, r = !0);
|
|
11
|
+
}
|
|
12
|
+
function l() {
|
|
13
|
+
n = 0, i = 1 / 0, f = 0, r = !1;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
u as MAX_SAMPLE_RTT_MS,
|
|
17
|
+
c as noteServerTime,
|
|
18
|
+
l as resetServerClock,
|
|
19
|
+
S as serverNow,
|
|
20
|
+
_ as serverOffset
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=serverClock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverClock.js","sources":["../../src/net/serverClock.ts"],"sourcesContent":["/*\n * The server's clock, as this client best knows it. Everything the game reckons from wall time — the time of day,\n * the weather, timetables, daily resets — reads `serverNow()` instead\n * of `Date.now()`, so a phone whose clock is a few minutes off still sees the sky and the resets everyone else sees.\n *\n * The offset comes from timed exchanges: every pong (the server's time when it answered, against the ping's own\n * round trip) and any request that returns the server's time. The sample with the shortest round trip wins, since its\n * midpoint is the tightest guess; a sample older than a minute gives way to the next one so a drifting clock is\n * followed. Until the first one lands this device's own clock stands in (a game clock counting from the server's start must never\n * seed this). An offline game is its own server, so there the offset is zero.\n */\n\n/** A timed sample this old gives way to a new one, even a slower one. */\nconst STALE_MS = 60_000;\n/** A sample whose round trip took longer than this says too little about when the server answered: it is passed over. */\nexport const MAX_SAMPLE_RTT_MS = 2000;\n\nlet offset = 0;\nlet bestRtt = Infinity;\nlet takenAt = 0;\nlet timed = false;\n\n/** Server wall time now, in ms since the epoch. */\nexport function serverNow(): number {\n return Date.now() + offset;\n}\n\n/** The current estimate of server time minus this device's time, in ms. */\nexport function serverOffset(): number {\n return offset;\n}\n\n/**\n * A server timestamp `serverMs` taken halfway through an exchange that took `rttMs` to come back: the server's clock\n * then stood at `serverMs + rttMs / 2` of this device's now.\n */\nexport function noteServerTime(serverMs: number, rttMs: number, now = Date.now()): void {\n if (!Number.isFinite(serverMs) || !Number.isFinite(rttMs) || rttMs < 0 || rttMs > MAX_SAMPLE_RTT_MS) return;\n if (timed && rttMs > bestRtt && now - takenAt < STALE_MS) return;\n offset = serverMs + rttMs / 2 - now;\n bestRtt = rttMs;\n takenAt = now;\n timed = true;\n}\n\n/** Back to this device's own clock (offline, or leaving a server). */\nexport function resetServerClock(): void {\n offset = 0;\n bestRtt = Infinity;\n takenAt = 0;\n timed = false;\n}\n"],"names":["MAX_SAMPLE_RTT_MS","offset","bestRtt","takenAt","timed","serverNow","serverOffset","noteServerTime","serverMs","rttMs","now","resetServerClock"],"mappings":"AAeO,MAAMA,IAAoB;AAEjC,IAAIC,IAAS,GACTC,IAAU,OACVC,IAAU,GACVC,IAAQ;AAGL,SAASC,IAAoB;AAClC,SAAO,KAAK,QAAQJ;AACtB;AAGO,SAASK,IAAuB;AACrC,SAAOL;AACT;AAMO,SAASM,EAAeC,GAAkBC,GAAeC,IAAM,KAAK,OAAa;AACtF,EAAI,CAAC,OAAO,SAASF,CAAQ,KAAK,CAAC,OAAO,SAASC,CAAK,KAAKA,IAAQ,KAAKA,IAAQ,OAC9EL,KAASK,IAAQP,KAAWQ,IAAMP,IAAU,QAChDF,IAASO,IAAWC,IAAQ,IAAIC,GAChCR,IAAUO,GACVN,IAAUO,GACVN,IAAQ;AACV;AAGO,SAASO,IAAyB;AACvC,EAAAV,IAAS,GACTC,IAAU,OACVC,IAAU,GACVC,IAAQ;AACV;"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const h = 1, d = 5, b = 16, M = 8, y = 256, c = Math.PI * 2;
|
|
2
|
+
function E(t, n, r) {
|
|
3
|
+
if (!Number.isFinite(t)) return Number.isNaN(t) ? 0 : t > 0 ? r : n;
|
|
4
|
+
const e = Math.round(t);
|
|
5
|
+
return e < n ? n : e > r ? r : e;
|
|
6
|
+
}
|
|
7
|
+
function s(t) {
|
|
8
|
+
return E(t * 8, -32768, 32767);
|
|
9
|
+
}
|
|
10
|
+
function T(t) {
|
|
11
|
+
return Number.isFinite(t) ? (Math.round(t * 256 / c) % 256 + 256) % 256 : 0;
|
|
12
|
+
}
|
|
13
|
+
function a(t) {
|
|
14
|
+
return (t >= 256 / 2 ? t - 256 : t) * c / 256;
|
|
15
|
+
}
|
|
16
|
+
function i(t, n, r) {
|
|
17
|
+
t.setInt32(n, E(r[0], -2147483648, 2147483647)), t.setInt16(n + 4, s(r[1])), t.setInt16(n + 6, s(r[2])), t.setUint8(n + 8, T(r[3])), t.setUint8(n + 9, E(r[4], 0, 255)), t.setInt32(n + 10, E(r[5], -2147483648, 2147483647)), t.setUint16(n + 14, E(r[6], 0, 65535));
|
|
18
|
+
}
|
|
19
|
+
function D(t, n) {
|
|
20
|
+
return [
|
|
21
|
+
t.getInt32(n),
|
|
22
|
+
t.getInt16(n + 4) / 8,
|
|
23
|
+
t.getInt16(n + 6) / 8,
|
|
24
|
+
a(t.getUint8(n + 8)),
|
|
25
|
+
t.getUint8(n + 9),
|
|
26
|
+
t.getInt32(n + 10),
|
|
27
|
+
t.getUint16(n + 14)
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function N(t) {
|
|
31
|
+
const n = new Uint8Array(t.length * 16), r = new DataView(n.buffer);
|
|
32
|
+
for (let e = 0; e < t.length; e++) i(r, e * 16, t[e]);
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
function u(t) {
|
|
36
|
+
if (t.byteLength % 16 !== 0) throw new Error(`update block of ${t.byteLength} bytes`);
|
|
37
|
+
const n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = [];
|
|
38
|
+
for (let e = 0; e < t.byteLength; e += 16) r.push(D(n, e));
|
|
39
|
+
return r;
|
|
40
|
+
}
|
|
41
|
+
function I(t) {
|
|
42
|
+
const n = new Array(t.length);
|
|
43
|
+
for (let r = 0; r < t.length; r++) {
|
|
44
|
+
const e = t[r];
|
|
45
|
+
n[r] = [
|
|
46
|
+
E(e[0], -2147483648, 2147483647) + 0,
|
|
47
|
+
s(e[1]) / 8 + 0,
|
|
48
|
+
s(e[2]) / 8 + 0,
|
|
49
|
+
a(T(e[3])),
|
|
50
|
+
E(e[4], 0, 255) + 0,
|
|
51
|
+
E(e[5], -2147483648, 2147483647) + 0,
|
|
52
|
+
E(e[6], 0, 65535) + 0
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
return n;
|
|
56
|
+
}
|
|
57
|
+
const P = globalThis, R = new P.TextEncoder(), g = new P.TextDecoder();
|
|
58
|
+
function O(t) {
|
|
59
|
+
const { up: n, ...r } = t, e = R.encode(JSON.stringify(r)), S = n?.length ? n.length : 0, A = new Uint8Array(5 + e.byteLength + S * 16), o = new DataView(A.buffer);
|
|
60
|
+
o.setUint8(0, 1), o.setUint32(1, e.byteLength), A.set(e, 5);
|
|
61
|
+
const U = 5 + e.byteLength;
|
|
62
|
+
for (let _ = 0; _ < S; _++) i(o, U + _ * 16, n[_]);
|
|
63
|
+
return A;
|
|
64
|
+
}
|
|
65
|
+
function f(t) {
|
|
66
|
+
const n = t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
67
|
+
if (n.byteLength < 5) throw new Error("short snapshot frame");
|
|
68
|
+
const r = new DataView(n.buffer, n.byteOffset, n.byteLength), e = r.getUint8(0);
|
|
69
|
+
if (e !== 1) throw new Error(`unknown binary frame tag ${e}`);
|
|
70
|
+
const A = 5 + r.getUint32(1);
|
|
71
|
+
if (A > n.byteLength) throw new Error("snapshot frame JSON overruns the frame");
|
|
72
|
+
const o = JSON.parse(g.decode(n.subarray(5, A)));
|
|
73
|
+
return A < n.byteLength && (o.up = u(n.subarray(A))), o;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
d as SNAP_FRAME_HEADER_BYTES,
|
|
77
|
+
h as SNAP_FRAME_TAG,
|
|
78
|
+
y as UPDATE_AIM_STEPS,
|
|
79
|
+
M as UPDATE_POS_SCALE,
|
|
80
|
+
b as UPDATE_RECORD_BYTES,
|
|
81
|
+
f as decodeSnapshotFrame,
|
|
82
|
+
u as decodeUpdates,
|
|
83
|
+
a as dequantizeAim,
|
|
84
|
+
O as encodeSnapshotFrame,
|
|
85
|
+
N as encodeUpdates,
|
|
86
|
+
T as quantizeAim,
|
|
87
|
+
s as quantizePos,
|
|
88
|
+
I as quantizeUpdates,
|
|
89
|
+
D as readUpdate,
|
|
90
|
+
i as writeUpdate
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=snapshotCodec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotCodec.js","sources":["../../src/net/snapshotCodec.ts"],"sourcesContent":["import type { EntityUpdate } from './constants';\n\n/** Any snapshot whose `up` block travels as binary records; the rest is JSON. */\nexport interface SnapshotLike {\n up?: EntityUpdate[];\n}\n\n/**\n * Binary wire form of a snapshot's `up` block. A server in another language must write the same bytes.\n *\n * A snapshot that carries no updates is still one text frame of JSON. A snapshot that does is one **binary** WebSocket\n * frame, big-endian throughout:\n *\n * ```\n * u8 SNAP_FRAME_TAG\n * u32 L, the byte length of the JSON that follows\n * L UTF-8 JSON of the snapshot with `up` left out\n * n × UPDATE_RECORD_BYTES, one record per EntityUpdate, n = (frame length - 5 - L) / 16\n * ```\n *\n * One record (16 bytes), the `[id, x, y, aim, anim, hp, flags]` tuple:\n *\n * | off | type | field |\n * |-----|-------|------------------------------------------------------------------------------------|\n * | 0 | i32 | id |\n * | 4 | i16 | x in 1/UPDATE_POS_SCALE px, clamped to [-32768, 32767] (−4096 … 4095.875 px) |\n * | 6 | i16 | y, the same |\n * | 8 | u8 | aim in 1/UPDATE_AIM_STEPS of a turn, wrapped; read back in [-π, π) |\n * | 9 | u8 | anim (ANIM), clamped to 0..255 |\n * | 10 | i32 | hp (big bodies go past 65535) |\n * | 14 | u16 | flags (ENTITY_FLAG, nine bits used today), clamped to 0..65535 |\n *\n * Quantisation error: position ≤ 1/16 px, aim ≤ π/256 rad. The position range holds maps up to 4096 px a side.\n * Each record is written once per actor state version on the server and shared by every viewer.\n */\nexport const SNAP_FRAME_TAG = 1;\n/** Tag byte + the u32 JSON length. */\nexport const SNAP_FRAME_HEADER_BYTES = 5;\nexport const UPDATE_RECORD_BYTES = 16;\nexport const UPDATE_POS_SCALE = 8;\nexport const UPDATE_AIM_STEPS = 256;\n\nconst TURN = Math.PI * 2;\n\nfunction clampInt(v: number, lo: number, hi: number): number {\n if (!Number.isFinite(v)) return Number.isNaN(v) ? 0 : v > 0 ? hi : lo;\n const r = Math.round(v);\n return r < lo ? lo : r > hi ? hi : r;\n}\n\n/** World px → the i16 on the wire. */\nexport function quantizePos(v: number): number {\n return clampInt(v * UPDATE_POS_SCALE, -32768, 32767);\n}\n\n/** Radians → the u8 on the wire (wrapped, so any angle is accepted). */\nexport function quantizeAim(a: number): number {\n if (!Number.isFinite(a)) return 0;\n const s = Math.round((a * UPDATE_AIM_STEPS) / TURN);\n return ((s % UPDATE_AIM_STEPS) + UPDATE_AIM_STEPS) % UPDATE_AIM_STEPS;\n}\n\nexport function dequantizeAim(b: number): number {\n return ((b >= UPDATE_AIM_STEPS / 2 ? b - UPDATE_AIM_STEPS : b) * TURN) / UPDATE_AIM_STEPS;\n}\n\nexport function writeUpdate(view: DataView, off: number, u: EntityUpdate): void {\n view.setInt32(off, clampInt(u[0], -0x80000000, 0x7fffffff));\n view.setInt16(off + 4, quantizePos(u[1]));\n view.setInt16(off + 6, quantizePos(u[2]));\n view.setUint8(off + 8, quantizeAim(u[3]));\n view.setUint8(off + 9, clampInt(u[4], 0, 255));\n view.setInt32(off + 10, clampInt(u[5], -0x80000000, 0x7fffffff));\n view.setUint16(off + 14, clampInt(u[6], 0, 0xffff));\n}\n\nexport function readUpdate(view: DataView, off: number): EntityUpdate {\n return [\n view.getInt32(off),\n view.getInt16(off + 4) / UPDATE_POS_SCALE,\n view.getInt16(off + 6) / UPDATE_POS_SCALE,\n dequantizeAim(view.getUint8(off + 8)),\n view.getUint8(off + 9),\n view.getInt32(off + 10),\n view.getUint16(off + 14),\n ];\n}\n\nexport function encodeUpdates(ups: readonly EntityUpdate[]): Uint8Array {\n const out = new Uint8Array(ups.length * UPDATE_RECORD_BYTES);\n const view = new DataView(out.buffer);\n for (let i = 0; i < ups.length; i++) writeUpdate(view, i * UPDATE_RECORD_BYTES, ups[i]!);\n return out;\n}\n\nexport function decodeUpdates(bytes: Uint8Array): EntityUpdate[] {\n if (bytes.byteLength % UPDATE_RECORD_BYTES !== 0) throw new Error(`update block of ${bytes.byteLength} bytes`);\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const out: EntityUpdate[] = [];\n for (let off = 0; off < bytes.byteLength; off += UPDATE_RECORD_BYTES) out.push(readUpdate(view, off));\n return out;\n}\n\n/** The updates exactly as a client reads them off the wire: what a local simulation sends, so it quantises like the server. */\nexport function quantizeUpdates(ups: readonly EntityUpdate[]): EntityUpdate[] {\n // Same numbers as decodeUpdates(encodeUpdates(ups)) without the byte round trip (`+ 0` turns -0 into 0, as a read does).\n const out: EntityUpdate[] = new Array(ups.length);\n for (let i = 0; i < ups.length; i++) {\n const u = ups[i]!;\n out[i] = [\n clampInt(u[0], -0x80000000, 0x7fffffff) + 0,\n quantizePos(u[1]) / UPDATE_POS_SCALE + 0,\n quantizePos(u[2]) / UPDATE_POS_SCALE + 0,\n dequantizeAim(quantizeAim(u[3])),\n clampInt(u[4], 0, 255) + 0,\n clampInt(u[5], -0x80000000, 0x7fffffff) + 0,\n clampInt(u[6], 0, 0xffff) + 0,\n ];\n }\n return out;\n}\n\ninterface TextCodecs {\n TextEncoder: new () => { encode(s: string): Uint8Array };\n TextDecoder: new () => { decode(b: Uint8Array): string };\n}\n// the protocol builds without DOM types; browsers and Node both have these\nconst text = globalThis as unknown as TextCodecs;\nconst encoder = new text.TextEncoder();\nconst decoder = new text.TextDecoder();\n\n/** A snapshot as the server frames it: binary when it carries updates (see the layout above). */\nexport function encodeSnapshotFrame<S extends SnapshotLike>(snap: S): Uint8Array {\n const { up, ...rest } = snap;\n const json = encoder.encode(JSON.stringify(rest));\n const records = up?.length ? up.length : 0;\n const out = new Uint8Array(SNAP_FRAME_HEADER_BYTES + json.byteLength + records * UPDATE_RECORD_BYTES);\n const view = new DataView(out.buffer);\n view.setUint8(0, SNAP_FRAME_TAG);\n view.setUint32(1, json.byteLength);\n out.set(json, SNAP_FRAME_HEADER_BYTES);\n const base = SNAP_FRAME_HEADER_BYTES + json.byteLength;\n for (let i = 0; i < records; i++) writeUpdate(view, base + i * UPDATE_RECORD_BYTES, up![i]!);\n return out;\n}\n\n/** Reads a binary snapshot frame back into the same object a text frame parses to. */\nexport function decodeSnapshotFrame<S extends SnapshotLike>(frame: ArrayBuffer | Uint8Array): S {\n const bytes = frame instanceof Uint8Array ? frame : new Uint8Array(frame);\n if (bytes.byteLength < SNAP_FRAME_HEADER_BYTES) throw new Error('short snapshot frame');\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const tag = view.getUint8(0);\n if (tag !== SNAP_FRAME_TAG) throw new Error(`unknown binary frame tag ${tag}`);\n const len = view.getUint32(1);\n const base = SNAP_FRAME_HEADER_BYTES + len;\n if (base > bytes.byteLength) throw new Error('snapshot frame JSON overruns the frame');\n const snap = JSON.parse(decoder.decode(bytes.subarray(SNAP_FRAME_HEADER_BYTES, base))) as S;\n if (base < bytes.byteLength) snap.up = decodeUpdates(bytes.subarray(base));\n return snap;\n}\n"],"names":["SNAP_FRAME_TAG","SNAP_FRAME_HEADER_BYTES","UPDATE_RECORD_BYTES","UPDATE_POS_SCALE","UPDATE_AIM_STEPS","TURN","clampInt","v","lo","hi","r","quantizePos","quantizeAim","a","dequantizeAim","b","writeUpdate","view","off","u","readUpdate","encodeUpdates","ups","out","i","decodeUpdates","bytes","quantizeUpdates","text","encoder","decoder","encodeSnapshotFrame","snap","up","rest","json","records","base","decodeSnapshotFrame","frame","tag"],"mappings":"AAmCO,MAAMA,IAAiB,GAEjBC,IAA0B,GAC1BC,IAAsB,IACtBC,IAAmB,GACnBC,IAAmB,KAE1BC,IAAO,KAAK,KAAK;AAEvB,SAASC,EAASC,GAAWC,GAAYC,GAAoB;AAC3D,MAAI,CAAC,OAAO,SAASF,CAAC,EAAG,QAAO,OAAO,MAAMA,CAAC,IAAI,IAAIA,IAAI,IAAIE,IAAKD;AACnE,QAAME,IAAI,KAAK,MAAMH,CAAC;AACtB,SAAOG,IAAIF,IAAKA,IAAKE,IAAID,IAAKA,IAAKC;AACrC;AAGO,SAASC,EAAYJ,GAAmB;AAC7C,SAAOD,EAASC,IAAI,GAAkB,QAAQ,KAAK;AACrD;AAGO,SAASK,EAAYC,GAAmB;AAC7C,SAAK,OAAO,SAASA,CAAC,KACZ,KAAK,MAAOA,IAAI,MAAoBR,CAAI,IACrC,MAAoB,OAAoB,MAFrB;AAGlC;AAEO,SA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AAK,aAAaC,IAAU,EAAmB,GAC9FnB,IAAO,IAAI,SAASM,EAAI,MAAM;AACpC,EAAAN,EAAK,SAAS,GAAG,CAAc,GAC/BA,EAAK,UAAU,GAAGkB,EAAK,UAAU,GACjCZ,EAAI,IAAIY,GAAM,CAAuB;AACrC,QAAME,IAAO,IAA0BF,EAAK;AAC5C,WAASX,IAAI,GAAGA,IAAIY,GAASZ,IAAK,CAAAR,EAAYC,GAAMoB,IAAOb,IAAI,IAAqBS,EAAIT,CAAC,CAAE;AAC3F,SAAOD;AACT;AAGO,SAASe,EAA4CC,GAAoC;AAC9F,QAAMb,IAAQa,aAAiB,aAAaA,IAAQ,IAAI,WAAWA,CAAK;AACxE,MAAIb,EAAM,aAAa,EAAyB,OAAM,IAAI,MAAM,sBAAsB;AACtF,QAAMT,IAAO,IAAI,SAASS,EAAM,QAAQA,EAAM,YAAYA,EAAM,UAAU,GACpEc,IAAMvB,EAAK,SAAS,CAAC;AAC3B,MAAIuB,MAAQ,EAAgB,OAAM,IAAI,MAAM,4BAA4BA,CAAG,EAAE;AAE7E,QAAMH,IAAO,IADDpB,EAAK,UAAU,CAAC;AAE5B,MAAIoB,IAAOX,EAAM,WAAY,OAAM,IAAI,MAAM,wCAAwC;AACrF,QAAMM,IAAO,KAAK,MAAMF,EAAQ,OAAOJ,EAAM,SAAS,GAAyBW,CAAI,CAAC,CAAC;AACrF,SAAIA,IAAOX,EAAM,eAAYM,EAAK,KAAKP,EAAcC,EAAM,SAASW,CAAI,CAAC,IAClEL;AACT;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Container as r } from "pixi.js";
|
|
2
|
+
import { ParallaxLayer as s } from "./ParallaxLayer.js";
|
|
3
|
+
class d {
|
|
4
|
+
view = new r({ sortableChildren: !0 });
|
|
5
|
+
list = [];
|
|
6
|
+
constructor(t = {}) {
|
|
7
|
+
this.view.zIndex = t.depth ?? -1e3;
|
|
8
|
+
}
|
|
9
|
+
get layers() {
|
|
10
|
+
return this.list;
|
|
11
|
+
}
|
|
12
|
+
/** Adds a layer (built here from options, or one made before); later layers draw in front unless a `depth` says. */
|
|
13
|
+
add(t) {
|
|
14
|
+
const i = t instanceof s ? t : new s(t);
|
|
15
|
+
return i.depth === void 0 && (i.view.zIndex = this.list.length), this.list.push(i), this.view.addChild(i.view), i;
|
|
16
|
+
}
|
|
17
|
+
/** Takes a layer out and destroys it. */
|
|
18
|
+
remove(t) {
|
|
19
|
+
const i = this.list.indexOf(t);
|
|
20
|
+
i < 0 || (this.list.splice(i, 1), t.destroy());
|
|
21
|
+
}
|
|
22
|
+
update(t, i) {
|
|
23
|
+
for (let e = 0; e < this.list.length; e++) this.list[e].update(t, i);
|
|
24
|
+
}
|
|
25
|
+
destroy() {
|
|
26
|
+
this.list.length = 0, this.view.destroy({ children: !0 });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
d as Parallax
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=Parallax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Parallax.js","sources":["../../src/parallax/Parallax.ts"],"sourcesContent":["import { Container } from 'pixi.js';\nimport { ParallaxLayer, type ParallaxCamera, type ParallaxLayerOptions } from './ParallaxLayer';\n\nexport interface ParallaxOptions {\n /**\n * Where the whole parallax sorts among the world layer's children (its `zIndex`, default -1000): below the level,\n * so every layer stays behind it. A foreground layer (factor above 1) belongs in a second `Parallax` with a depth\n * above the level's.\n */\n depth?: number;\n}\n\n/**\n * Layers of scenery behind (or before) the world, each scrolling at its own share of the camera's speed. Add `view`\n * to the world layer — a scene's `root` — and call `update(camera, dtMs)` once a frame after the camera moved, so\n * the layers sit where this frame's view is:\n *\n * ```ts\n * const sky = new Parallax();\n * sky.add({ texture: clouds, factorX: 0.1, repeatX: true, speedX: -6 });\n * sky.add({ display: hills, factorX: 0.5, factorY: 1 });\n * this.root.addChild(sky.view);\n * // each frame\n * sky.update(stage.cameras.main, dt * 1000);\n * ```\n */\nexport class Parallax {\n readonly view = new Container({ sortableChildren: true });\n private readonly list: ParallaxLayer[] = [];\n\n constructor(options: ParallaxOptions = {}) {\n this.view.zIndex = options.depth ?? -1000;\n }\n\n get layers(): readonly ParallaxLayer[] {\n return this.list;\n }\n\n /** Adds a layer (built here from options, or one made before); later layers draw in front unless a `depth` says. */\n add(layer: ParallaxLayer | ParallaxLayerOptions): ParallaxLayer {\n const made = layer instanceof ParallaxLayer ? layer : new ParallaxLayer(layer);\n if (made.depth === undefined) made.view.zIndex = this.list.length;\n this.list.push(made);\n this.view.addChild(made.view);\n return made;\n }\n\n /** Takes a layer out and destroys it. */\n remove(layer: ParallaxLayer): void {\n const i = this.list.indexOf(layer);\n if (i < 0) return;\n this.list.splice(i, 1);\n layer.destroy();\n }\n\n update(camera: ParallaxCamera, dtMs: number): void {\n for (let i = 0; i < this.list.length; i++) this.list[i]!.update(camera, dtMs);\n }\n\n destroy(): void {\n this.list.length = 0;\n this.view.destroy({ children: true });\n }\n}\n"],"names":["Parallax","Container","options","layer","made","ParallaxLayer","camera","dtMs","i"],"mappings":";;AA0BO,MAAMA,EAAS;AAAA,EACX,OAAO,IAAIC,EAAU,EAAE,kBAAkB,IAAM;AAAA,EACvC,OAAwB,CAAA;AAAA,EAEzC,YAAYC,IAA2B,IAAI;AACzC,SAAK,KAAK,SAASA,EAAQ,SAAS;AAAA,EACtC;AAAA,EAEA,IAAI,SAAmC;AACrC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAIC,GAA4D;AAC9D,UAAMC,IAAOD,aAAiBE,IAAgBF,IAAQ,IAAIE,EAAcF,CAAK;AAC7E,WAAIC,EAAK,UAAU,aAAgB,KAAK,SAAS,KAAK,KAAK,SAC3D,KAAK,KAAK,KAAKA,CAAI,GACnB,KAAK,KAAK,SAASA,EAAK,IAAI,GACrBA;AAAA,EACT;AAAA;AAAA,EAGA,OAAOD,GAA4B;AACjC,UAAM,IAAI,KAAK,KAAK,QAAQA,CAAK;AACjC,IAAI,IAAI,MACR,KAAK,KAAK,OAAO,GAAG,CAAC,GACrBA,EAAM,QAAA;AAAA,EACR;AAAA,EAEA,OAAOG,GAAwBC,GAAoB;AACjD,aAASC,IAAI,GAAGA,IAAI,KAAK,KAAK,QAAQA,IAAK,MAAK,KAAKA,CAAC,EAAG,OAAOF,GAAQC,CAAI;AAAA,EAC9E;AAAA,EAEA,UAAgB;AACd,SAAK,KAAK,SAAS,GACnB,KAAK,KAAK,QAAQ,EAAE,UAAU,IAAM;AAAA,EACtC;AACF;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Container as u, TilingSprite as X, Sprite as Y } from "pixi.js";
|
|
2
|
+
import { wrap as f, placeAxis as a } from "./parallaxMath.js";
|
|
3
|
+
class g {
|
|
4
|
+
view = new u();
|
|
5
|
+
factorX;
|
|
6
|
+
factorY;
|
|
7
|
+
offsetX;
|
|
8
|
+
offsetY;
|
|
9
|
+
speedX;
|
|
10
|
+
speedY;
|
|
11
|
+
snap;
|
|
12
|
+
cull;
|
|
13
|
+
/** The depth it was given, if any (a `Parallax` numbers the others in the order they were added). */
|
|
14
|
+
depth;
|
|
15
|
+
repeatX;
|
|
16
|
+
repeatY;
|
|
17
|
+
tiling = null;
|
|
18
|
+
tileW = 0;
|
|
19
|
+
tileH = 0;
|
|
20
|
+
/** The content's local bounds, measured once: reading bounds every frame walks the whole display tree. */
|
|
21
|
+
boundsX = 0;
|
|
22
|
+
boundsY = 0;
|
|
23
|
+
boundsW = 0;
|
|
24
|
+
boundsH = 0;
|
|
25
|
+
driftX = 0;
|
|
26
|
+
driftY = 0;
|
|
27
|
+
// scratch, so a frame allocates nothing
|
|
28
|
+
input = { scroll: 0, view: 0, factor: 0, offset: 0, repeat: !1, tile: 0, contentStart: 0, contentSize: 0, snap: !1 };
|
|
29
|
+
px = { position: 0, size: 0, phase: 0, visible: !0 };
|
|
30
|
+
py = { position: 0, size: 0, phase: 0, visible: !0 };
|
|
31
|
+
constructor(t) {
|
|
32
|
+
const { texture: e, display: s } = t;
|
|
33
|
+
if (!e == !s) throw new Error("ParallaxLayer: give exactly one of `texture` and `display`");
|
|
34
|
+
this.factorX = t.factorX ?? 0.5, this.factorY = t.factorY ?? this.factorX, this.offsetX = t.offsetX ?? 0, this.offsetY = t.offsetY ?? 0, this.speedX = t.speedX ?? 0, this.speedY = t.speedY ?? 0, this.snap = t.snap, this.cull = t.cull ?? !0, this.repeatX = e !== void 0 && t.repeatX === !0, this.repeatY = e !== void 0 && t.repeatY === !0, this.depth = t.depth, t.depth !== void 0 && (this.view.zIndex = t.depth), e ? (this.tileW = e.width, this.tileH = e.height, this.repeatX || this.repeatY ? (this.tiling = new X({ texture: e, width: e.width, height: e.height }), this.view.addChild(this.tiling)) : this.view.addChild(new Y(e))) : s && this.view.addChild(s), this.remeasure();
|
|
35
|
+
}
|
|
36
|
+
/** Measures the content again, after it was redrawn larger or smaller (culling reads the measured size). */
|
|
37
|
+
remeasure() {
|
|
38
|
+
if (this.tiling) {
|
|
39
|
+
this.boundsX = 0, this.boundsY = 0, this.boundsW = this.tileW, this.boundsH = this.tileH;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const t = this.view.getLocalBounds();
|
|
43
|
+
this.boundsX = t.x, this.boundsY = t.y, this.boundsW = t.width, this.boundsH = t.height;
|
|
44
|
+
}
|
|
45
|
+
/** Places the layer for this frame; `dtMs` advances the drift. */
|
|
46
|
+
update(t, e) {
|
|
47
|
+
const s = e / 1e3;
|
|
48
|
+
this.driftX += this.speedX * s, this.driftY += this.speedY * s, this.repeatX && (this.driftX = f(this.driftX, this.tileW)), this.repeatY && (this.driftY = f(this.driftY, this.tileH));
|
|
49
|
+
const p = this.snap ?? t.roundPixels === !0, d = t.zoom > 0 ? t.zoom : 1, i = this.input;
|
|
50
|
+
i.snap = p, i.scroll = t.scrollX, i.view = t.width / d, i.factor = this.factorX, i.offset = this.offsetX + this.driftX, i.repeat = this.repeatX, i.tile = this.tileW, i.contentStart = this.boundsX, i.contentSize = this.boundsW;
|
|
51
|
+
const r = a(this.px, i);
|
|
52
|
+
i.scroll = t.scrollY, i.view = t.height / d, i.factor = this.factorY, i.offset = this.offsetY + this.driftY, i.repeat = this.repeatY, i.tile = this.tileH, i.contentStart = this.boundsY, i.contentSize = this.boundsH;
|
|
53
|
+
const o = a(this.py, i);
|
|
54
|
+
this.view.position.set(r.position, o.position);
|
|
55
|
+
const h = this.tiling;
|
|
56
|
+
if (h) {
|
|
57
|
+
const l = this.repeatX ? r.size : this.tileW, n = this.repeatY ? o.size : this.tileH;
|
|
58
|
+
(h.width !== l || h.height !== n) && h.setSize(l, n), h.tilePosition.set(r.phase, o.phase);
|
|
59
|
+
}
|
|
60
|
+
const c = t.width > 0 && t.height > 0;
|
|
61
|
+
this.view.visible = !this.cull || !c || r.visible && o.visible;
|
|
62
|
+
}
|
|
63
|
+
destroy() {
|
|
64
|
+
this.view.destroy({ children: !0 });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
g as ParallaxLayer
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=ParallaxLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParallaxLayer.js","sources":["../../src/parallax/ParallaxLayer.ts"],"sourcesContent":["import { Container, Sprite, TilingSprite, type Texture } from 'pixi.js';\nimport { placeAxis, wrap, type AxisInput, type AxisPlacement } from './parallaxMath';\n\n/** What a parallax layer reads off the camera each frame; the engine's `Camera` has all of it. */\nexport interface ParallaxCamera {\n readonly scrollX: number;\n readonly scrollY: number;\n readonly width: number;\n readonly height: number;\n readonly zoom: number;\n /** Set on a pixel-perfect engine: a layer then lands on whole world pixels unless told otherwise. */\n readonly roundPixels?: boolean;\n}\n\nexport interface ParallaxLayerOptions {\n /**\n * A texture to draw, repeated along the axes `repeatX` / `repeatY` name (one tiling sprite, as wide as the view\n * whatever the level's length). Give either this or `display`.\n */\n texture?: Texture;\n /** Anything already drawn (a sprite, a `Graphics`, a container of them), drawn once and never repeated. */\n display?: Container;\n /** Share of the camera's horizontal travel the layer moves on screen: 0 fixed to the screen, 1 with the world (default 0.5). */\n factorX?: number;\n /** The same vertically (default: `factorX`). */\n factorY?: number;\n /** Repeat the texture left and right forever (a `texture` layer only). */\n repeatX?: boolean;\n /** Repeat the texture up and down forever (a `texture` layer only). */\n repeatY?: boolean;\n /** World px added to the layer's position, e.g. where on the level a row of hills stands. */\n offsetX?: number;\n offsetY?: number;\n /** Drift, world px a second, on top of the parallax (clouds). */\n speedX?: number;\n speedY?: number;\n /** Land on whole world pixels (default: the camera's `roundPixels`, i.e. a pixel-perfect engine). */\n snap?: boolean;\n /** Hide the layer while none of it is in view (default true). Repeated layers always fill the view. */\n cull?: boolean;\n /** Order among the parallax's layers: lower draws further back (default: the order they were added in). */\n depth?: number;\n}\n\n/**\n * One layer of a `Parallax`: a texture or a display object that scrolls at a share of the camera's speed, optionally\n * repeated and drifting. `view` goes into the world layer (the parallax adds it), so the camera's zoom and pixel\n * rounding apply to it like to any world object; the layer only moves it.\n */\nexport class ParallaxLayer {\n readonly view = new Container();\n factorX: number;\n factorY: number;\n offsetX: number;\n offsetY: number;\n speedX: number;\n speedY: number;\n snap: boolean | undefined;\n cull: boolean;\n /** The depth it was given, if any (a `Parallax` numbers the others in the order they were added). */\n readonly depth: number | undefined;\n private readonly repeatX: boolean;\n private readonly repeatY: boolean;\n private readonly tiling: TilingSprite | null = null;\n private readonly tileW: number = 0;\n private readonly tileH: number = 0;\n /** The content's local bounds, measured once: reading bounds every frame walks the whole display tree. */\n private boundsX = 0;\n private boundsY = 0;\n private boundsW = 0;\n private boundsH = 0;\n private driftX = 0;\n private driftY = 0;\n // scratch, so a frame allocates nothing\n private readonly input: AxisInput = { scroll: 0, view: 0, factor: 0, offset: 0, repeat: false, tile: 0, contentStart: 0, contentSize: 0, snap: false };\n private readonly px: AxisPlacement = { position: 0, size: 0, phase: 0, visible: true };\n private readonly py: AxisPlacement = { position: 0, size: 0, phase: 0, visible: true };\n\n constructor(options: ParallaxLayerOptions) {\n const { texture, display } = options;\n if (!texture === !display) throw new Error('ParallaxLayer: give exactly one of `texture` and `display`');\n this.factorX = options.factorX ?? 0.5;\n this.factorY = options.factorY ?? this.factorX;\n this.offsetX = options.offsetX ?? 0;\n this.offsetY = options.offsetY ?? 0;\n this.speedX = options.speedX ?? 0;\n this.speedY = options.speedY ?? 0;\n this.snap = options.snap;\n this.cull = options.cull ?? true;\n this.repeatX = texture !== undefined && options.repeatX === true;\n this.repeatY = texture !== undefined && options.repeatY === true;\n this.depth = options.depth;\n if (options.depth !== undefined) this.view.zIndex = options.depth;\n if (texture) {\n this.tileW = texture.width;\n this.tileH = texture.height;\n if (this.repeatX || this.repeatY) {\n this.tiling = new TilingSprite({ texture, width: texture.width, height: texture.height });\n this.view.addChild(this.tiling);\n } else this.view.addChild(new Sprite(texture));\n } else if (display) this.view.addChild(display);\n this.remeasure();\n }\n\n /** Measures the content again, after it was redrawn larger or smaller (culling reads the measured size). */\n remeasure(): void {\n if (this.tiling) {\n this.boundsX = 0;\n this.boundsY = 0;\n this.boundsW = this.tileW;\n this.boundsH = this.tileH;\n return;\n }\n const b = this.view.getLocalBounds();\n this.boundsX = b.x;\n this.boundsY = b.y;\n this.boundsW = b.width;\n this.boundsH = b.height;\n }\n\n /** Places the layer for this frame; `dtMs` advances the drift. */\n update(camera: ParallaxCamera, dtMs: number): void {\n const seconds = dtMs / 1000;\n this.driftX += this.speedX * seconds;\n this.driftY += this.speedY * seconds;\n // a repeating drift only matters within one tile: kept there, it never grows until the floats lose pixels\n if (this.repeatX) this.driftX = wrap(this.driftX, this.tileW);\n if (this.repeatY) this.driftY = wrap(this.driftY, this.tileH);\n const snap = this.snap ?? camera.roundPixels === true;\n const zoom = camera.zoom > 0 ? camera.zoom : 1;\n const a = this.input;\n a.snap = snap;\n a.scroll = camera.scrollX;\n a.view = camera.width / zoom;\n a.factor = this.factorX;\n a.offset = this.offsetX + this.driftX;\n a.repeat = this.repeatX;\n a.tile = this.tileW;\n a.contentStart = this.boundsX;\n a.contentSize = this.boundsW;\n const x = placeAxis(this.px, a);\n a.scroll = camera.scrollY;\n a.view = camera.height / zoom;\n a.factor = this.factorY;\n a.offset = this.offsetY + this.driftY;\n a.repeat = this.repeatY;\n a.tile = this.tileH;\n a.contentStart = this.boundsY;\n a.contentSize = this.boundsH;\n const y = placeAxis(this.py, a);\n this.view.position.set(x.position, y.position);\n const tiling = this.tiling;\n if (tiling) {\n const w = this.repeatX ? x.size : this.tileW;\n const h = this.repeatY ? y.size : this.tileH;\n // resized only when the view's size changed: a resize marks the sprite's geometry dirty for the renderer\n if (tiling.width !== w || tiling.height !== h) tiling.setSize(w, h);\n tiling.tilePosition.set(x.phase, y.phase);\n }\n // a camera that has no size yet (before the first resize) shows everything rather than nothing\n const sized = camera.width > 0 && camera.height > 0;\n this.view.visible = !this.cull || !sized || (x.visible && y.visible);\n }\n\n destroy(): void {\n this.view.destroy({ children: true });\n }\n}\n"],"names":["ParallaxLayer","Container","options","texture","display","TilingSprite","Sprite","b","camera","dtMs","seconds","wrap","snap","zoom","a","x","placeAxis","y","tiling","w","h","sized"],"mappings":";;AAiDO,MAAMA,EAAc;AAAA,EAChB,OAAO,IAAIC,EAAA;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAES;AAAA,EACQ;AAAA,EACA;AAAA,EACA,SAA8B;AAAA,EAC9B,QAAgB;AAAA,EAChB,QAAgB;AAAA;AAAA,EAEzB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA;AAAA,EAEA,QAAmB,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,IAAO,MAAM,GAAG,cAAc,GAAG,aAAa,GAAG,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IAAI,KAAK,UAAUH,EAAE,OAAO,KAAK;AAEvC,OAAIC,EAAO,UAAUC,KAAKD,EAAO,WAAWE,MAAGF,EAAO,QAAQC,GAAGC,CAAC,GAClEF,EAAO,aAAa,IAAIH,EAAE,OAAOE,EAAE,KAAK;AAAA,IAC1C;AAEA,UAAMI,IAAQb,EAAO,QAAQ,KAAKA,EAAO,SAAS;AAClD,SAAK,KAAK,UAAU,CAAC,KAAK,QAAQ,CAACa,KAAUN,EAAE,WAAWE,EAAE;AAAA,EAC9D;AAAA,EAEA,UAAgB;AACd,SAAK,KAAK,QAAQ,EAAE,UAAU,IAAM;AAAA,EACtC;AACF;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function l(n, e, i = 0) {
|
|
2
|
+
return n * (1 - e) + i;
|
|
3
|
+
}
|
|
4
|
+
function s(n, e) {
|
|
5
|
+
if (!(e > 0)) return 0;
|
|
6
|
+
const i = n % e;
|
|
7
|
+
return i < 0 ? i + e : i + 0;
|
|
8
|
+
}
|
|
9
|
+
function c(n, e, i, r, t = 0) {
|
|
10
|
+
return n < i + r + t && n + e > i - t;
|
|
11
|
+
}
|
|
12
|
+
function o(n, e) {
|
|
13
|
+
let i = l(e.scroll, e.factor, e.offset);
|
|
14
|
+
if (e.snap && (i = Math.round(i)), e.repeat && e.tile > 0) {
|
|
15
|
+
const r = e.snap ? Math.floor(e.scroll) : e.scroll;
|
|
16
|
+
n.position = r, n.size = Math.ceil(e.view) + 1, n.phase = s(i - r, e.tile), n.visible = !0;
|
|
17
|
+
} else
|
|
18
|
+
n.position = i, n.size = e.contentSize, n.phase = 0, n.visible = c(i + e.contentStart, e.contentSize, e.scroll, e.view);
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
l as parallaxOrigin,
|
|
23
|
+
o as placeAxis,
|
|
24
|
+
c as spanVisible,
|
|
25
|
+
s as wrap
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=parallaxMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallaxMath.js","sources":["../../src/parallax/parallaxMath.ts"],"sourcesContent":["/**\n * The arithmetic of parallax, apart from anything that draws so it can be tested under node. One axis at a time:\n * the same functions serve x and y.\n */\n\n/**\n * The world position a layer is drawn at so that, on screen, it moves `factor` times as far as the camera: 0 stays\n * fixed to the screen (a sky at infinity), 1 moves with the world, 0.5 at half speed, above 1 faster (a foreground).\n * The layer lives in the world layer, so the camera's zoom scales it like everything else.\n */\nexport function parallaxOrigin(scroll: number, factor: number, offset = 0): number {\n return scroll * (1 - factor) + offset;\n}\n\n/** `value` brought into [0, size): where a repeating pattern stands within one tile. 0 for an empty tile. */\nexport function wrap(value: number, size: number): number {\n if (!(size > 0)) return 0;\n const r = value % size;\n // `+ 0` turns the -0 a negative multiple leaves into 0, which a tile position compares equal to anyway\n return r < 0 ? r + size : r + 0;\n}\n\n/** Whether a span [start, start + size) overlaps the view [viewStart, viewStart + viewSize), `margin` px wider. */\nexport function spanVisible(start: number, size: number, viewStart: number, viewSize: number, margin = 0): boolean {\n return start < viewStart + viewSize + margin && start + size > viewStart - margin;\n}\n\n/** Where one axis of a layer goes this frame; written into a caller's object so a frame allocates nothing. */\nexport interface AxisPlacement {\n /** The layer's world position on this axis. */\n position: number;\n /** For a repeated axis, how long the tiled strip is (it covers the view); otherwise the content's own size. */\n size: number;\n /** For a repeated axis, the pattern's offset inside the strip (a tiling sprite's tile position), in [0, tile). */\n phase: number;\n /** For an axis that does not repeat, whether the content reaches into the view at all. */\n visible: boolean;\n}\n\nexport interface AxisInput {\n /** The camera's scroll on this axis (the world coordinate at the screen's edge). */\n scroll: number;\n /** How much of the world the view shows on this axis: the screen's size over the camera's zoom. */\n view: number;\n factor: number;\n /** Fixed offset plus whatever auto-scroll has added. */\n offset: number;\n repeat: boolean;\n /** One tile's size on this axis (repeated axes). */\n tile: number;\n /** Where the content's bounds begin from the layer's position, and how long they are (axes that do not repeat). */\n contentStart: number;\n contentSize: number;\n /** Land on whole world pixels. */\n snap: boolean;\n}\n\n/**\n * Places one axis. A repeated axis is a strip laid over the view, starting at the view's edge (floored to a whole\n * pixel when snapping), whose pattern is shifted so its tiles stand where the parallax puts them: the strip never\n * grows with the level, however long it is. An axis that does not repeat sits at its parallax origin and is visible\n * only while its content overlaps the view.\n */\nexport function placeAxis(out: AxisPlacement, a: AxisInput): AxisPlacement {\n let origin = parallaxOrigin(a.scroll, a.factor, a.offset);\n if (a.snap) origin = Math.round(origin);\n if (a.repeat && a.tile > 0) {\n const start = a.snap ? Math.floor(a.scroll) : a.scroll;\n out.position = start;\n // one pixel more than the view, for the part of a pixel the floor gave back\n out.size = Math.ceil(a.view) + 1;\n out.phase = wrap(origin - start, a.tile);\n out.visible = true;\n } else {\n out.position = origin;\n out.size = a.contentSize;\n out.phase = 0;\n out.visible = spanVisible(origin + a.contentStart, a.contentSize, a.scroll, a.view);\n }\n return out;\n}\n"],"names":["parallaxOrigin","scroll","factor","offset","wrap","value","size","r","spanVisible","start","viewStart","viewSize","margin","placeAxis","out","a","origin"],"mappings":"AAUO,SAASA,EAAeC,GAAgBC,GAAgBC,IAAS,GAAW;AACjF,SAAOF,KAAU,IAAIC,KAAUC;AACjC;AAGO,SAASC,EAAKC,GAAeC,GAAsB;AACxD,MAAI,EAAEA,IAAO,GAAI,QAAO;AACxB,QAAMC,IAAIF,IAAQC;AAElB,SAAOC,IAAI,IAAIA,IAAID,IAAOC,IAAI;AAChC;AAGO,SAASC,EAAYC,GAAeH,GAAcI,GAAmBC,GAAkBC,IAAS,GAAY;AACjH,SAAOH,IAAQC,IAAYC,IAAWC,KAAUH,IAAQH,IAAOI,IAAYE;AAC7E;AAsCO,SAASC,EAAUC,GAAoBC,GAA6B;AACzE,MAAIC,IAAShB,EAAee,EAAE,QAAQA,EAAE,QAAQA,EAAE,MAAM;AAExD,MADIA,EAAE,SAAMC,IAAS,KAAK,MAAMA,CAAM,IAClCD,EAAE,UAAUA,EAAE,OAAO,GAAG;AAC1B,UAAMN,IAAQM,EAAE,OAAO,KAAK,MAAMA,EAAE,MAAM,IAAIA,EAAE;AAChD,IAAAD,EAAI,WAAWL,GAEfK,EAAI,OAAO,KAAK,KAAKC,EAAE,IAAI,IAAI,GAC/BD,EAAI,QAAQV,EAAKY,IAASP,GAAOM,EAAE,IAAI,GACvCD,EAAI,UAAU;AAAA,EAChB;AACE,IAAAA,EAAI,WAAWE,GACfF,EAAI,OAAOC,EAAE,aACbD,EAAI,QAAQ,GACZA,EAAI,UAAUN,EAAYQ,IAASD,EAAE,cAAcA,EAAE,aAAaA,EAAE,QAAQA,EAAE,IAAI;AAEpF,SAAOD;AACT;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ParticleContainer as M, Particle as b } from "pixi.js";
|
|
2
|
+
import { engineSettings as P } from "../settings.js";
|
|
3
|
+
import { inView as v } from "../fx/viewCull.js";
|
|
4
|
+
import { particleBudget as C } from "./ParticleBudget.js";
|
|
5
|
+
import { ParticleSim as I } from "./ParticleSim.js";
|
|
6
|
+
import { sampleCurve as w, sampleColor as S } from "./particleCurves.js";
|
|
7
|
+
import { scaleCount as z, dueParticles as F, spreadAngle as X, sampleRange as y } from "./particleSampling.js";
|
|
8
|
+
class R {
|
|
9
|
+
view;
|
|
10
|
+
x = 0;
|
|
11
|
+
y = 0;
|
|
12
|
+
/** Continuous emission on or off (bursts work either way). */
|
|
13
|
+
emitting = !1;
|
|
14
|
+
sim;
|
|
15
|
+
pool = [];
|
|
16
|
+
budget;
|
|
17
|
+
random;
|
|
18
|
+
opts;
|
|
19
|
+
carry = 0;
|
|
20
|
+
destroyed = !1;
|
|
21
|
+
/** Set by the last `update`: whether the emitter's point was near the screen. */
|
|
22
|
+
near = !0;
|
|
23
|
+
constructor(t) {
|
|
24
|
+
this.opts = t, this.sim = new I(t.capacity ?? 256), this.budget = t.budget ?? C, this.random = t.random ?? Math.random, this.view = new M({
|
|
25
|
+
texture: t.texture,
|
|
26
|
+
dynamicProperties: { position: !0, rotation: !0, vertex: !0, color: !0, uvs: !1 }
|
|
27
|
+
}), this.view.blendMode = t.blend === "add" ? "add" : "normal";
|
|
28
|
+
}
|
|
29
|
+
/** Particles alive now. */
|
|
30
|
+
get live() {
|
|
31
|
+
return this.sim.count;
|
|
32
|
+
}
|
|
33
|
+
setPosition(t, n) {
|
|
34
|
+
return this.x = t, this.y = n, this;
|
|
35
|
+
}
|
|
36
|
+
start() {
|
|
37
|
+
return this.emitting = !0, this;
|
|
38
|
+
}
|
|
39
|
+
/** Stops emitting; the particles in the air live out their lives. */
|
|
40
|
+
stop() {
|
|
41
|
+
return this.emitting = !1, this.carry = 0, this;
|
|
42
|
+
}
|
|
43
|
+
/** `count` particles at once, at the emitter or at (x, y). Thinned under reduced effects; skipped off screen. */
|
|
44
|
+
burst(t, n = this.x, s = this.y) {
|
|
45
|
+
this.destroyed || !this.near || this.emit(z(t, this.thin(), this.random()), n, s);
|
|
46
|
+
}
|
|
47
|
+
/** Advances by `dt` seconds. Pass the camera to skip spawning and drawing while everything is off screen. */
|
|
48
|
+
update(t, n) {
|
|
49
|
+
if (this.destroyed) return;
|
|
50
|
+
const s = this.opts.cullMargin ?? 64;
|
|
51
|
+
this.near = n ? v(n, this.x, this.y, s) : !0;
|
|
52
|
+
const e = this.opts.rate ?? 0;
|
|
53
|
+
if (this.emitting && e > 0 && this.near) {
|
|
54
|
+
const i = F(e * this.thin(), t, this.carry), d = Math.floor(i);
|
|
55
|
+
this.carry = i - d, d > 0 && this.emit(d, this.x, this.y);
|
|
56
|
+
} else this.carry = 0;
|
|
57
|
+
const a = this.opts, r = this.sim.step(t, a.gravityX ?? 0, a.gravityY ?? 0, a.drag ?? 0);
|
|
58
|
+
r > 0 && this.budget.give(r), this.draw(n, s);
|
|
59
|
+
}
|
|
60
|
+
/** Every particle gone at once (a scene change, a cancelled effect). */
|
|
61
|
+
clear() {
|
|
62
|
+
this.budget.give(this.sim.clear()), this.draw(void 0, 0);
|
|
63
|
+
}
|
|
64
|
+
destroy() {
|
|
65
|
+
this.destroyed || (this.clear(), this.destroyed = !0, this.pool.length = 0, this.view.destroy());
|
|
66
|
+
}
|
|
67
|
+
thin() {
|
|
68
|
+
const t = P.getState();
|
|
69
|
+
return t.reducedFx || t.batterySaver ? this.opts.thinFactor ?? 0.35 : 1;
|
|
70
|
+
}
|
|
71
|
+
emit(t, n, s) {
|
|
72
|
+
const e = this.sim, a = this.budget.take(Math.min(t, e.capacity - e.count)), r = this.opts, i = this.random, d = r.angle ?? -Math.PI / 2, f = r.spread ?? Math.PI;
|
|
73
|
+
for (let l = 0; l < a; l++) {
|
|
74
|
+
let o = n, h = s;
|
|
75
|
+
const c = r.area;
|
|
76
|
+
if (c && "radius" in c) {
|
|
77
|
+
const g = Math.sqrt(i()) * c.radius, u = i() * Math.PI * 2;
|
|
78
|
+
o += Math.cos(u) * g, h += Math.sin(u) * g;
|
|
79
|
+
} else c && (o += (i() - 0.5) * c.width, h += (i() - 0.5) * c.height);
|
|
80
|
+
const p = X(d, f, i()), m = y(r.speed ?? [40, 80], i());
|
|
81
|
+
e.spawn(o, h, Math.cos(p) * m, Math.sin(p) * m, y(r.lifetime ?? 1, i()), y(r.rotation ?? 0, i()), y(r.spin ?? 0, i()), i());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
draw(t, n) {
|
|
85
|
+
const s = this.sim, e = this.view.particleChildren;
|
|
86
|
+
if (e.length !== s.count) {
|
|
87
|
+
for (; e.length < s.count; ) e.push(this.pool.pop() ?? new b({ texture: this.opts.texture, anchorX: 0.5, anchorY: 0.5 }));
|
|
88
|
+
for (; e.length > s.count; ) this.pool.push(e.pop());
|
|
89
|
+
this.view.update();
|
|
90
|
+
}
|
|
91
|
+
const a = this.opts, r = a.size ?? 1, i = a.alpha ?? Y, d = a.tint ?? 16777215, f = a.sizeVariance ?? 0;
|
|
92
|
+
let l = s.count === 0;
|
|
93
|
+
for (let o = 0; o < s.count; o++) {
|
|
94
|
+
const h = e[o], c = s.progress(o), p = s.x[o], m = s.y[o];
|
|
95
|
+
h.x = p, h.y = m, h.rotation = s.rot[o];
|
|
96
|
+
const g = w(r, c) * (1 + (s.seed[o] * 2 - 1) * f);
|
|
97
|
+
h.scaleX = g, h.scaleY = g;
|
|
98
|
+
const u = S(d, c), x = Math.min(1, Math.max(0, w(i, c)));
|
|
99
|
+
h.color = ((u & 255) << 16 | u & 65280 | u >> 16 & 255) + ((x * 255 | 0) << 24), !l && (!t || v(t, p, m, n)) && (l = !0);
|
|
100
|
+
}
|
|
101
|
+
this.view.visible = l && s.count > 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const Y = { start: 1, end: 0 };
|
|
105
|
+
export {
|
|
106
|
+
R as Emitter
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=Emitter.js.map
|