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":"Darkness.js","sources":["../../src/pixel/Darkness.ts"],"sourcesContent":["import { Container, RenderTexture, Sprite, Texture } from 'pixi.js';\nimport { TILE_SIZE } from '../net/constants';\nimport type { Stage } from '../core/Stage';\nimport { lightRadius, liveLights } from './lights';\nimport { isTouchUi } from '../platform/touch';\n\n/**\n * The dark underground, and the lights that are cut out of it.\n *\n * The obvious way to do this — a black sheet with glowing blobs added on top — is what makes a dungeon look\n * like it is standing in fog: adding light to black gives grey, so the floor inside the \"light\" is a washed-out\n * haze rather than lit stone. What reads as light is the opposite operation. The sheet of night and the lamps\n * are drawn into a texture of their own, the lamps **erasing** the night rather than adding to it, and that\n * texture is laid over the world. Inside a lamp there is simply no night left, so the art underneath shows at\n * its own colour; outside one there is nothing but black. That is the whole trick.\n *\n * It lives in screen space because the hole has to stay under the torch as the camera moves, and a texture the\n * size of the window is far cheaper than one the size of the map.\n */\n/** How often a flicker alone redraws the sheet (≈15 a second): a torch's wobble does not need 60. */\nconst FLICKER_MS = 66;\n/** The least time between two redraws on a phone (≈30 a second, what the phones run at by default). */\nconst PHONE_MS = 33;\n/** World pixels of night drawn past each edge of the window: room for a shake and for a phone's held redraw. */\nconst MARGIN = 8;\n\n/*\n * Lit the way pixel art lights a room: the night is drawn one texel to one **world** pixel, lined up\n * with the camera so its texels sit exactly on the art's pixels, and every light's falloff is a few levels of alpha\n * blended by an ordered (Bayer 4×4) dither in those world pixels — far off a stipple, close a solid fill — instead of\n * a smooth gradient laid over pixel art (which read as fog) or hard rings (which read as a target). A torch's\n * flicker is its radius stepping a whole pixel, not a sprite scaled by fractions.\n */\n\n/** How a light falls off with `d`, a share of its radius: a bright core and a long thinning tail. */\nconst holeAt = (d: number): number => Math.min(1, Math.pow(Math.max(0, 1 - d * d), 1.5) * 1.15);\n/** The colour a light lays on what it lights: strongest at the heart, gone well before its edge. */\nconst washAt = (d: number): number => Math.pow(Math.max(0, 1 - d), 2);\n/** Alpha levels the dither blends between: the hole's and the colour's. */\nconst HOLE_LEVELS = 4;\nconst WASH_LEVELS = 3;\n/** How strongly a light colours what it lights, before the night's own depth weighs it. */\nconst WASH_ALPHA = 0.3;\n/** A light's height over its width: the ground is seen at a slant, so a pool of light is an ellipse. */\nconst SQUASH = 0.85;\n/** A plain light's colour (a lamp nobody named one for, the light a body carries): warm, as flame is. */\nexport const WARM_LIGHT = 0xffc27a;\n\nconst BAYER = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5].map((v) => (v + 0.5) / 16);\n\n/**\n * Radii are painted at every second pixel up to 24 and every eighth above, so a shrinking flash reuses a few textures\n * (each new one is a canvas and an upload; one per pixel made the first flashes hitch).\n */\nconst bucket = (r: number): number => (r <= 24 ? Math.max(2, Math.round(r / 2) * 2) : Math.round(r / 8) * 8);\n/** Every bucket a light can take, painted ahead one per task (`warm`), so no flash pays for its texture. */\nconst BUCKETS = [...new Set(Array.from({ length: 160 }, (_, r) => bucket(r + 1)))];\n/** How often transient lights alone redraw the sheet (≈30 a second): a flash fading needs no more. */\nconst FLASH_MS = 33;\n\nconst textures = new Map<string, Texture>();\n\nlet warming = false;\n\n/** Paints every falloff ahead, one a task, so the first flashes find theirs made. */\nfunction warm(): void {\n if (warming) return;\n warming = true;\n const todo = BUCKETS.flatMap((r) => [['hole', r], ['wash', r]] as const);\n const next = () => {\n const item = todo.shift();\n if (!item) return;\n falloff(item[0], item[1]);\n setTimeout(next, 0);\n };\n setTimeout(next, 0);\n}\n\n/** One falloff at radius `r` world px, one texel a world pixel, dithered in place. */\nfunction falloff(kind: 'hole' | 'wash', r: number): Texture {\n const key = `${kind}${r}`;\n const cached = textures.get(key);\n if (cached) return cached;\n const w = r * 2;\n const h = Math.max(2, Math.round(r * 2 * SQUASH));\n const levels = kind === 'hole' ? HOLE_LEVELS : WASH_LEVELS;\n const curve = kind === 'hole' ? holeAt : washAt;\n const canvas = document.createElement('canvas');\n canvas.width = w;\n canvas.height = h;\n // a browser out of canvas memory (iOS) gives no context: no light this time, and the next asks again\n const ctx = canvas.getContext('2d');\n if (!ctx) return Texture.EMPTY;\n const img = ctx.createImageData(w, h);\n for (let y = 0; y < h; y++)\n for (let x = 0; x < w; x++) {\n const d = Math.hypot((x + 0.5 - w / 2) / r, (y + 0.5 - h / 2) / (r * SQUASH));\n if (d >= 1) continue;\n const v = Math.min(levels, Math.floor(curve(d) * levels + BAYER[(y % 4) * 4 + (x % 4)]!)) / levels;\n const i = (y * w + x) * 4;\n img.data[i] = img.data[i + 1] = img.data[i + 2] = 255;\n img.data[i + 3] = Math.round(v * 255);\n }\n ctx.putImageData(img, 0, 0);\n const texture = Texture.from(canvas);\n texture.source.scaleMode = 'nearest';\n textures.set(key, texture);\n return texture;\n}\n\n/** A light's two marks on the night: the hole it erases, and the colour it lays over what shows through. */\ninterface LightSprites {\n hole: Sprite;\n wash: Sprite;\n}\n\nexport class Darkness {\n private readonly scratch = new Container();\n private readonly sheet: Sprite;\n /** Every hole is erased before any colour is laid, or a later hole would wipe an earlier light's colour away. */\n private readonly holes = new Container();\n private readonly washes = new Container();\n private readonly lamps: { sprites: LightSprites; x: number; y: number; r: number; flicker: number }[] = [];\n /** The transient lights (`lights.ts`), reused frame to frame. */\n private readonly flashes: LightSprites[] = [];\n private rt: RenderTexture;\n /**\n * On the screen layer, laid over the world with its exact transform by the camera (`Camera.follow`), shake included:\n * the night is drawn in world pixels round the unshaken camera and only this layer moves with a shake, so a shaking\n * screen does not redraw the night every frame.\n */\n private readonly layer = new Container();\n private readonly view: Sprite;\n /** The light the player carries: the only one that follows them, and the last one they lose. */\n private readonly carried: LightSprites;\n private readonly unsubscribeResize: () => void;\n /** Lamps that flicker: while one does (or the player carries a light) every frame differs. */\n private flickering = 0;\n /** Something other than the camera changed what the night looks like (a lamp added, dimmed, the window resized). */\n private dirty = true;\n /** What the last drawn frame was drawn from: the texture, the camera's texel and the shade. */\n private drawn = '';\n /** The carried light's place at the last redraw (it follows the body). */\n private carriedAt = '';\n /** When the sheet was last redrawn. */\n private drawnAt = -Infinity;\n /** The world pixel the night's top-left texel stands on. */\n private ox = 0;\n private oy = 0;\n /** The night texture's size in world pixels, and the zoom it was made for. */\n private rtKey = '';\n /** The lamps' colour turned down (`setLampsDimmed`). */\n private dimLamps = false;\n /** A phone redraws the night at most `PHONE_MS` apart, whatever moves (`isTouchUi`). */\n private readonly phone = isTouchUi();\n\n constructor(\n private readonly stage: Stage,\n private color: number,\n private alpha: number,\n ) {\n // a flat sheet of night over the whole window: one white pixel, tinted and stretched\n this.sheet = new Sprite({ texture: Texture.WHITE });\n this.scratch.addChild(this.sheet, this.holes, this.washes);\n this.carried = this.light(0xfff0dc);\n\n this.rt = RenderTexture.create({ width: 1, height: 1 });\n this.view = new Sprite({ texture: this.rt });\n this.layer.addChild(this.view);\n stage.screen.addChild(this.layer);\n stage.cameras.main.follow(this.layer);\n this.unsubscribeResize = stage.onResize(() => (this.dirty = true));\n warm();\n }\n\n /** A hole and its colour, added to the night's layers. */\n private light(color: number): LightSprites {\n const hole = new Sprite({ texture: falloff('hole', 8) });\n hole.blendMode = 'erase';\n this.holes.addChild(hole);\n const wash = new Sprite({ texture: falloff('wash', 8) });\n wash.tint = color;\n this.washes.addChild(wash);\n return { hole, wash };\n }\n\n /** A lamp fixed in the world: a torch on a wall, the seep in its chamber, a crystal in a seam, in its own colour. */\n addLamp(x: number, y: number, radius: number, flicker = 0, color = WARM_LIGHT): void {\n this.lamps.push({ sprites: this.light(color), x, y, r: radius, flicker });\n if (flicker) this.flickering++;\n this.dirty = true;\n }\n\n /**\n * Changes how dark and what colour the sheet is (the outdoor night, `NightShade`, deepens and lifts with the\n * world clock). A sheet with no alpha left is neither drawn nor redrawn, so a map at noon pays nothing for its night.\n */\n setShade(color: number, alpha: number): void {\n this.color = color;\n this.alpha = alpha;\n this.layer.visible = alpha > 0.004;\n }\n\n /**\n * Dimmed lamps lay only `LAMP_DIM` of their colour on the dark (a \"fewer ambient lights\" setting). The holes they\n * cut stay as wide, so a dark place is still seen by them.\n */\n setLampsDimmed(dim: boolean): void {\n if (dim === this.dimLamps) return;\n this.dimLamps = dim;\n this.dirty = true;\n }\n\n /**\n * The night's own texture, one texel a world pixel and `MARGIN` to spare on each side (a shake, or a camera that\n * moved while a phone waits for its next redraw, never shows its edge), remade when the window or the zoom changes:\n * at zoom 2 or 3 it is a quarter or a ninth of the screen's pixels. True when it was remade.\n */\n private fit(w: number, h: number, zoom: number): boolean {\n const tw = Math.ceil(w / zoom) + MARGIN * 2;\n const th = Math.ceil(h / zoom) + MARGIN * 2;\n const key = `${tw},${th},${zoom}`;\n if (key === this.rtKey) return false;\n this.rtKey = key;\n this.rt.destroy(true);\n this.rt = RenderTexture.create({ width: tw, height: th });\n this.rt.source.scaleMode = 'nearest';\n this.view.texture = this.rt;\n return true;\n }\n\n /** Redraws the night with this frame's holes in it, when anything in it changed. `px`/`py` is where the player stands. */\n update(now: number, px: number, py: number, carriedRadius: number): void {\n if (!this.layer.visible) return;\n const cam = this.stage.cameras.main;\n const zoom = cam.zoom || 1;\n const remade = this.fit(this.stage.width, this.stage.height, zoom);\n // the texel grid follows the camera (never its shake) in whole world pixels\n const ox = Math.floor(cam.scrollX) - MARGIN;\n const oy = Math.floor(cam.scrollY) - MARGIN;\n const key = `${ox},${oy},${this.rtKey},${this.color},${this.alpha}`;\n const lights = liveLights(now);\n const carriedAt = carriedRadius > 0 ? `${Math.round(px)},${Math.round(py)},${Math.round(carriedRadius)}` : '';\n // the light a body carries goes where it goes; a fight's flashes fade (`FLASH_MS`), torches wobble (`FLICKER_MS`)\n const since = now - this.drawnAt;\n const due =\n this.dirty ||\n key !== this.drawn ||\n carriedAt !== this.carriedAt ||\n (lights.length > 0 && since >= FLASH_MS) ||\n ((carriedRadius > 0 || this.flickering > 0) && since >= FLICKER_MS);\n if (!due) return;\n // a phone holds every redraw `PHONE_MS` apart (redrawing the night at 60 a second runs it hot); the night stays\n // pinned to the world meanwhile, and only a camera about to show the texture's edge cannot wait\n const edge = Math.abs(ox - this.ox) >= MARGIN - 1 || Math.abs(oy - this.oy) >= MARGIN - 1;\n if (this.phone && since < PHONE_MS && !remade && !edge) return;\n this.dirty = false;\n this.drawn = key;\n this.carriedAt = carriedAt;\n this.drawnAt = now;\n this.ox = ox;\n this.oy = oy;\n this.view.position.set(ox, oy);\n this.sheet.width = this.rt.width;\n this.sheet.height = this.rt.height;\n this.sheet.position.set(0, 0);\n this.sheet.tint = this.color;\n this.sheet.alpha = this.alpha;\n\n // the colour a light lays shows as much as the night is deep: a dungeon's lamps colour their stone fully, a dusk\n // street's only a little\n const wash = WASH_ALPHA * Math.min(1, this.alpha * 1.4);\n if (carriedRadius <= 0) this.hide(this.carried);\n else this.place(this.carried, px, py - 6, carriedRadius * (1 + Math.sin(now / 260) * 0.03 + Math.sin(now / 90) * 0.015), wash * 0.5);\n const lampWash = this.dimLamps ? wash * LAMP_DIM : wash;\n for (const l of this.lamps) {\n // torchlight is never still: each one wobbles on its own phase so a corridor of them does not pulse as one,\n // and its colour breathes with it\n const wobble = l.flicker ? 1 + Math.sin(now / 190 + l.flicker) * 0.05 + Math.sin(now / 71 + l.flicker) * 0.03 : 1;\n this.place(l.sprites, l.x, l.y, l.r * wobble, lampWash * (l.flicker ? 0.9 + (wobble - 1) * 2 : 1));\n }\n while (this.flashes.length < lights.length) this.flashes.push(this.light(WARM_LIGHT));\n for (let i = 0; i < this.flashes.length; i++) {\n const l = lights[i];\n const f = this.flashes[i]!;\n if (!l) {\n this.hide(f);\n continue;\n }\n f.wash.tint = l.color;\n // a flash colours what it lights more than a lamp does: it is the brightest thing in the room for its moment\n this.place(f, l.x, l.y, lightRadius(l, now), Math.min(0.6, wash * 1.6));\n }\n\n this.stage.app.renderer.render({ container: this.scratch, target: this.rt, clear: true });\n }\n\n private hide(l: LightSprites): void {\n l.hole.visible = false;\n l.wash.visible = false;\n }\n\n /** Lays light `l` at world (wx, wy), `r` px across its radius, in the night's world-pixel grid. */\n private place(l: LightSprites, wx: number, wy: number, r: number, wash: number): void {\n const R = bucket(r);\n const cx = Math.round(wx) - this.ox;\n const cy = Math.round(wy) - this.oy;\n // a light wholly off the texture cannot be seen, so it is not drawn\n if (r < 1 || cx < -R || cy < -R || cx > this.rt.width + R || cy > this.rt.height + R) {\n this.hide(l);\n return;\n }\n l.hole.texture = falloff('hole', R);\n l.wash.texture = falloff('wash', R);\n for (const sprite of [l.hole, l.wash]) {\n sprite.visible = true;\n sprite.position.set(cx - R, cy - Math.round(R * SQUASH));\n }\n l.wash.alpha = wash;\n l.wash.visible = wash > 0.01;\n }\n\n destroy(): void {\n this.unsubscribeResize();\n this.stage.cameras.main.unfollow(this.layer);\n this.layer.destroy({ children: true });\n this.rt.destroy(true);\n this.scratch.destroy({ children: true, context: true });\n }\n}\n\n/** What is left of a lamp's glow and colour while lamps are dimmed (`setLampsDimmed`). */\nexport const LAMP_DIM = 0.35;\n\n/** World units of light the player carries underground — about five tiles of certainty in any direction. */\nexport const CARRIED_LIGHT = TILE_SIZE * 5;\n"],"names":["FLICKER_MS","PHONE_MS","MARGIN","holeAt","d","washAt","HOLE_LEVELS","WASH_LEVELS","WASH_ALPHA","SQUASH","WARM_LIGHT","BAYER","v","bucket","r","BUCKETS","_","FLASH_MS","textures","warming","warm","todo","next","item","falloff","kind","key","cached","w","h","levels","curve","canvas","ctx","Texture","img","y","x","i","texture","Darkness","stage","color","alpha","Sprite","RenderTexture","Container","isTouchUi","hole","wash","radius","flicker","dim","zoom","tw","th","now","px","py","carriedRadius","cam","remade","ox","oy","lights","liveLights","carriedAt","since","edge","lampWash","LAMP_DIM","l","wobble","f","lightRadius","wx","wy","R","cx","cy","sprite","CARRIED_LIGHT","TILE_SIZE"],"mappings":";;;;AAoBA,MAAMA,IAAa,IAEbC,IAAW,IAEXC,IAAS,GAWTC,IAAS,CAACC,MAAsB,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,IAAI,GAAG,IAAIA,IAAIA,CAAC,GAAG,GAAG,IAAI,IAAI,GAExFC,IAAS,CAACD,MAAsB,KAAK,IAAI,KAAK,IAAI,GAAG,IAAIA,CAAC,GAAG,CAAC,GAE9DE,IAAc,GACdC,IAAc,GAEdC,IAAa,KAEbC,IAAS,MAEFC,IAAa,UAEpBC,IAAQ,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,GAAG,GAAG,IAAI,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,CAACC,OAAOA,IAAI,OAAO,EAAE,GAMxFC,IAAS,CAACC,MAAuBA,KAAK,KAAK,KAAK,IAAI,GAAG,KAAK,MAAMA,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAMA,IAAI,CAAC,IAAI,GAEpGC,IAAU,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,EAAE,QAAQ,OAAO,CAACC,GAAGF,MAAMD,EAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,GAE3EG,IAAW,IAEXC,wBAAe,IAAA;AAErB,IAAIC,IAAU;AAGd,SAASC,IAAa;AACpB,MAAID,EAAS;AACb,EAAAA,IAAU;AACV,QAAME,IAAON,EAAQ,QAAQ,CAACD,MAAM,CAAC,CAAC,QAAQA,CAAC,GAAG,CAAC,QAAQA,CAAC,CAAC,CAAU,GACjEQ,IAAO,MAAM;AACjB,U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AS,IAAM;AAAA,EACxD;AACF;AAGO,MAAMqB,IAAW,MAGXW,IAAgBC,IAAY;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Sprite as x, Texture as g } from "pixi.js";
|
|
2
|
+
import { vignetteMask as M } from "./vignetteMask.js";
|
|
3
|
+
const o = /* @__PURE__ */ new Map(), k = 12;
|
|
4
|
+
function w(d, t, e = 1, h = 0.55) {
|
|
5
|
+
const i = Math.max(1, Math.ceil(d)), s = Math.max(1, Math.ceil(t)), m = `${i}x${s}|${e.toFixed(2)}|${h}`, l = o.get(m);
|
|
6
|
+
if (l) return l;
|
|
7
|
+
const r = document.createElement("canvas");
|
|
8
|
+
r.width = i, r.height = s;
|
|
9
|
+
const n = r.getContext("2d");
|
|
10
|
+
if (!n) return g.EMPTY;
|
|
11
|
+
const f = M(i, s, e, h), u = n.createImageData(i, s);
|
|
12
|
+
for (let a = 0; a < f.length; a++) f[a] && u.data.fill(255, a * 4, a * 4 + 4);
|
|
13
|
+
n.putImageData(u, 0, 0);
|
|
14
|
+
const c = g.from(r);
|
|
15
|
+
if (c.source.scaleMode = "nearest", o.size >= k) {
|
|
16
|
+
for (const a of o.values()) a.destroy(!0);
|
|
17
|
+
o.clear();
|
|
18
|
+
}
|
|
19
|
+
return o.set(m, c), c;
|
|
20
|
+
}
|
|
21
|
+
class y {
|
|
22
|
+
constructor(t, e = {}) {
|
|
23
|
+
this.stage = t, this.from = e.from ?? 0.55, this.edge.tint = e.color ?? 0, this.edge.visible = !1, t.screen.addChild(this.edge), this.making = setTimeout(() => {
|
|
24
|
+
this.making = null, this.make();
|
|
25
|
+
}, 0);
|
|
26
|
+
}
|
|
27
|
+
stage;
|
|
28
|
+
edge = new x();
|
|
29
|
+
madeFor = "";
|
|
30
|
+
making = null;
|
|
31
|
+
from;
|
|
32
|
+
setColor(t) {
|
|
33
|
+
this.edge.tint = t;
|
|
34
|
+
}
|
|
35
|
+
make() {
|
|
36
|
+
if (this.edge.destroyed) return;
|
|
37
|
+
const t = Math.max(1, this.stage.cameras.main.zoom), e = this.stage.width / t, h = this.stage.height / t, i = `${Math.ceil(e)}x${Math.ceil(h)}`;
|
|
38
|
+
if (i === this.madeFor) return;
|
|
39
|
+
const s = w(e, h, 1, this.from);
|
|
40
|
+
this.edge.texture = s, s !== g.EMPTY && (this.madeFor = i);
|
|
41
|
+
}
|
|
42
|
+
/** Shows the edge at `alpha` (0..1); call each frame it shows. */
|
|
43
|
+
show(t) {
|
|
44
|
+
this.edge.visible = t > 0, this.edge.visible && (this.make(), this.edge.alpha = t, this.edge.width = this.stage.width, this.edge.height = this.stage.height);
|
|
45
|
+
}
|
|
46
|
+
hide() {
|
|
47
|
+
this.edge.visible = !1;
|
|
48
|
+
}
|
|
49
|
+
destroy() {
|
|
50
|
+
this.making && clearTimeout(this.making), this.edge.destroy();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
y as DitherVignette,
|
|
55
|
+
w as ditherVignette
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=DitherVignette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DitherVignette.js","sources":["../../src/pixel/DitherVignette.ts"],"sourcesContent":["import { Sprite, Texture } from 'pixi.js';\nimport type { Stage } from '../core/Stage';\nimport { vignetteMask } from './vignetteMask';\n\nconst CACHE = new Map<string, Texture>();\n/** Each texture is a whole screen's worth of pixels: keep only a few sizes. */\nconst CACHE_MAX = 12;\n\n/**\n * A white dithered edge for a screen of `w`×`h` world pixels, one texel a world pixel and scaled up `'nearest'`;\n * the sprite that draws it tints it. Made once per size and strength. Returns `Texture.EMPTY` when the browser has\n * no canvas memory to spare (iOS), so the caller asks again later.\n */\nexport function ditherVignette(w: number, h: number, strength = 1, from = 0.55): Texture {\n const tw = Math.max(1, Math.ceil(w));\n const th = Math.max(1, Math.ceil(h));\n const key = `${tw}x${th}|${strength.toFixed(2)}|${from}`;\n const hit = CACHE.get(key);\n if (hit) return hit;\n const canvas = document.createElement('canvas');\n canvas.width = tw;\n canvas.height = th;\n const ctx = canvas.getContext('2d');\n if (!ctx) return Texture.EMPTY;\n const mask = vignetteMask(tw, th, strength, from);\n const img = ctx.createImageData(tw, th);\n for (let i = 0; i < mask.length; i++) if (mask[i]) img.data.fill(255, i * 4, i * 4 + 4);\n ctx.putImageData(img, 0, 0);\n const texture = Texture.from(canvas);\n texture.source.scaleMode = 'nearest';\n if (CACHE.size >= CACHE_MAX) {\n for (const t of CACHE.values()) t.destroy(true);\n CACHE.clear();\n }\n CACHE.set(key, texture);\n return texture;\n}\n\nexport interface DitherVignetteOptions {\n /** The edge's colour (default black). */\n color?: number;\n /** How far from the centre toward a corner the edge begins, 0..1 (default 0.55). */\n from?: number;\n}\n\n/**\n * A dithered pixel edge round the screen, on the screen layer: a darkened border, or tinted red and beaten with\n * `heartbeat` while a player is low on health. The texture is made at full strength, off the frame that first needs\n * it (a full-screen dither is a few ms on a phone), and remade only when the window or the zoom changes; `show`\n * changes how much of it shows.\n */\nexport class DitherVignette {\n private readonly edge = new Sprite();\n private madeFor = '';\n private making: ReturnType<typeof setTimeout> | null = null;\n private readonly from: number;\n\n constructor(\n private readonly stage: Stage,\n options: DitherVignetteOptions = {},\n ) {\n this.from = options.from ?? 0.55;\n this.edge.tint = options.color ?? 0x000000;\n this.edge.visible = false;\n stage.screen.addChild(this.edge);\n this.making = setTimeout(() => {\n this.making = null;\n this.make();\n }, 0);\n }\n\n setColor(color: number): void {\n this.edge.tint = color;\n }\n\n private make(): void {\n if (this.edge.destroyed) return;\n const z = Math.max(1, this.stage.cameras.main.zoom);\n const w = this.stage.width / z;\n const h = this.stage.height / z;\n const key = `${Math.ceil(w)}x${Math.ceil(h)}`;\n if (key === this.madeFor) return;\n const tex = ditherVignette(w, h, 1, this.from);\n this.edge.texture = tex;\n // an empty texture leaves the size unmarked, so the next call asks again\n if (tex !== Texture.EMPTY) this.madeFor = key;\n }\n\n /** Shows the edge at `alpha` (0..1); call each frame it shows. */\n show(alpha: number): void {\n this.edge.visible = alpha > 0;\n if (!this.edge.visible) return;\n this.make();\n this.edge.alpha = alpha;\n this.edge.width = this.stage.width;\n this.edge.height = this.stage.height;\n }\n\n hide(): void {\n this.edge.visible = false;\n }\n\n destroy(): void {\n if (this.making) clearTimeout(this.making);\n this.edge.destroy();\n }\n}\n"],"names":["CACHE","CACHE_MAX","ditherVignette","w","h","strength","from","tw","th","key","hit","canvas","ctx","Texture","mask","vignetteMask","img","i","texture","t","DitherVignette","stage","options","Sprite","color","z","tex","alpha"],"mappings":";;AAIA,MAAMA,wBAAY,IAAA,GAEZC,IAAY;AAOX,SAASC,EAAeC,GAAWC,GAAWC,IAAW,GAAGC,IAAO,MAAe;AACvF,QAAMC,IAAK,KAAK,IAAI,GAAG,KAAK,KAAKJ,CAAC,CAAC,GAC7BK,IAAK,KAAK,IAAI,GAAG,KAAK,KAAKJ,CAAC,CAAC,GAC7BK,IAAM,GAAGF,CAAE,IAAIC,CAAE,IAAIH,EAAS,QAAQ,CAAC,CAAC,IAAIC,CAAI,IAChDI,IAAMV,EAAM,IAAIS,CAAG;AACzB,MAAIC,EAAK,QAAOA;AAChB,QAAMC,IAAS,SAAS,cAAc,QAAQ;AAC9C,EAAAA,EAAO,QAAQJ,GACfI,EAAO,SAASH;AAChB,QAAMI,IAAMD,EAAO,WAAW,IAAI;AAClC,MAAI,CAACC,EAAK,QAAOC,EAAQ;AACzB,QAAMC,IAAOC,EAAaR,GAAIC,GAAIH,GAAUC,CAAI,GAC1CU,IAAMJ,EAAI,gBAAgBL,GAAIC,CAAE;AACtC,WAASS,IAAI,GAAGA,IAAIH,EAAK,QAAQG,KAASH,EAAKG,CAAC,KAAGD,EAAI,KAAK,KAAK,KAAKC,IAAI,GAAGA,IAAI,IAAI,CAAC;AACtF,EAAAL,EAAI,aAAaI,GAAK,GAAG,CAAC;AAC1B,QAAME,IAAUL,EAAQ,KAAKF,CAAM;AAEnC,MADAO,EAAQ,OAAO,YA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GAClB,KAAK,KAAK,QAAQ,KAAK,MAAM,OAC7B,KAAK,KAAK,SAAS,KAAK,MAAM;AAAA,EAChC;AAAA,EAEA,OAAa;AACX,SAAK,KAAK,UAAU;AAAA,EACtB;AAAA,EAEA,UAAgB;AACd,IAAI,KAAK,UAAQ,aAAa,KAAK,MAAM,GACzC,KAAK,KAAK,QAAA;AAAA,EACZ;AACF;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { addPixelLayer as E } from "./PixelLayer.js";
|
|
2
|
+
import { engineSettings as P } from "../settings.js";
|
|
3
|
+
import { ramp as I } from "./pixelTone.js";
|
|
4
|
+
const A = 1e3 / 12, _ = 1400, B = 150, D = 420, R = 16, p = { budget: 500, body: 60, big: 160 };
|
|
5
|
+
class G {
|
|
6
|
+
constructor(t, r) {
|
|
7
|
+
this.scene = t, this.track = r;
|
|
8
|
+
}
|
|
9
|
+
scene;
|
|
10
|
+
track;
|
|
11
|
+
clouds = [];
|
|
12
|
+
live = 0;
|
|
13
|
+
play(t, r, n) {
|
|
14
|
+
const m = P.getState(), c = m.reducedFx || m.batterySaver, f = Math.min(t.pixels.length, r ? c ? p.big : D : c ? p.body : B), e = Math.min(f, Math.max(R, (c ? p.budget : _) - this.live));
|
|
15
|
+
if (e <= 0) return;
|
|
16
|
+
const y = Math.max(1, Math.round(Math.abs(t.scaleY))), M = E(this.scene);
|
|
17
|
+
this.track(M);
|
|
18
|
+
const a = {
|
|
19
|
+
g: M,
|
|
20
|
+
x: Math.round(t.x),
|
|
21
|
+
y: Math.round(t.y),
|
|
22
|
+
born: n,
|
|
23
|
+
end: n,
|
|
24
|
+
size: y,
|
|
25
|
+
n: e,
|
|
26
|
+
frame: -1,
|
|
27
|
+
x0: new Float32Array(e),
|
|
28
|
+
y0: new Float32Array(e),
|
|
29
|
+
delay: new Float32Array(e),
|
|
30
|
+
life: new Float32Array(e),
|
|
31
|
+
vx: new Float32Array(e),
|
|
32
|
+
vy: new Float32Array(e),
|
|
33
|
+
phase: new Float32Array(e),
|
|
34
|
+
color: new Uint32Array(e)
|
|
35
|
+
};
|
|
36
|
+
let h = 0, d = -1 / 0, i = 1;
|
|
37
|
+
const o = t.pixels;
|
|
38
|
+
for (let l = 0; l < o.length; l++)
|
|
39
|
+
h = Math.min(h, o.dy[l]), d = Math.max(d, o.dy[l]), i = Math.max(i, Math.abs(o.dx[l] * t.scaleX));
|
|
40
|
+
const x = Math.max(1, d - h), u = r ? 520 : 260, F = r ? 900 : 620, g = e / o.length;
|
|
41
|
+
let s = 0;
|
|
42
|
+
for (let l = 0; l < o.length && s < e; l++) {
|
|
43
|
+
if (g < 1 && Math.random() > g && o.length - l > e - s) continue;
|
|
44
|
+
const v = o.dy[l], b = o.dx[l] * t.scaleX, k = v * Math.abs(t.scaleY), w = (v - h) / x;
|
|
45
|
+
a.x0[s] = b, a.y0[s] = k, a.delay[s] = w * u * 0.6 + Math.random() * u * 0.4, a.life[s] = F * (0.6 + Math.random() * 0.6), a.vx[s] = b / i * 5 + (Math.random() - 0.5) * 10, a.vy[s] = -(10 + Math.random() * 16) * (r ? 1.3 : 1), a.phase[s] = Math.random() * Math.PI * 2, a.color[s] = o.color[l], a.end = Math.max(a.end, n + a.delay[s] + a.life[s]), s++;
|
|
46
|
+
}
|
|
47
|
+
a.n = s, this.live += a.n, this.clouds.push(a), this.draw(a, n);
|
|
48
|
+
}
|
|
49
|
+
update(t) {
|
|
50
|
+
for (let r = this.clouds.length - 1; r >= 0; r--) {
|
|
51
|
+
const n = this.clouds[r];
|
|
52
|
+
if (!n.g.active || t >= n.end) {
|
|
53
|
+
n.g.active && n.g.destroy(), this.live -= n.n, this.clouds.splice(r, 1);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
this.draw(n, t);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
draw(t, r) {
|
|
60
|
+
const n = Math.floor((r - t.born) / A);
|
|
61
|
+
if (n === t.frame) return;
|
|
62
|
+
t.frame = n;
|
|
63
|
+
const m = n * A, c = t.g;
|
|
64
|
+
c.clear(), c.setPosition(t.x, t.y).setDepth(t.y + 2);
|
|
65
|
+
const f = t.size;
|
|
66
|
+
for (let e = 0; e < t.n; e++) {
|
|
67
|
+
const y = m - t.delay[e];
|
|
68
|
+
let M = t.x0[e], a = t.y0[e], h = t.color[e], d = 1;
|
|
69
|
+
if (y > 0) {
|
|
70
|
+
const i = y / t.life[e];
|
|
71
|
+
if (i >= 1) continue;
|
|
72
|
+
const o = y / 1e3;
|
|
73
|
+
M += t.vx[e] * o + Math.sin(t.phase[e] + o * 9) * i * 1.5, a += t.vy[e] * o - 22 * o * o;
|
|
74
|
+
const x = I(h);
|
|
75
|
+
h = i < 0.3 ? h : i < 0.6 ? x.light : x.hi, d = i < 0.55 ? 1 : i < 0.8 ? 0.66 : 0.33;
|
|
76
|
+
}
|
|
77
|
+
c.rect(Math.round(M), Math.round(a), f, f, h, d);
|
|
78
|
+
}
|
|
79
|
+
c.present();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
G as Evaporation
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=Evaporation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Evaporation.js","sources":["../../src/pixel/Evaporation.ts"],"sourcesContent":["import { addPixelLayer, type PixelLayer } from './PixelLayer';\nimport type { Stage } from '../core/Stage';\nimport { engineSettings } from '../settings';\nimport type { WorldObject } from '../core/types';\nimport { ramp } from './pixelTone';\nimport type { PackedPixels } from './spritePixels';\n\n/** What a dying body hands over: its feet in the world, how it was drawn, and the pixels of its last frame. */\nexport interface DeathPixels {\n x: number;\n y: number;\n /** World pixels per sprite pixel (the body's `scale`), negative when the body faced left. */\n scaleX: number;\n scaleY: number;\n pixels: PackedPixels;\n}\n\nconst FRAME_MS = 1000 / 12;\n/** Pixels in flight across every cloud at once: a crowd dying together shares this, it never adds to it. */\nconst BUDGET = 1400;\nconst PER_BODY = 150;\nconst PER_BIG = 420;\n/** Even a body dying into a full budget leaves a few of its pixels, or it would just blink out. */\nconst MIN_PER_BODY = 16;\n/** The same three under reduced effects or the battery saver. */\nconst THIN = { budget: 500, body: 60, big: 160 };\n\ninterface Cloud {\n g: PixelLayer;\n x: number;\n y: number;\n born: number;\n end: number;\n size: number;\n n: number;\n /** Per particle: start offset, release delay, lifetime, drift speed, wobble phase. */\n x0: Float32Array;\n y0: Float32Array;\n delay: Float32Array;\n life: Float32Array;\n vx: Float32Array;\n vy: Float32Array;\n phase: Float32Array;\n color: Uint32Array;\n frame: number;\n}\n\n/**\n * A dead body evaporating: it breaks into its own pixels, which let go top rows first, rise, scatter a little and\n * give out, while the body itself is hidden by the caller. Every particle is one whole world pixel in a colour read\n * off the body's last frame, painted at 12 fps like every other effect; it pales up its own ramp as it rises and\n * steps its alpha down instead of melting, so it stays pixel art the whole way. A cloud is one `PixelLayer` (a pooled\n * texture) rather than a Graphics of up to 1,400 rects.\n */\nexport class Evaporation {\n private readonly clouds: Cloud[] = [];\n private live = 0;\n\n constructor(\n private readonly scene: Stage,\n private readonly track: (object: WorldObject) => void,\n ) {}\n\n play(d: DeathPixels, big: boolean, now: number): void {\n const s = engineSettings.getState();\n const thin = s.reducedFx || s.batterySaver;\n const want = Math.min(d.pixels.length, big ? (thin ? THIN.big : PER_BIG) : thin ? THIN.body : PER_BODY);\n const n = Math.min(want, Math.max(MIN_PER_BODY, (thin ? THIN.budget : BUDGET) - this.live));\n if (n <= 0) return;\n const size = Math.max(1, Math.round(Math.abs(d.scaleY)));\n const g = addPixelLayer(this.scene);\n this.track(g);\n const c: Cloud = {\n g, x: Math.round(d.x), y: Math.round(d.y), born: now, end: now, size, n, frame: -1,\n x0: new Float32Array(n), y0: new Float32Array(n), delay: new Float32Array(n), life: new Float32Array(n),\n vx: new Float32Array(n), vy: new Float32Array(n), phase: new Float32Array(n), color: new Uint32Array(n),\n };\n let top = 0;\n let bottom = -Infinity;\n let halfW = 1;\n const px = d.pixels;\n for (let k = 0; k < px.length; k++) {\n top = Math.min(top, px.dy[k]!);\n bottom = Math.max(bottom, px.dy[k]!);\n halfW = Math.max(halfW, Math.abs(px.dx[k]! * d.scaleX));\n }\n const height = Math.max(1, bottom - top);\n const spread = big ? 520 : 260;\n const lifeMs = big ? 900 : 620;\n // a random subset when the body has more pixels than its share; every pixel otherwise\n const keep = n / px.length;\n let i = 0;\n for (let k = 0; k < px.length && i < n; k++) {\n if (keep < 1 && Math.random() > keep && px.length - k > n - i) continue;\n const pdy = px.dy[k]!;\n const x = px.dx[k]! * d.scaleX;\n const y = pdy * Math.abs(d.scaleY);\n const fromTop = (pdy - top) / height;\n c.x0[i] = x;\n c.y0[i] = y;\n // the top lets go first and the feet last, so the body dissolves upwards\n c.delay[i] = fromTop * spread * 0.6 + Math.random() * spread * 0.4;\n c.life[i] = lifeMs * (0.6 + Math.random() * 0.6);\n c.vx[i] = (x / halfW) * 5 + (Math.random() - 0.5) * 10;\n c.vy[i] = -(10 + Math.random() * 16) * (big ? 1.3 : 1);\n c.phase[i] = Math.random() * Math.PI * 2;\n c.color[i] = px.color[k]!;\n c.end = Math.max(c.end, now + c.delay[i]! + c.life[i]!);\n i++;\n }\n c.n = i;\n this.live += c.n;\n this.clouds.push(c);\n this.draw(c, now);\n }\n\n update(now: number): void {\n for (let k = this.clouds.length - 1; k >= 0; k--) {\n const c = this.clouds[k]!;\n if (!c.g.active || now >= c.end) {\n if (c.g.active) c.g.destroy();\n this.live -= c.n;\n this.clouds.splice(k, 1);\n continue;\n }\n this.draw(c, now);\n }\n }\n\n private draw(c: Cloud, now: number): void {\n const frame = Math.floor((now - c.born) / FRAME_MS);\n if (frame === c.frame) return;\n c.frame = frame;\n const ms = frame * FRAME_MS;\n const g = c.g;\n g.clear();\n g.setPosition(c.x, c.y).setDepth(c.y + 2);\n const s = c.size;\n for (let i = 0; i < c.n; i++) {\n const t = ms - c.delay[i]!;\n let x = c.x0[i]!;\n let y = c.y0[i]!;\n let color = c.color[i]!;\n let alpha = 1;\n if (t > 0) {\n const k = t / c.life[i]!;\n if (k >= 1) continue;\n const sec = t / 1000;\n // rises faster as it goes, and sways as it rises\n x += c.vx[i]! * sec + Math.sin(c.phase[i]! + sec * 9) * k * 1.5;\n y += c.vy[i]! * sec - 22 * sec * sec;\n const r = ramp(color);\n color = k < 0.3 ? color : k < 0.6 ? r.light : r.hi;\n alpha = k < 0.55 ? 1 : k < 0.8 ? 0.66 : 0.33;\n }\n g.rect(Math.round(x), Math.round(y), s, s, color, alpha);\n }\n g.present();\n }\n}\n"],"names":["FRAME_MS","BUDGET","PER_BODY","PER_BIG","MIN_PER_BODY","THIN","Evaporation","scene","track","d","big","now","s","engineSettings","thin","want","n","size","g","addPixelLayer","c","top","bottom","halfW","px","k","height","spread","lifeMs","keep","i","pdy","x","y","fromTop","frame","ms","t","color","alpha","sec","r","ramp"],"mappings":";;;AAiBA,MAAMA,IAAW,MAAO,IAElBC,IAAS,MACTC,IAAW,KACXC,IAAU,KAEVC,IAAe,IAEfC,IAAO,EAAE,QAAQ,KAAK,MAAM,IAAI,KAAK,IAAA;AA6BpC,MAAMC,EAAY;AAAA,EAIvB,YACmBC,GACAC,GACjB;AAFiB,SAAA,QAAAD,GACA,KAAA,QAAAC;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EALF,SAAkB,CAAA;AAAA,EAC3B,OAAO;AAAA,EAOf,KAAKC,GAAgBC,GAAcC,GAAmB;AACpD,UAAMC,IAAIC,EAAe,SAAA,GACnBC,IAAOF,EAAE,aAAaA,EAAE,cACxBG,IAAO,KAAK,IAAIN,EAAE,OAAO,QAAQC,IAAOI,IAAOT,EAAK,MAAMF,IAAWW,IAAOT,EAAK,OAAOH,CAAQ,GAChGc,IAAI,KAAK,IAAID,GAAM,KAAK,IAAIX,IAAeU,IAAOT,EAAK,SAASJ,KAAU,KAAK,IAAI,CAAC;AAC1F,QAAIe,KAAK,EAAG;AACZ,UAAMC,IAAO,KAAK,IAAI,GAAG,KA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,EAAE,QAAA;AAAA,EACJ;AACF;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { tintNight as e } from "../ambient/DayClock.js";
|
|
2
|
+
import { Darkness as h } from "./Darkness.js";
|
|
3
|
+
class p {
|
|
4
|
+
constructor(a, t) {
|
|
5
|
+
this.options = t, this.dark = new h(a, 0, 0), this.dark.setShade(0, 0), this.lampScale = t.lampScale ?? 1.6, this.carried = t.carriedLight ?? 64, this.carriedFrom = Math.min(0.99, t.carriedFrom ?? 0.55);
|
|
6
|
+
}
|
|
7
|
+
options;
|
|
8
|
+
dark;
|
|
9
|
+
lampScale;
|
|
10
|
+
carried;
|
|
11
|
+
carriedFrom;
|
|
12
|
+
/** A light the place glows with, `glowSize` the diameter of the glow drawn for it: by night it is what is seen by. */
|
|
13
|
+
addLight(a, t, r, s, i = 0) {
|
|
14
|
+
this.dark.addLamp(a, t, r / 2 * this.lampScale, i, s);
|
|
15
|
+
}
|
|
16
|
+
/** Lamps colour the dark less (a "fewer ambient lights" setting); their holes stay as wide. */
|
|
17
|
+
setLampsDimmed(a) {
|
|
18
|
+
this.dark.setLampsDimmed(a);
|
|
19
|
+
}
|
|
20
|
+
/** `now` the frame's ms, `wallMs` the shared wall time the clock reads (`serverNow()`), `px`/`py` the player. */
|
|
21
|
+
update(a, t, r, s) {
|
|
22
|
+
const i = this.options.clock.at(t);
|
|
23
|
+
this.dark.setShade(e(i, this.options.tint, this.options.tintShare), i.alpha);
|
|
24
|
+
const d = this.carriedFrom;
|
|
25
|
+
this.dark.update(a, r, s, Math.max(0, (i.night - d) / (1 - d)) * this.carried);
|
|
26
|
+
}
|
|
27
|
+
destroy() {
|
|
28
|
+
this.dark.destroy();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
p as NightShade
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=NightShade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NightShade.js","sources":["../../src/pixel/NightShade.ts"],"sourcesContent":["import type { Stage } from '../core/Stage';\nimport { tintNight, type DayClock } from '../ambient/DayClock';\nimport { Darkness } from './Darkness';\n\nexport interface NightShadeOptions {\n /** The day the night follows. */\n clock: DayClock;\n /** This place's own night colour, pulled in as the night deepens (`tintNight`); none keeps the clock's. */\n tint?: number;\n /** How far the tint takes over at full night (default 0.6). */\n tintShare?: number;\n /** A lamp's hole in the night against the glow it is drawn with (default 1.6: the light reaches past the glow). */\n lampScale?: number;\n /** The radius (world px) of the light a body carries at full night; 0 for none (default 64). */\n carriedLight?: number;\n /** The night share below which nothing is carried (default 0.55): at dusk a hole round the feet reads as a spotlight. */\n carriedFrom?: number;\n}\n\n/**\n * The outdoor night: a `DayClock`'s grade laid over the world as a dithered `Darkness`, deepening at dusk and lifting\n * at dawn, with every lamp, window and fire burning a hole in it — the same erase trick an underground is lit by,\n * only with a sheet whose colour and depth follow the clock. A place under no sky (a cave) builds a `Darkness` of its\n * own instead; at noon the sheet has no alpha and costs nothing.\n */\nexport class NightShade {\n private readonly dark: Darkness;\n private readonly lampScale: number;\n private readonly carried: number;\n private readonly carriedFrom: number;\n\n constructor(\n stage: Stage,\n private readonly options: NightShadeOptions,\n ) {\n this.dark = new Darkness(stage, 0x000000, 0);\n this.dark.setShade(0, 0);\n this.lampScale = options.lampScale ?? 1.6;\n this.carried = options.carriedLight ?? 64;\n this.carriedFrom = Math.min(0.99, options.carriedFrom ?? 0.55);\n }\n\n /** A light the place glows with, `glowSize` the diameter of the glow drawn for it: by night it is what is seen by. */\n addLight(x: number, y: number, glowSize: number, color?: number, flicker = 0): void {\n this.dark.addLamp(x, y, (glowSize / 2) * this.lampScale, flicker, color);\n }\n\n /** Lamps colour the dark less (a \"fewer ambient lights\" setting); their holes stay as wide. */\n setLampsDimmed(dim: boolean): void {\n this.dark.setLampsDimmed(dim);\n }\n\n /** `now` the frame's ms, `wallMs` the shared wall time the clock reads (`serverNow()`), `px`/`py` the player. */\n update(now: number, wallMs: number, px: number, py: number): void {\n const day = this.options.clock.at(wallMs);\n this.dark.setShade(tintNight(day, this.options.tint, this.options.tintShare), day.alpha);\n const from = this.carriedFrom;\n this.dark.update(now, px, py, Math.max(0, (day.night - from) / (1 - from)) * this.carried);\n }\n\n destroy(): void {\n this.dark.destroy();\n }\n}\n"],"names":["NightShade","stage","options","Darkness","x","y","glowSize","color","flicker","dim","now","wallMs","px","py","day","tintNight","from"],"mappings":";;AAyBO,MAAMA,EAAW;AAAA,EAMtB,YACEC,GACiBC,GACjB;AADiB,SAAA,UAAAA,GAEjB,KAAK,OAAO,IAAIC,EAASF,GAAO,GAAU,CAAC,GAC3C,KAAK,KAAK,SAAS,GAAG,CAAC,GACvB,KAAK,YAAYC,EAAQ,aAAa,KACtC,KAAK,UAAUA,EAAQ,gBAAgB,IACvC,KAAK,cAAc,KAAK,IAAI,MAAMA,EAAQ,eAAe,IAAI;AAAA,EAC/D;AAAA,EAPmB;AAAA,EAPF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAcjB,SAASE,GAAWC,GAAWC,GAAkBC,GAAgBC,IAAU,GAAS;AAClF,SAAK,KAAK,QAAQJ,GAAGC,GAAIC,IAAW,IAAK,KAAK,WAAWE,GAASD,CAAK;AAAA,EACzE;AAAA;AAAA,EAGA,eAAeE,GAAoB;AACjC,SAAK,KAAK,eAAeA,CAAG;AAAA,EAC9B;AAAA;AAAA,EAGA,OAAOC,GAAaC,GAAgBC,GAAYC,GAAkB;AAChE,UAAMC,IAAM,KAAK,QAAQ,MAAM,GAAGH,CAAM;AACxC,SAAK,KAAK,SAASI,EAAUD,GAAK,KAAK,QAAQ,MAAM,KAAK,QAAQ,SAAS,GAAGA,EAAI,KAAK;AACvF,UAAME,IAAO,KAAK;AAClB,SAAK,KAAK,OAAON,GAAKE,GAAIC,GAAI,KAAK,IAAI,IAAIC,EAAI,QAAQE,MAAS,IAAIA,EAAK,IAAI,KAAK,OAAO;AAAA,EAC3F;AAAA,EAEA,UAAgB;AACd,SAAK,KAAK,QAAA;AAAA,EACZ;AACF;"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Sprite as R, Texture as Y, BufferImageSource as B } from "pixi.js";
|
|
2
|
+
import { Graphics as C } from "../core/Graphics.js";
|
|
3
|
+
import { patchPixi as D } from "../core/pixiPatches.js";
|
|
4
|
+
D();
|
|
5
|
+
const W = 1024, U = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024], G = 24, K = 24 * 1024 * 1024, j = 60, m = /* @__PURE__ */ new Map();
|
|
6
|
+
let S = 0, E = 0;
|
|
7
|
+
const L = (n) => {
|
|
8
|
+
for (const t of U) if (t >= n) return t;
|
|
9
|
+
return Math.ceil(n / 256) * 256;
|
|
10
|
+
}, F = (n, t) => n * 4096 + t;
|
|
11
|
+
function q(n, t) {
|
|
12
|
+
let i = m.get(F(n, t));
|
|
13
|
+
if (!i?.length) {
|
|
14
|
+
let o = 1 / 0;
|
|
15
|
+
for (const [c, a] of m) {
|
|
16
|
+
if (!a.length) continue;
|
|
17
|
+
const p = Math.floor(c / 4096), f = c % 4096, g = p * f;
|
|
18
|
+
p >= n && f >= t && g <= n * t * 2 && g < o && (o = g, i = a);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const s = i?.pop();
|
|
22
|
+
if (s)
|
|
23
|
+
return S -= s.pixels.byteLength, s;
|
|
24
|
+
E++;
|
|
25
|
+
const e = new Uint8Array(n * t * 4), l = new B({
|
|
26
|
+
resource: e,
|
|
27
|
+
width: n,
|
|
28
|
+
height: t,
|
|
29
|
+
format: "rgba8unorm",
|
|
30
|
+
alphaMode: "premultiplied-alpha",
|
|
31
|
+
scaleMode: "nearest"
|
|
32
|
+
});
|
|
33
|
+
return { pixels: e, words: new Uint32Array(e.buffer), source: l, texture: new Y({ source: l }), capW: n, capH: t };
|
|
34
|
+
}
|
|
35
|
+
function z(n) {
|
|
36
|
+
const t = F(n.capW, n.capH);
|
|
37
|
+
let i = m.get(t);
|
|
38
|
+
if (i || m.set(t, i = []), i.length >= G || S + n.pixels.byteLength > K) {
|
|
39
|
+
n.texture.destroy(!0);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
i.push(n), S += n.pixels.byteLength;
|
|
43
|
+
}
|
|
44
|
+
function $(n) {
|
|
45
|
+
return n.add.existing(new J());
|
|
46
|
+
}
|
|
47
|
+
class J extends C {
|
|
48
|
+
/** This frame's rects: x, y, w, h, colour, alpha — six numbers each. */
|
|
49
|
+
rects = [];
|
|
50
|
+
/** Staged solid runs not yet committed: x, y, w, colour — four numbers each; later ones win. */
|
|
51
|
+
staged = [];
|
|
52
|
+
ink = 16777215;
|
|
53
|
+
inkAlpha = 1;
|
|
54
|
+
sprite = new R(Y.EMPTY);
|
|
55
|
+
surface = null;
|
|
56
|
+
/** Where the buffer's first pixel sits in the layer, as of the last `present`. */
|
|
57
|
+
originX = 0;
|
|
58
|
+
originY = 0;
|
|
59
|
+
/** The last frame's size, and how many presents in a row it stayed well inside a quarter of the buffer. */
|
|
60
|
+
lastW = 0;
|
|
61
|
+
lastH = 0;
|
|
62
|
+
small = 0;
|
|
63
|
+
constructor() {
|
|
64
|
+
super(), this.sprite.visible = !1, this.addChild(this.sprite);
|
|
65
|
+
}
|
|
66
|
+
/** Textures made, spent buffers waiting in the pool and their bytes (the leak tools read it). */
|
|
67
|
+
static stats() {
|
|
68
|
+
let t = 0;
|
|
69
|
+
for (const i of m.values()) t += i.length;
|
|
70
|
+
return { made: E, pooled: t, pooledBytes: S };
|
|
71
|
+
}
|
|
72
|
+
/** Lets every pooled buffer go (the world changed map): the next map's effects start a pool of their own. */
|
|
73
|
+
static drainPool() {
|
|
74
|
+
for (const t of m.values()) for (const i of t) i.texture.destroy(!0);
|
|
75
|
+
m.clear(), S = 0;
|
|
76
|
+
}
|
|
77
|
+
fillStyle(t, i = 1) {
|
|
78
|
+
return this.ink = t, this.inkAlpha = i, super.fillStyle(t, i);
|
|
79
|
+
}
|
|
80
|
+
fillRect(t, i, s, e) {
|
|
81
|
+
const l = Math.round(t), o = Math.round(i), c = Math.round(t + s) - l, a = Math.round(i + e) - o;
|
|
82
|
+
return c > 0 && a > 0 && this.inkAlpha > 0 && this.rects.push(l, o, c, a, this.ink, this.inkAlpha), this;
|
|
83
|
+
}
|
|
84
|
+
/** `fillStyle` + `fillRect` on whole pixels in one call, leaving the fill style alone (a hot loop's way in). */
|
|
85
|
+
rect(t, i, s, e, l, o = 1) {
|
|
86
|
+
s > 0 && e > 0 && o > 0 && Number.isFinite(t) && Number.isFinite(i) && Number.isFinite(s) && Number.isFinite(e) && this.rects.push(t, i, s, e, l, o);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A solid run of `w` whole pixels at (x, y) in `color`, held until `commit` lays every staged run in the order given
|
|
90
|
+
* (the later winning where they cross), after whatever was drawn before the commit. What `pixelTone`'s batch writes
|
|
91
|
+
* instead of filing each pixel in a map and sorting it into rects.
|
|
92
|
+
*/
|
|
93
|
+
stage(t, i, s, e) {
|
|
94
|
+
Number.isFinite(t) && Number.isFinite(i) && Number.isFinite(s) && this.staged.push(t, i, s, e);
|
|
95
|
+
}
|
|
96
|
+
/** Lays the staged runs, as opaque rects, after everything drawn so far. */
|
|
97
|
+
commit() {
|
|
98
|
+
const t = this.staged, i = t.length;
|
|
99
|
+
if (i === 0) return;
|
|
100
|
+
const s = this.rects;
|
|
101
|
+
for (let e = 0; e < i; e += 4) s.push(t[e], t[e + 1], t[e + 2], 1, t[e + 3], 1);
|
|
102
|
+
t.length = 0;
|
|
103
|
+
}
|
|
104
|
+
clear() {
|
|
105
|
+
return this.rects.length = 0, this.staged.length = 0, super.clear();
|
|
106
|
+
}
|
|
107
|
+
/** How far the last frame reached from the layer's origin, in world pixels (0 when nothing showed). */
|
|
108
|
+
reach() {
|
|
109
|
+
return this.sprite.visible ? Math.max(Math.abs(this.originX), Math.abs(this.originY), Math.abs(this.originX + this.lastW), Math.abs(this.originY + this.lastH)) : 0;
|
|
110
|
+
}
|
|
111
|
+
/** Writes this frame's rects into the texture and shows it; call once the frame is painted. */
|
|
112
|
+
present() {
|
|
113
|
+
this.commit();
|
|
114
|
+
const t = this.rects;
|
|
115
|
+
if (t.length === 0) {
|
|
116
|
+
this.sprite.visible = !1;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let i = 1 / 0, s = 1 / 0, e = -1 / 0, l = -1 / 0;
|
|
120
|
+
for (let r = 0; r < t.length; r += 6)
|
|
121
|
+
t[r] < i && (i = t[r]), t[r + 1] < s && (s = t[r + 1]), t[r] + t[r + 2] > e && (e = t[r] + t[r + 2]), t[r + 1] + t[r + 3] > l && (l = t[r + 1] + t[r + 3]);
|
|
122
|
+
const o = e - i, c = l - s;
|
|
123
|
+
if (o > W || c > W) {
|
|
124
|
+
this.sprite.visible = !1;
|
|
125
|
+
const r = t.length;
|
|
126
|
+
for (let u = 0; u < r; u += 6)
|
|
127
|
+
super.fillStyle(t[u + 4], t[u + 5]), super.fillRect(t[u], t[u + 1], t[u + 2], t[u + 3]);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const a = this.fit(o, c), { words: p, pixels: f, capW: g } = a;
|
|
131
|
+
p.fill(0);
|
|
132
|
+
for (let r = 0; r < t.length; r += 6) {
|
|
133
|
+
const u = t[r] - i, y = t[r + 1] - s, M = t[r + 2], v = t[r + 3], P = t[r + 4], x = t[r + 5], k = P >> 16 & 255, A = P >> 8 & 255, H = P & 255;
|
|
134
|
+
if (x >= 1) {
|
|
135
|
+
const d = (4278190080 | H << 16 | A << 8 | k) >>> 0;
|
|
136
|
+
if (M === 1 && v === 1) {
|
|
137
|
+
p[y * g + u] = d;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
for (let h = y; h < y + v; h++) {
|
|
141
|
+
const b = h * g + u;
|
|
142
|
+
if (M < 8) for (let X = b, _ = b + M; X < _; X++) p[X] = d;
|
|
143
|
+
else p.fill(d, b, b + M);
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const w = 1 - x, I = k * x, N = A * x, O = H * x, T = 255 * x;
|
|
148
|
+
for (let d = y; d < y + v; d++)
|
|
149
|
+
for (let h = (d * g + u) * 4, b = h + M * 4; h < b; h += 4)
|
|
150
|
+
f[h] = I + f[h] * w, f[h + 1] = N + f[h + 1] * w, f[h + 2] = O + f[h + 2] * w, f[h + 3] = T + f[h + 3] * w;
|
|
151
|
+
}
|
|
152
|
+
a.source.update(), this.sprite.texture = a.texture, this.sprite.position.set(i, s), this.sprite.visible = !0, this.originX = i, this.originY = s, this.lastW = o, this.lastH = c;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Shows `other`'s last frame instead of painting one: its texture, placed where it placed it. A frame shared by
|
|
156
|
+
* several bodies (the same aura on two bodies) is painted once and shown by each of their layers.
|
|
157
|
+
*/
|
|
158
|
+
mirror(t) {
|
|
159
|
+
const i = t.surface;
|
|
160
|
+
if (!i || !t.sprite.visible) {
|
|
161
|
+
this.hideMirror();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.sprite.texture = i.texture, this.sprite.position.set(t.originX, t.originY), this.sprite.visible = !0, this.originX = t.originX, this.originY = t.originY, this.lastW = t.lastW, this.lastH = t.lastH;
|
|
165
|
+
}
|
|
166
|
+
/** Shows nothing and lets go of the texture a `mirror` showed. */
|
|
167
|
+
hideMirror() {
|
|
168
|
+
this.sprite.visible = !1, this.sprite.texture = this.surface?.texture ?? Y.EMPTY;
|
|
169
|
+
}
|
|
170
|
+
/** The premultiplied [r, g, b, a] last presented at layer pixel (x, y); zeros where nothing was (tests read it). */
|
|
171
|
+
pixelAt(t, i) {
|
|
172
|
+
const s = this.surface, e = s?.capW ?? 0, l = s?.capH ?? 0;
|
|
173
|
+
if (this.sprite.width !== e || this.sprite.height !== l) throw new Error("PixelLayer sprite is scaled");
|
|
174
|
+
const o = t - this.originX, c = i - this.originY;
|
|
175
|
+
if (!s || !this.sprite.visible || o < 0 || c < 0 || o >= e || c >= l) return [0, 0, 0, 0];
|
|
176
|
+
const a = (c * e + o) * 4;
|
|
177
|
+
return [s.pixels[a], s.pixels[a + 1], s.pixels[a + 2], s.pixels[a + 3]];
|
|
178
|
+
}
|
|
179
|
+
/** The buffer's size (tests read it). */
|
|
180
|
+
capacity() {
|
|
181
|
+
return { w: this.surface?.capW ?? 0, h: this.surface?.capH ?? 0 };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A buffer at least `w` × `h`: grown a size class at a time and kept while it fits, traded back to the pool for a
|
|
185
|
+
* smaller one only once the frames have stayed well inside it for `SHRINK_AFTER` presents (a long-lived layer — an
|
|
186
|
+
* aura, a status mark — that once swelled would otherwise hold and upload its largest buffer for good).
|
|
187
|
+
*/
|
|
188
|
+
fit(t, i) {
|
|
189
|
+
const s = this.surface;
|
|
190
|
+
if (s && t <= s.capW && i <= s.capH) {
|
|
191
|
+
const a = s.capW * s.capH >= 16384 && t * 4 <= s.capW && i * 4 <= s.capH;
|
|
192
|
+
if (this.small = a ? this.small + 1 : 0, this.small < j) return s;
|
|
193
|
+
}
|
|
194
|
+
this.small = 0;
|
|
195
|
+
const e = !!s && (t > s.capW || i > s.capH), l = L(Math.max(1, t, e ? s.capW : 0)), o = L(Math.max(1, i, e ? s.capH : 0));
|
|
196
|
+
this.dropSurface();
|
|
197
|
+
const c = q(l, o);
|
|
198
|
+
return this.surface = c, this.sprite.texture = c.texture, c;
|
|
199
|
+
}
|
|
200
|
+
dropSurface() {
|
|
201
|
+
this.sprite.texture = Y.EMPTY, this.surface && z(this.surface), this.surface = null;
|
|
202
|
+
}
|
|
203
|
+
destroy() {
|
|
204
|
+
this.destroyed || (this.dropSurface(), super.destroy());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
J as PixelLayer,
|
|
209
|
+
$ as addPixelLayer
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=PixelLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PixelLayer.js","sources":["../../src/pixel/PixelLayer.ts"],"sourcesContent":["import { BufferImageSource, Sprite, Texture } from 'pixi.js';\nimport { Graphics } from '../core/Graphics';\nimport { patchPixi } from '../core/pixiPatches';\nimport type { Stage } from '../core/Stage';\n\npatchPixi();\n\n/** Larger than this a frame is laid as rects after all: a texture that size is no saving. */\nconst MAX_SIDE = 1024;\n/**\n * The sides a buffer is made in, each about a third to a half over the last: a layer that swells frame by frame\n * crosses a handful of them, not one every 32 px, and a spent buffer fits the next layer of its class (`POOL`).\n */\nconst SIDES = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024];\n/** Spent buffers kept per size class, and in all, for the next layers to take instead of making a texture. */\nconst POOL_PER_CLASS = 24;\nconst POOL_MAX_BYTES = 24 * 1024 * 1024;\n/** A layer whose frames have stayed this many presents well inside a quarter of its buffer trades it for a smaller one. */\nconst SHRINK_AFTER = 60;\n\n/** One buffer, the texture over it, and its size: what a layer holds and the pool keeps. */\ninterface Surface {\n pixels: Uint8Array;\n words: Uint32Array;\n source: BufferImageSource;\n texture: Texture;\n capW: number;\n capH: number;\n}\n\nconst POOL = new Map<number, Surface[]>();\nlet pooledBytes = 0;\n/** Textures made since boot (`PixelLayer.stats`): the pool is working when this stops climbing. */\nlet made = 0;\n\nconst sideFor = (n: number): number => {\n for (const s of SIDES) if (s >= n) return s;\n return Math.ceil(n / 256) * 256;\n};\nconst classOf = (w: number, h: number) => w * 4096 + h;\n\nfunction takeSurface(capW: number, capH: number): Surface {\n // the exact class, else the smallest pooled one that holds it within twice its area: a 48×24 frame takes a spent\n // 48×32 rather than making a texture of its own\n let list = POOL.get(classOf(capW, capH));\n if (!list?.length) {\n let best = Infinity;\n for (const [k, l] of POOL) {\n if (!l.length) continue;\n const w = Math.floor(k / 4096);\n const h = k % 4096;\n const area = w * h;\n if (w >= capW && h >= capH && area <= capW * capH * 2 && area < best) {\n best = area;\n list = l;\n }\n }\n }\n const hit = list?.pop();\n if (hit) {\n pooledBytes -= hit.pixels.byteLength;\n return hit;\n }\n made++;\n const pixels = new Uint8Array(capW * capH * 4);\n const source = new BufferImageSource({\n resource: pixels,\n width: capW,\n height: capH,\n format: 'rgba8unorm',\n alphaMode: 'premultiplied-alpha',\n scaleMode: 'nearest',\n });\n return { pixels, words: new Uint32Array(pixels.buffer), source, texture: new Texture({ source }), capW, capH };\n}\n\nfunction giveSurface(s: Surface): void {\n const key = classOf(s.capW, s.capH);\n let list = POOL.get(key);\n if (!list) POOL.set(key, (list = []));\n if (list.length >= POOL_PER_CLASS || pooledBytes + s.pixels.byteLength > POOL_MAX_BYTES) {\n s.texture.destroy(true);\n return;\n }\n list.push(s);\n pooledBytes += s.pixels.byteLength;\n}\n\n/**\n * A `Graphics` for the pixel effects: every `fillRect` of a frame is written into a small RGBA buffer\n * and shown as **one** sprite, instead of becoming a rect Pixi must tessellate, batch and upload. An effect's frame is\n * hundreds to thousands of one-pixel runs (a poison cloud, a status mark round every body in a pack), and as rects they\n * were most of a fight's CPU on a phone (profiled). The pixels are the same: whole\n * world pixels, a translucent fill blended over what was painted before it in the same frame, as a Graphics did.\n *\n * Paint between `clear()` and `present()`; anything other than `fillStyle`/`fillRect` still draws through the\n * Graphics underneath, so a painter using another shape keeps working. Solid pixels may also be **staged**\n * (`stage`, from `pixelTone`'s batch) and laid in one go by `commit`, which is what a batch's flush does.\n *\n * Buffers and their textures are pooled by size class (a texture per effect ran to ~114 a second in a busy fight,\n * and each one stayed in Pixi's batch tables), so a destroyed layer hands its texture\n * to the next one; `PixelLayer.drainPool` lets them all go when the map changes.\n */\n/** A new `PixelLayer` on the stage's world layer. */\nexport function addPixelLayer(stage: Stage): PixelLayer {\n return stage.add.existing(new PixelLayer());\n}\n\nexport class PixelLayer extends Graphics {\n /** This frame's rects: x, y, w, h, colour, alpha — six numbers each. */\n private readonly rects: number[] = [];\n /** Staged solid runs not yet committed: x, y, w, colour — four numbers each; later ones win. */\n private readonly staged: number[] = [];\n private ink = 0xffffff;\n private inkAlpha = 1;\n private readonly sprite = new Sprite(Texture.EMPTY);\n private surface: Surface | null = null;\n /** Where the buffer's first pixel sits in the layer, as of the last `present`. */\n private originX = 0;\n private originY = 0;\n /** The last frame's size, and how many presents in a row it stayed well inside a quarter of the buffer. */\n private lastW = 0;\n private lastH = 0;\n private small = 0;\n\n constructor() {\n super();\n this.sprite.visible = false;\n this.addChild(this.sprite);\n }\n\n /** Textures made, spent buffers waiting in the pool and their bytes (the leak tools read it). */\n static stats(): { made: number; pooled: number; pooledBytes: number } {\n let pooled = 0;\n for (const l of POOL.values()) pooled += l.length;\n return { made, pooled, pooledBytes };\n }\n\n /** Lets every pooled buffer go (the world changed map): the next map's effects start a pool of their own. */\n static drainPool(): void {\n for (const list of POOL.values()) for (const s of list) s.texture.destroy(true);\n POOL.clear();\n pooledBytes = 0;\n }\n\n override fillStyle(color: number, alpha = 1): this {\n this.ink = color;\n this.inkAlpha = alpha;\n return super.fillStyle(color, alpha);\n }\n\n override fillRect(x: number, y: number, w: number, h: number): this {\n const x0 = Math.round(x);\n const y0 = Math.round(y);\n const rw = Math.round(x + w) - x0;\n const rh = Math.round(y + h) - y0;\n if (rw > 0 && rh > 0 && this.inkAlpha > 0) this.rects.push(x0, y0, rw, rh, this.ink, this.inkAlpha);\n return this;\n }\n\n /** `fillStyle` + `fillRect` on whole pixels in one call, leaving the fill style alone (a hot loop's way in). */\n rect(x: number, y: number, w: number, h: number, color: number, alpha = 1): void {\n // a coordinate off to Infinity or NaN would make the frame's box endless (`present`), so it is dropped here\n if (w > 0 && h > 0 && alpha > 0 && Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(w) && Number.isFinite(h)) this.rects.push(x, y, w, h, color, alpha);\n }\n\n /**\n * A solid run of `w` whole pixels at (x, y) in `color`, held until `commit` lays every staged run in the order given\n * (the later winning where they cross), after whatever was drawn before the commit. What `pixelTone`'s batch writes\n * instead of filing each pixel in a map and sorting it into rects.\n */\n stage(x: number, y: number, w: number, color: number): void {\n if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(w)) this.staged.push(x, y, w, color);\n }\n\n /** Lays the staged runs, as opaque rects, after everything drawn so far. */\n commit(): void {\n const s = this.staged;\n const n = s.length;\n if (n === 0) return;\n const r = this.rects;\n for (let i = 0; i < n; i += 4) r.push(s[i]!, s[i + 1]!, s[i + 2]!, 1, s[i + 3]!, 1);\n s.length = 0;\n }\n\n override clear(): this {\n this.rects.length = 0;\n this.staged.length = 0;\n return super.clear();\n }\n\n /** How far the last frame reached from the layer's origin, in world pixels (0 when nothing showed). */\n reach(): number {\n if (!this.sprite.visible) return 0;\n return Math.max(Math.abs(this.originX), Math.abs(this.originY), Math.abs(this.originX + this.lastW), Math.abs(this.originY + this.lastH));\n }\n\n /** Writes this frame's rects into the texture and shows it; call once the frame is painted. */\n present(): void {\n this.commit();\n const r = this.rects;\n if (r.length === 0) {\n this.sprite.visible = false;\n return;\n }\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < r.length; i += 6) {\n if (r[i]! < minX) minX = r[i]!;\n if (r[i + 1]! < minY) minY = r[i + 1]!;\n if (r[i]! + r[i + 2]! > maxX) maxX = r[i]! + r[i + 2]!;\n if (r[i + 1]! + r[i + 3]! > maxY) maxY = r[i + 1]! + r[i + 3]!;\n }\n const w = maxX - minX;\n const h = maxY - minY;\n if (w > MAX_SIDE || h > MAX_SIDE) {\n this.sprite.visible = false;\n // the Graphics' own fillRect, never chained off `super.fillStyle(…)`: that returns `this`, so `.fillRect` was this\n // class's, which pushed every rect back onto `r` while it was walked — the loop never ended and grew the array to\n // a gigabyte (a body evaporating far across the screen froze PCs for seconds and killed mobile web views)\n const n = r.length;\n for (let i = 0; i < n; i += 6) {\n super.fillStyle(r[i + 4]!, r[i + 5]!);\n super.fillRect(r[i]!, r[i + 1]!, r[i + 2]!, r[i + 3]!);\n }\n return;\n }\n const surface = this.fit(w, h);\n const { words, pixels, capW: cap } = surface;\n // the whole buffer: the sprite always shows all of it at one texel a world pixel. Cropping the texture's frame to\n // this frame's size instead stretched it to the old size (a Pixi sprite is sized by `orig`), and an effect that\n // shrank — a falling column — came down as blocks blown up several times over\n words.fill(0);\n for (let i = 0; i < r.length; i += 6) {\n const x0 = r[i]! - minX;\n const y0 = r[i + 1]! - minY;\n const rw = r[i + 2]!;\n const rh = r[i + 3]!;\n const c = r[i + 4]!;\n const a = r[i + 5]!;\n const cr = (c >> 16) & 255;\n const cg = (c >> 8) & 255;\n const cb = c & 255;\n if (a >= 1) {\n // little-endian RGBA bytes, opaque: no blend\n const word = (0xff000000 | (cb << 16) | (cg << 8) | cr) >>> 0;\n if (rw === 1 && rh === 1) {\n words[y0 * cap + x0] = word;\n continue;\n }\n for (let y = y0; y < y0 + rh; y++) {\n const row = y * cap + x0;\n if (rw < 8) for (let p = row, end = row + rw; p < end; p++) words[p] = word;\n else words.fill(word, row, row + rw);\n }\n continue;\n }\n // premultiplied source-over, what a translucent Graphics fill did over the pixels under it\n const keep = 1 - a;\n const pr = cr * a;\n const pg = cg * a;\n const pb = cb * a;\n const pa = 255 * a;\n for (let y = y0; y < y0 + rh; y++) {\n for (let p = (y * cap + x0) * 4, end = p + rw * 4; p < end; p += 4) {\n pixels[p] = pr + pixels[p]! * keep;\n pixels[p + 1] = pg + pixels[p + 1]! * keep;\n pixels[p + 2] = pb + pixels[p + 2]! * keep;\n pixels[p + 3] = pa + pixels[p + 3]! * keep;\n }\n }\n }\n surface.source.update();\n this.sprite.texture = surface.texture;\n this.sprite.position.set(minX, minY);\n this.sprite.visible = true;\n this.originX = minX;\n this.originY = minY;\n this.lastW = w;\n this.lastH = h;\n }\n\n /**\n * Shows `other`'s last frame instead of painting one: its texture, placed where it placed it. A frame shared by\n * several bodies (the same aura on two bodies) is painted once and shown by each of their layers.\n */\n mirror(other: PixelLayer): void {\n const s = other.surface;\n if (!s || !other.sprite.visible) {\n this.hideMirror();\n return;\n }\n this.sprite.texture = s.texture;\n this.sprite.position.set(other.originX, other.originY);\n this.sprite.visible = true;\n this.originX = other.originX;\n this.originY = other.originY;\n this.lastW = other.lastW;\n this.lastH = other.lastH;\n }\n\n /** Shows nothing and lets go of the texture a `mirror` showed. */\n hideMirror(): void {\n this.sprite.visible = false;\n this.sprite.texture = this.surface?.texture ?? Texture.EMPTY;\n }\n\n /** The premultiplied [r, g, b, a] last presented at layer pixel (x, y); zeros where nothing was (tests read it). */\n pixelAt(x: number, y: number): [number, number, number, number] {\n const s = this.surface;\n const capW = s?.capW ?? 0;\n const capH = s?.capH ?? 0;\n // the sprite must show the buffer one texel to a world pixel, or every pixel read here lands somewhere else\n if (this.sprite.width !== capW || this.sprite.height !== capH) throw new Error('PixelLayer sprite is scaled');\n const px = x - this.originX;\n const py = y - this.originY;\n if (!s || !this.sprite.visible || px < 0 || py < 0 || px >= capW || py >= capH) return [0, 0, 0, 0];\n const p = (py * capW + px) * 4;\n return [s.pixels[p]!, s.pixels[p + 1]!, s.pixels[p + 2]!, s.pixels[p + 3]!];\n }\n\n /** The buffer's size (tests read it). */\n capacity(): { w: number; h: number } {\n return { w: this.surface?.capW ?? 0, h: this.surface?.capH ?? 0 };\n }\n\n /**\n * A buffer at least `w` × `h`: grown a size class at a time and kept while it fits, traded back to the pool for a\n * smaller one only once the frames have stayed well inside it for `SHRINK_AFTER` presents (a long-lived layer — an\n * aura, a status mark — that once swelled would otherwise hold and upload its largest buffer for good).\n */\n private fit(w: number, h: number): Surface {\n const s = this.surface;\n if (s && w <= s.capW && h <= s.capH) {\n const roomy = s.capW * s.capH >= 128 * 128 && w * 4 <= s.capW && h * 4 <= s.capH;\n this.small = roomy ? this.small + 1 : 0;\n if (this.small < SHRINK_AFTER) return s;\n }\n this.small = 0;\n // growing keeps the larger side it had, so a frame that swells one way and then the other is not traded each time\n const grow = !!s && (w > s.capW || h > s.capH);\n const capW = sideFor(Math.max(1, w, grow ? s!.capW : 0));\n const capH = sideFor(Math.max(1, h, grow ? s!.capH : 0));\n this.dropSurface();\n const next = takeSurface(capW, capH);\n this.surface = next;\n this.sprite.texture = next.texture;\n return next;\n }\n\n private dropSurface(): void {\n this.sprite.texture = Texture.EMPTY;\n if (this.surface) giveSurface(this.surface);\n this.surface = null;\n }\n\n override destroy(): void {\n if (this.destroyed) return;\n this.dropSurface();\n super.destroy();\n }\n}\n"],"names":["patchPixi","MAX_SIDE","SIDES","POOL_PER_CLASS","POOL_MAX_BYTES","SHRINK_AFTER","POOL","pooledBytes","made","sideFor","s","classOf","w","h","takeSurface","capW","capH","list","best","k","l","area","hit","pixels","source","BufferImageSource","Texture","giveSurface","key","addPixelLayer","stage","PixelLayer","Graphics","Sprite","pooled","color","alpha","x","y","x0","y0","rw","rh","n","r","i","minX","minY","maxX","maxY","surface","words","cap","c","a","cr","cg","cb","word","row","p","end","keep","pr","pg","pb","pa","other","px","py","roomy","grow","next"],"mappings":";;;AAKAA,EAAA;AAGA,MAAMC,IAAW,MAKXC,IAAQ,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,GAEnEC,IAAiB,IACjBC,IAAiB,KAAK,OAAO,MAE7BC,IAAe,IAYfC,wBAAW,IAAA;AACjB,IAAIC,IAAc,GAEdC,IAAO;AAEX,MAAMC,IAAU,CAAC,MAAsB;AACrC,aAAWC,KAAKR,EAAO,KAAIQ,KAAK,EAAG,QAAOA;AAC1C,SAAO,KAAK,KAAK,IAAI,GAAG,IAAI;AAC9B,GACMC,IAAU,CAACC,GAAWC,MAAcD,IAAI,OAAOC;AAErD,SAASC,EAAYC,GAAcC,GAAuB;AAGxD,MAAIC,IAAOX,EAAK,IAAIK,EAAQI,GAAMC,CAAI,CAAC;AACvC,MAAI,CAACC,GAAM,QAAQ;AACjB,QAAIC,IAAO;AACX,eAAW,CAACC,GAAGC,CAAC,KAAKd,GAAM;AACzB,UAAI,CAACc,EAAE,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__PURE__ */ new WeakMap();
|
|
4
|
+
function v(r, t) {
|
|
5
|
+
let s = g.get(r.source);
|
|
6
|
+
s || g.set(r.source, s = /* @__PURE__ */ new Map());
|
|
7
|
+
const h = r.frame, o = `${h.x + t.x},${h.y + t.y},${t.w},${t.h}`;
|
|
8
|
+
let i = s.get(o);
|
|
9
|
+
return i || s.set(o, i = new m({ source: r.source, frame: new I(h.x + t.x, h.y + t.y, t.w, t.h) })), i;
|
|
10
|
+
}
|
|
11
|
+
function $(r) {
|
|
12
|
+
const s = r.source.resource?.getContext?.("2d");
|
|
13
|
+
if (!s) return;
|
|
14
|
+
const { x: h, y: o, width: i, height: c } = r.frame, e = s.getImageData(h, o, i, c).data, n = [];
|
|
15
|
+
for (let u = 0; u < c; u++) {
|
|
16
|
+
let p = -1, d = -1;
|
|
17
|
+
for (let f = 0; f < i; f++)
|
|
18
|
+
e[(u * i + f) * 4 + 3] > 0 && (p < 0 && (p = f), d = f);
|
|
19
|
+
n.push(p < 0 ? 0 : d - p + 1);
|
|
20
|
+
}
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
class k {
|
|
24
|
+
constructor(t, s, h = {}) {
|
|
25
|
+
this.img = t, this.def = s, this.phase = h.phase ?? 0, this.speed = s.speed * (h.pace ?? 1), this.shown = t.visible, this.alpha = t.alpha;
|
|
26
|
+
const o = t.texture, i = o.frame.width, c = o.frame.height, e = t.parent, n = h.rig ?? (i >= 2 && c >= 2 ? M(s, i, c, s.mode === "crown" ? h.rowWidths ?? $(o) : void 0, h.variant ?? 0) : null);
|
|
27
|
+
if (this.active = !!n && !!e && n.pieces.length > 0 && n.strips.length > 0, !this.active || !n || !e) return;
|
|
28
|
+
const u = t.anchor.x * i, p = t.anchor.y * c, d = Math.round(t.x - u), f = Math.round(t.y - p), [w, ...y] = n.pieces;
|
|
29
|
+
t.texture = v(o, w), t.anchor.set((u - w.x) / w.w, (p - w.y) / w.h);
|
|
30
|
+
const x = (a) => {
|
|
31
|
+
const l = new b(v(o, a));
|
|
32
|
+
return l.position.set(d + a.x, f + a.y), l.zIndex = t.zIndex, l.visible = t.visible, l.alpha = t.alpha, e.addChild(l), this.parts.push(l), l;
|
|
33
|
+
};
|
|
34
|
+
for (const a of y) x(a);
|
|
35
|
+
for (const a of n.strips) this.strips.push({ sprite: x(a.rect), homeX: d + a.rect.x, weight: a.weight, lag: a.lag, offset: 0 });
|
|
36
|
+
}
|
|
37
|
+
img;
|
|
38
|
+
def;
|
|
39
|
+
parts = [];
|
|
40
|
+
strips = [];
|
|
41
|
+
phase;
|
|
42
|
+
speed;
|
|
43
|
+
shown;
|
|
44
|
+
alpha;
|
|
45
|
+
/** False when the frame is too small or the rig has nothing to move: `update` then does nothing. */
|
|
46
|
+
active;
|
|
47
|
+
/** `tSec` seconds of any steady clock; `enabled` false stands everything still (an ambient-effects setting). */
|
|
48
|
+
update(t, s, h = !0) {
|
|
49
|
+
if (!this.active) return;
|
|
50
|
+
const o = this.img.visible;
|
|
51
|
+
if (o !== this.shown) {
|
|
52
|
+
this.shown = o;
|
|
53
|
+
for (const e of this.parts) e.visible = o;
|
|
54
|
+
}
|
|
55
|
+
if (!o) return;
|
|
56
|
+
if (this.img.alpha !== this.alpha) {
|
|
57
|
+
this.alpha = this.img.alpha;
|
|
58
|
+
for (const e of this.parts) e.alpha = this.alpha;
|
|
59
|
+
}
|
|
60
|
+
const i = !h || s.wind <= 0, c = i ? 0 : R(t, this.img.x, s.gustSeconds, s.gustPx);
|
|
61
|
+
for (const e of this.strips) {
|
|
62
|
+
const n = i ? 0 : S(t, this.speed, this.phase, e.lag, this.def.amp, s.wind, c, e.weight, s.minReach ?? 0);
|
|
63
|
+
n !== e.offset && (e.offset = n, e.sprite.x = e.homeX + n);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
destroy() {
|
|
67
|
+
for (const t of this.parts) t.destroy();
|
|
68
|
+
this.parts.length = 0, this.strips.length = 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
k as SwayProp,
|
|
73
|
+
$ as opaqueRowWidths
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=SwayProp.js.map
|