threedog 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/core/Animator.js +267 -0
- package/core/Assets.js +240 -0
- package/core/Audio.js +267 -0
- package/core/Baked.js +72 -0
- package/core/Batching.js +247 -0
- package/core/Budget.js +221 -0
- package/core/Clock.js +94 -0
- package/core/Commits.js +77 -0
- package/core/Describe.js +134 -0
- package/core/Engine.js +221 -0
- package/core/Events.js +95 -0
- package/core/I18n.js +94 -0
- package/core/Input.js +245 -0
- package/core/Inspect.js +97 -0
- package/core/InspectScene.js +187 -0
- package/core/Jobs.js +146 -0
- package/core/Loading.js +149 -0
- package/core/Ops.js +272 -0
- package/core/Random.js +52 -0
- package/core/Rays.js +160 -0
- package/core/SaveStore.js +85 -0
- package/core/Saves.js +253 -0
- package/core/Stream.js +279 -0
- package/core/Threads.js +158 -0
- package/core/UrlState.js +93 -0
- package/core/Vars.js +34 -0
- package/core/actor.js +23 -0
- package/core/assetEntry.js +89 -0
- package/core/assetLoad.js +190 -0
- package/core/assetManifest.js +35 -0
- package/core/audioRules.js +121 -0
- package/core/audioVoice.js +225 -0
- package/core/batchGroups.js +116 -0
- package/core/canvasBox.js +63 -0
- package/core/dayTime.js +15 -0
- package/core/describeText.js +136 -0
- package/core/easing.js +34 -0
- package/core/errorCodes.js +172 -0
- package/core/errorHints.js +203 -0
- package/core/errors.js +40 -0
- package/core/events.generated.js +84 -0
- package/core/ground.js +102 -0
- package/core/inputContext.js +69 -0
- package/core/inputDefaults.js +22 -0
- package/core/inputPad.js +35 -0
- package/core/inputPointer.js +48 -0
- package/core/inputTouch.js +48 -0
- package/core/lifecycle.js +68 -0
- package/core/lightWatch.js +36 -0
- package/core/loop.js +199 -0
- package/core/math.js +33 -0
- package/core/modules.js +182 -0
- package/core/movement.js +19 -0
- package/core/mulberry32.js +14 -0
- package/core/opsCheck.js +86 -0
- package/core/opsGuard.js +26 -0
- package/core/opsHistory.js +27 -0
- package/core/page.js +78 -0
- package/core/pureWorker.js +5 -0
- package/core/saveApply.js +128 -0
- package/core/saveFiles.js +139 -0
- package/core/saveIds.js +53 -0
- package/core/saveVersions.js +97 -0
- package/core/scatter.js +92 -0
- package/core/sceneMethods.js +125 -0
- package/core/screenToGround.js +39 -0
- package/core/session.js +171 -0
- package/core/shadowTypes.js +15 -0
- package/core/skip.js +104 -0
- package/core/startup.js +133 -0
- package/core/streamCells.js +24 -0
- package/core/streamSources.js +73 -0
- package/core/styleParts.js +96 -0
- package/core/targeting.js +64 -0
- package/core/thingOps.js +157 -0
- package/core/things.js +198 -0
- package/core/threadPure.js +120 -0
- package/core/threadServe.js +25 -0
- package/core/tier.js +11 -0
- package/core/validate.js +188 -0
- package/docs/AI.md +149 -0
- package/docs/API.md +84 -0
- package/docs/CODEMAP.md +335 -0
- package/docs/COMMANDS.md +96 -0
- package/docs/CONVENTIONS.md +134 -0
- package/docs/PERF.md +217 -0
- package/docs/THREE.md +86 -0
- package/docs/api/ambience.md +15 -0
- package/docs/api/assets.md +60 -0
- package/docs/api/audio.md +53 -0
- package/docs/api/budget.md +40 -0
- package/docs/api/cameraRig.md +120 -0
- package/docs/api/characters.md +142 -0
- package/docs/api/clock.md +7 -0
- package/docs/api/collision.md +35 -0
- package/docs/api/content.md +63 -0
- package/docs/api/debug.md +10 -0
- package/docs/api/dialogue.md +39 -0
- package/docs/api/engine.md +190 -0
- package/docs/api/entities.md +61 -0
- package/docs/api/events.md +91 -0
- package/docs/api/flow.md +27 -0
- package/docs/api/grids.md +11 -0
- package/docs/api/ground.md +16 -0
- package/docs/api/hlod.md +34 -0
- package/docs/api/hud.md +31 -0
- package/docs/api/i18n.md +10 -0
- package/docs/api/input.md +24 -0
- package/docs/api/interactions.md +31 -0
- package/docs/api/inventory.md +66 -0
- package/docs/api/jobs.md +10 -0
- package/docs/api/level.md +41 -0
- package/docs/api/lightPool.md +56 -0
- package/docs/api/music.md +34 -0
- package/docs/api/nav.md +26 -0
- package/docs/api/net.md +14 -0
- package/docs/api/openWorld.md +24 -0
- package/docs/api/particles.md +41 -0
- package/docs/api/photo.md +15 -0
- package/docs/api/post.md +9 -0
- package/docs/api/quests.md +36 -0
- package/docs/api/rays.md +26 -0
- package/docs/api/rigid.md +84 -0
- package/docs/api/saves.md +31 -0
- package/docs/api/settings.md +36 -0
- package/docs/api/sky.md +58 -0
- package/docs/api/stream.md +31 -0
- package/docs/api/style.md +134 -0
- package/docs/api/terrain.md +34 -0
- package/docs/api/timeline.md +39 -0
- package/docs/api/tools.md +55 -0
- package/docs/api/triggers.md +56 -0
- package/docs/api/vars.md +9 -0
- package/docs/api/vegetation.md +52 -0
- package/docs/api/water.md +48 -0
- package/docs/api/weather.md +29 -0
- package/docs/api/world.md +30 -0
- package/docs/recipes/01-new-game.md +148 -0
- package/docs/recipes/02-npc.md +151 -0
- package/docs/recipes/03-items-pickups.md +158 -0
- package/docs/recipes/04-quests.md +83 -0
- package/docs/recipes/05-props-bake.md +159 -0
- package/docs/recipes/06-clock-events.md +104 -0
- package/docs/recipes/07-flow-scenes-pause.md +128 -0
- package/docs/recipes/08-weather-sky.md +74 -0
- package/docs/recipes/09-style-pack.md +234 -0
- package/docs/recipes/10-blender-level.md +67 -0
- package/docs/recipes/11-vehicles.md +55 -0
- package/docs/recipes/12-navmesh.md +57 -0
- package/docs/recipes/13-animation.md +146 -0
- package/docs/recipes/14-custom-module.md +91 -0
- package/docs/recipes/15-perf.md +78 -0
- package/docs/recipes/16-dev-bridge.md +146 -0
- package/docs/recipes/18-world.md +185 -0
- package/docs/recipes/19-shooting-picking.md +76 -0
- package/docs/recipes/20-content-actions-save.md +176 -0
- package/docs/recipes/21-camera.md +104 -0
- package/docs/recipes/22-shop-gold.md +107 -0
- package/docs/recipes/23-ops.md +139 -0
- package/docs/recipes/26-ui-parts.md +138 -0
- package/docs/recipes/27-net.md +96 -0
- package/docs/recipes/28-terrain.md +80 -0
- package/docs/recipes/29-grid.md +87 -0
- package/docs/recipes/30-templates.md +131 -0
- package/docs/recipes/31-audio.md +126 -0
- package/docs/recipes/32-action-game.md +33 -0
- package/docs/recipes/33-stream-sources.md +37 -0
- package/docs/recipes/34-environment-lighting.md +35 -0
- package/docs/recipes/35-style-from-reference.md +89 -0
- package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
- package/docs/recipes/37-terrain-look-hooks.md +97 -0
- package/docs/recipes/38-environment-look-hooks.md +81 -0
- package/docs/recipes/40-scene.md +79 -0
- package/docs/recipes/41-thing-registry.md +64 -0
- package/docs/recipes/42-terrain-shape.md +64 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +118 -0
- package/docs/recipes/44-water-weather-look-hooks.md +133 -0
- package/docs/recipes/45-cascaded-shadows.md +51 -0
- package/docs/recipes/46-blender-art-route.md +92 -0
- package/docs/recipes/47-island-snow-backdrop.md +44 -0
- package/examples/action/DESIGN.md +3 -0
- package/examples/action/GAMEMAP.md +127 -0
- package/examples/action/content/actions.js +8 -0
- package/examples/action/content/audio.js +9 -0
- package/examples/action/content/index.js +9 -0
- package/examples/action/content/items.js +4 -0
- package/examples/action/content/places.js +4 -0
- package/examples/action/content/props.js +11 -0
- package/examples/action/content/templates.js +10 -0
- package/examples/action/look.js +5 -0
- package/examples/action/main.js +137 -0
- package/examples/action/models.js +25 -0
- package/examples/sheepisland/GAMEMAP.md +108 -0
- package/examples/sheepisland/content/index.js +6 -0
- package/examples/sheepisland/content/props.js +19 -0
- package/examples/sheepisland/content/templates.js +5 -0
- package/examples/sheepisland/content/vegetation.js +8 -0
- package/examples/sheepisland/main.js +71 -0
- package/examples/sheepisland/params.js +25 -0
- package/examples/sheepisland/style/index.js +79 -0
- package/examples/sheepisland/style/models.js +59 -0
- package/examples/sheepisland/views.js +9 -0
- package/examples/styletest/GAMEMAP.md +135 -0
- package/examples/styletest/content/index.js +9 -0
- package/examples/styletest/content/items.js +8 -0
- package/examples/styletest/content/npcs.js +8 -0
- package/examples/styletest/content/places.js +5 -0
- package/examples/styletest/content/props.js +16 -0
- package/examples/styletest/content/templates.js +9 -0
- package/examples/styletest/content/vegetation.js +31 -0
- package/examples/styletest/look.js +11 -0
- package/examples/styletest/main.js +95 -0
- package/examples/styletest/models.js +87 -0
- package/examples/styletest/overrides.js +33 -0
- package/examples/styletest/panel.js +135 -0
- package/examples/styletest/params.js +32 -0
- package/examples/styletest/views.js +31 -0
- package/examples/world/DESIGN.md +5 -0
- package/examples/world/GAMEMAP.md +171 -0
- package/examples/world/content/actions.js +8 -0
- package/examples/world/content/audio.js +25 -0
- package/examples/world/content/bodies.js +12 -0
- package/examples/world/content/containers.js +4 -0
- package/examples/world/content/dialogues.js +33 -0
- package/examples/world/content/index.js +17 -0
- package/examples/world/content/items.js +10 -0
- package/examples/world/content/npcs.js +14 -0
- package/examples/world/content/pickups.js +11 -0
- package/examples/world/content/places.js +6 -0
- package/examples/world/content/props.js +12 -0
- package/examples/world/content/quests.js +15 -0
- package/examples/world/content/rules.js +23 -0
- package/examples/world/content/templates.js +5 -0
- package/examples/world/content/vegetation.js +32 -0
- package/examples/world/main.js +168 -0
- package/examples/world/models.js +28 -0
- package/index.d.ts +279 -0
- package/index.js +120 -0
- package/llms.txt +56 -0
- package/modules/ambience/Ambience.js +183 -0
- package/modules/camera/FirstPersonCamera.js +133 -0
- package/modules/camera/FixedCamera.js +155 -0
- package/modules/camera/FollowCamera.js +85 -0
- package/modules/camera/RtsCamera.js +134 -0
- package/modules/camera/common.js +152 -0
- package/modules/camera/index.js +11 -0
- package/modules/characters/Character.js +223 -0
- package/modules/characters/NPC.js +242 -0
- package/modules/characters/assetModel.js +42 -0
- package/modules/characters/astar.js +59 -0
- package/modules/characters/behaviors.js +72 -0
- package/modules/characters/footsteps.js +13 -0
- package/modules/characters/index.js +212 -0
- package/modules/characters/moveHelpers.js +29 -0
- package/modules/characters/movers/common.js +62 -0
- package/modules/characters/movers/rapier.js +74 -0
- package/modules/characters/movers/simple.js +38 -0
- package/modules/characters/npcAvoid.js +129 -0
- package/modules/characters/npcSim.js +144 -0
- package/modules/characters/npcView.js +42 -0
- package/modules/characters/pathAsync.js +107 -0
- package/modules/characters/pathJob.js +61 -0
- package/modules/characters/pathWorker.js +7 -0
- package/modules/characters/playerStrings.js +12 -0
- package/modules/characters/proceduralRig.js +54 -0
- package/modules/collision/Collision.js +176 -0
- package/modules/collision/grid.js +63 -0
- package/modules/content/ids.js +95 -0
- package/modules/content/index.js +152 -0
- package/modules/content/loader.js +187 -0
- package/modules/content/models.js +69 -0
- package/modules/content/packs.js +69 -0
- package/modules/content/props.js +89 -0
- package/modules/content/rules.js +133 -0
- package/modules/content/templates.js +189 -0
- package/modules/debug/DebugPanel.js +168 -0
- package/modules/entities/Entities.js +239 -0
- package/modules/entities/build.js +25 -0
- package/modules/entities/index.js +4 -0
- package/modules/flow/index.js +98 -0
- package/modules/gameplay/Container.js +227 -0
- package/modules/gameplay/Containers.js +89 -0
- package/modules/gameplay/Dialogue.js +216 -0
- package/modules/gameplay/Interactions.js +243 -0
- package/modules/gameplay/Inventory.js +214 -0
- package/modules/gameplay/Quests.js +195 -0
- package/modules/gameplay/boxOps.js +60 -0
- package/modules/gameplay/dialogueBox.js +48 -0
- package/modules/gameplay/interactionPrompt.js +28 -0
- package/modules/gameplay/inventoryOps.js +137 -0
- package/modules/gameplay/pickups.js +113 -0
- package/modules/gameplay/questLog.js +54 -0
- package/modules/gameplay/questSave.js +71 -0
- package/modules/grid/Grid.js +184 -0
- package/modules/grid/Layer.js +142 -0
- package/modules/grid/index.js +236 -0
- package/modules/grid/ops.js +73 -0
- package/modules/grid/preview.js +85 -0
- package/modules/grid/tiles.js +75 -0
- package/modules/hlod/index.js +164 -0
- package/modules/hud/index.js +164 -0
- package/modules/hud/parts.js +80 -0
- package/modules/level/geometry.js +46 -0
- package/modules/level/heightfield.js +160 -0
- package/modules/level/index.js +231 -0
- package/modules/level/nodes.js +84 -0
- package/modules/lights/index.js +224 -0
- package/modules/music/Music.js +290 -0
- package/modules/music/index.js +2 -0
- package/modules/music/rules.js +28 -0
- package/modules/nav/index.js +154 -0
- package/modules/nav/navPath.js +17 -0
- package/modules/net/Client.js +136 -0
- package/modules/net/Host.js +117 -0
- package/modules/net/Net.js +49 -0
- package/modules/net/index.js +75 -0
- package/modules/net/sync.js +114 -0
- package/modules/net/transports.js +118 -0
- package/modules/particles/Particles.js +179 -0
- package/modules/particles/effect.js +112 -0
- package/modules/particles/shaders.js +28 -0
- package/modules/photo/Photo.js +143 -0
- package/modules/rigid/RigidBodies.js +262 -0
- package/modules/rigid/Vehicles.js +97 -0
- package/modules/rigid/sync.js +158 -0
- package/modules/settings/Settings.js +294 -0
- package/modules/settings/apply.js +20 -0
- package/modules/settings/index.js +3 -0
- package/modules/settings/sections.js +156 -0
- package/modules/settings/strings.js +53 -0
- package/modules/settings/view.js +65 -0
- package/modules/sky/Sky.js +257 -0
- package/modules/sky/calendar.js +80 -0
- package/modules/sky/cascades.js +125 -0
- package/modules/sky/clouds.js +79 -0
- package/modules/sky/domeLayers.js +33 -0
- package/modules/sky/environment.js +115 -0
- package/modules/sky/fog.js +136 -0
- package/modules/sky/frame.js +76 -0
- package/modules/sky/layers.js +69 -0
- package/modules/sky/look.js +50 -0
- package/modules/sky/schedule.js +80 -0
- package/modules/sky/shader.js +96 -0
- package/modules/sky/shadow.js +80 -0
- package/modules/sky/skyModule.js +59 -0
- package/modules/terrain/ChunkManager.js +291 -0
- package/modules/terrain/chunkJob.js +19 -0
- package/modules/terrain/chunkQueries.js +42 -0
- package/modules/terrain/chunkWorker.js +5 -0
- package/modules/terrain/index.js +110 -0
- package/modules/terrain/mountTerrain.js +32 -0
- package/modules/terrain/terrainColorMap.js +41 -0
- package/modules/terrain/terrainDefaults.js +39 -0
- package/modules/terrain/terrainEdit.js +139 -0
- package/modules/terrain/terrainGen.js +155 -0
- package/modules/terrain/terrainIsland.js +131 -0
- package/modules/terrain/terrainMesh.js +92 -0
- package/modules/terrain/terrainShape.js +108 -0
- package/modules/terrain/terrainShapeMain.js +41 -0
- package/modules/terrain/terrainTexture.js +44 -0
- package/modules/timeline/Timeline.js +249 -0
- package/modules/timeline/Tween.js +118 -0
- package/modules/timeline/letterbox.js +24 -0
- package/modules/timeline/shots.js +88 -0
- package/modules/triggers/index.js +261 -0
- package/modules/vegetation/Vegetation.js +255 -0
- package/modules/vegetation/groundChunks.js +177 -0
- package/modules/vegetation/index.js +40 -0
- package/modules/vegetation/modelGeometry.js +21 -0
- package/modules/water/Water.js +144 -0
- package/modules/water/surface.js +88 -0
- package/modules/weather/Weather.js +251 -0
- package/modules/weather/particles.js +92 -0
- package/modules/weather/shaders.js +49 -0
- package/modules/world/World.js +231 -0
- package/modules/world/cells.js +42 -0
- package/modules/world/index.js +64 -0
- package/modules/world/persist.js +107 -0
- package/modules/world/pos.js +20 -0
- package/modules/world/records.js +89 -0
- package/modules/world/sim.js +175 -0
- package/modules/world/simFar.js +82 -0
- package/modules/world/state.js +115 -0
- package/modules/world/views.js +182 -0
- package/package.json +66 -4
- package/presets.js +96 -0
- package/render/PostFX.js +243 -0
- package/render/detail.js +105 -0
- package/render/effects.js +142 -0
- package/render/engineUniforms.js +23 -0
- package/render/fuse.js +72 -0
- package/render/lighting.js +100 -0
- package/render/lights.js +16 -0
- package/render/materials.js +203 -0
- package/render/patches.js +252 -0
- package/render/surface.js +67 -0
- package/render/uniformDecl.js +29 -0
- package/types/common.d.ts +34 -0
- package/types/core.d.ts +1773 -0
- package/types/gameplay.d.ts +1812 -0
- package/types/generated/core/Audio.d.ts +200 -0
- package/types/generated/core/Batching.d.ts +47 -0
- package/types/generated/core/Budget.d.ts +90 -0
- package/types/generated/core/Commits.d.ts +31 -0
- package/types/generated/core/Events.d.ts +46 -0
- package/types/generated/core/I18n.d.ts +30 -0
- package/types/generated/core/Input.d.ts +118 -0
- package/types/generated/core/Jobs.d.ts +41 -0
- package/types/generated/core/Ops.d.ts +162 -0
- package/types/generated/core/Random.d.ts +49 -0
- package/types/generated/core/Rays.d.ts +49 -0
- package/types/generated/core/Saves.d.ts +161 -0
- package/types/generated/core/Stream.d.ts +93 -0
- package/types/generated/core/Threads.d.ts +82 -0
- package/types/generated/core/audioVoice.d.ts +47 -0
- package/types/generated/core/page.d.ts +18 -0
- package/types/generated/core/session.d.ts +48 -0
- package/types/generated/modules/ambience/Ambience.d.ts +48 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
- package/types/generated/modules/flow/index.d.ts +10 -0
- package/types/generated/modules/grid/Grid.d.ts +151 -0
- package/types/generated/modules/grid/Layer.d.ts +64 -0
- package/types/generated/modules/grid/index.d.ts +86 -0
- package/types/generated/modules/hlod/index.d.ts +11 -0
- package/types/generated/modules/hud/index.d.ts +10 -0
- package/types/generated/modules/lights/index.d.ts +13 -0
- package/types/generated/modules/music/Music.d.ts +111 -0
- package/types/generated/modules/net/Net.d.ts +34 -0
- package/types/generated/modules/net/index.d.ts +53 -0
- package/types/generated/modules/net/transports.d.ts +58 -0
- package/types/generated/modules/particles/Particles.d.ts +69 -0
- package/types/generated/modules/sky/Sky.d.ts +152 -0
- package/types/generated/modules/sky/skyModule.d.ts +10 -0
- package/types/generated/modules/timeline/Timeline.d.ts +51 -0
- package/types/generated/modules/water/Water.d.ts +29 -0
- package/types/generated/modules/weather/Weather.d.ts +72 -0
- package/types/generated/modules/world/World.d.ts +242 -0
- package/types/generated/modules/world/index.d.ts +15 -0
- package/types/generated/render/PostFX.d.ts +128 -0
- package/types/generated/render/materials.d.ts +90 -0
- package/types/generated/render/patches.d.ts +41 -0
- package/types/generated/ui/Focus.d.ts +11 -0
- package/types/generated/ui/LoadingScreen.d.ts +2 -0
- package/types/generated/ui/UI.d.ts +57 -0
- package/types/nav.d.ts +52 -0
- package/types/physics.d.ts +584 -0
- package/types/style.d.ts +628 -0
- package/types/worker.d.ts +11 -0
- package/types/world.d.ts +772 -0
- package/ui/Focus.js +51 -0
- package/ui/LoadingScreen.js +42 -0
- package/ui/Parts.js +195 -0
- package/ui/UI.js +167 -0
- package/ui/defaults.js +85 -0
- package/ui/theme.js +124 -0
- package/ui/touchPart.js +49 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/page.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** engine.page: window focus, tab visibility, mouse lock and WebGL context, all handled here. */
|
|
3
|
+
export class Page {
|
|
4
|
+
/** Wait (no fixed steps) while the page is away; default true. Settable at runtime @type {boolean} */
|
|
5
|
+
pauseOnBlur: boolean;
|
|
6
|
+
/** The window has keyboard focus @type {boolean} */
|
|
7
|
+
focused: boolean;
|
|
8
|
+
/** The tab is visible @type {boolean} */
|
|
9
|
+
visible: boolean;
|
|
10
|
+
/** The mouse is locked to the canvas (first-person / shoulder cameras lock on click) @type {boolean} */
|
|
11
|
+
pointerLocked: boolean;
|
|
12
|
+
/** The WebGL context is lost and not yet restored @type {boolean} */
|
|
13
|
+
contextLost: boolean;
|
|
14
|
+
/** The page is away: the window lost focus or the tab is hidden @type {boolean} */
|
|
15
|
+
get away(): boolean;
|
|
16
|
+
/** The real-time loop holds gameplay now (away with pauseOnBlur, or the WebGL context is lost) @type {boolean} */
|
|
17
|
+
get held(): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/session.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
|
|
3
|
+
/** engine.session: new game / continue / back to title, each from a clean slate. */
|
|
4
|
+
export class Session {
|
|
5
|
+
/**
|
|
6
|
+
* True while a playthrough runs: start() has finished, no newGame / load / quit is replacing the state, and the title screen is not up.
|
|
7
|
+
* Autosave and other "only during play" work check it.
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
*/
|
|
10
|
+
get playing(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Keep a handle only for this playthrough: newGame / load / quit call handle.remove(). Returns the handle.
|
|
13
|
+
* @template {{ remove(): void }} H
|
|
14
|
+
* @param {H} handle
|
|
15
|
+
* @returns {H}
|
|
16
|
+
* @example
|
|
17
|
+
* // a quest's helper listener lives only as long as this playthrough
|
|
18
|
+
* engine.session.track(engine.events.on('npc:talk', ({ id }) => { if (id === 'baker') engine.vars.setFlag('metBaker'); }));
|
|
19
|
+
*/
|
|
20
|
+
track<H extends {
|
|
21
|
+
remove(): void;
|
|
22
|
+
}>(handle: H): H;
|
|
23
|
+
/**
|
|
24
|
+
* Start a new playthrough from the state the game had right after start(). Returns Promise<boolean> (false only if a save part failed to load; the game is then rolled back).
|
|
25
|
+
* @returns {Promise<boolean>}
|
|
26
|
+
* @example
|
|
27
|
+
* // a "Restart" button in a game-over screen
|
|
28
|
+
* restartBtn.onclick = () => engine.session.newGame();
|
|
29
|
+
*/
|
|
30
|
+
newGame(): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Continue from a save (or retry from a checkpoint) with nothing of the current playthrough left over: the new-game state with the save on top,
|
|
33
|
+
* so a part the save does not have (a module added in a later version of the game) starts from its new-game state.
|
|
34
|
+
* A save that cannot be read (missing, corrupt, from a newer build) is refused before anything changes: returns false, the current game and the save stay as they were.
|
|
35
|
+
* @param {string} [slot]
|
|
36
|
+
* @returns {Promise<boolean>}
|
|
37
|
+
* @example
|
|
38
|
+
* engine.events.on('player:dead', () => engine.session.load('checkpoint')); // retry; the checkpoint was saved with engine.saves.save('checkpoint')
|
|
39
|
+
*/
|
|
40
|
+
load(slot?: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* End the playthrough and show the title screen (the title part when the game turned it on; flow returns to its start state).
|
|
43
|
+
* The state behind the title is the new-game state, so nothing from the old playthrough runs while the title is up.
|
|
44
|
+
* @returns {Promise<boolean>}
|
|
45
|
+
* @example settingsBackToTitle.onclick = () => engine.session.quit();
|
|
46
|
+
*/
|
|
47
|
+
quit(): Promise<boolean>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/ambience/Ambience.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Ambience -> engine.ambience. Rules come from createEngine({ audio: { ambience: [...] } }) plus opts.rules
|
|
4
|
+
* @param {AmbienceOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Ambience>}
|
|
6
|
+
* @example engine.use(ambience({ rules: [{ sound: 'hum', when: { zone: 'lab' }, volume: 0.4 }] }));
|
|
7
|
+
*/
|
|
8
|
+
export function ambience(opts?: AmbienceOptions): ModuleDef<Ambience>;
|
|
9
|
+
/** engine.ambience: the rule table of background sounds */
|
|
10
|
+
export class Ambience {
|
|
11
|
+
/** Where the sounds are heard from: whoever the player controls (engine.actor), else the camera focus @type {THREE.Vector3} */
|
|
12
|
+
position: THREE.Vector3;
|
|
13
|
+
/**
|
|
14
|
+
* Add one rule; returns a handle whose remove() fades the sound out and drops the rule
|
|
15
|
+
* @param {AmbienceRule} rule
|
|
16
|
+
* @returns {{ remove(): void }}
|
|
17
|
+
* @example const h = engine.ambience.add({ sound: 'storm-wind', when: { weather: 'storm' }, volume: 0.5 });
|
|
18
|
+
*/
|
|
19
|
+
add(rule: AmbienceRule): {
|
|
20
|
+
remove(): void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Replace the whole rule table (null or [] = silence)
|
|
24
|
+
* @param {AmbienceRule[] | null} list
|
|
25
|
+
* @returns {this}
|
|
26
|
+
*/
|
|
27
|
+
rules(list: AmbienceRule[] | null): this;
|
|
28
|
+
/**
|
|
29
|
+
* How much of the ground within `radius` meters of the listener is water (0-1), sampled at 6 points: for a water rule's volume
|
|
30
|
+
* @param {number} [radius]
|
|
31
|
+
* @returns {number}
|
|
32
|
+
* @example { sound: 'river', volume: (e, a) => a.nearWater(20) * 0.12 } // in data: volume: { add: { nearWater: 0.12 } } (12 m)
|
|
33
|
+
*/
|
|
34
|
+
nearWater(radius?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* What each rule is doing (debug, tests): sound name, whether its condition holds, its current target volume
|
|
37
|
+
* @returns {{ sound: string, on: boolean, volume: number }[]}
|
|
38
|
+
*/
|
|
39
|
+
get info(): {
|
|
40
|
+
sound: string;
|
|
41
|
+
on: boolean;
|
|
42
|
+
volume: number;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
import type { AmbienceOptions } from '../../../gameplay';
|
|
46
|
+
import type { ModuleDef } from '../../../core';
|
|
47
|
+
import type { AmbienceRule } from '../../../core';
|
|
48
|
+
import * as THREE from 'three';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/debug/DebugPanel.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* F3 F3 debug panel -> engine.debug: performance panel, settings, stress test. Collapsed by default; F3 shows/hides it; open: true shows it at start. Just do not install it in a release
|
|
4
|
+
* @param {{ open?: boolean }} [opts]
|
|
5
|
+
* @returns {ModuleDef<DebugPanel>}
|
|
6
|
+
*/
|
|
7
|
+
export function debug(opts?: {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
}): ModuleDef<DebugPanel>;
|
|
10
|
+
/** @import { ModuleDef } from '../../../core' */
|
|
11
|
+
/** engine.debug (F3 panel) */
|
|
12
|
+
export class DebugPanel {
|
|
13
|
+
/** Stress test running (player auto-runs fast) @type {boolean} */
|
|
14
|
+
benchmarking: boolean;
|
|
15
|
+
/** Panel root element @type {HTMLElement} */
|
|
16
|
+
el: HTMLElement;
|
|
17
|
+
/**
|
|
18
|
+
* Start the stress test (seconds, default 20): the character auto-runs fast, continuously loading new chunks, and a report is shown in the panel at the end
|
|
19
|
+
* @param {number} [seconds]
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
startBench(seconds?: number): void;
|
|
23
|
+
}
|
|
24
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/flow/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Game flow and scene transitions → engine.flow
|
|
4
|
+
* @param {FlowOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Flow>}
|
|
6
|
+
*/
|
|
7
|
+
export function flow(opts?: FlowOptions): ModuleDef<Flow>;
|
|
8
|
+
import type { FlowOptions } from '../../../gameplay';
|
|
9
|
+
import type { Flow } from '../../../gameplay';
|
|
10
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/Grid.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* A placement grid. Several can exist at once (a yard outdoors, a room indoors); each has its own cell size, origin and bounds.
|
|
4
|
+
* @example
|
|
5
|
+
* const room = engine.grids.add('room', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
6
|
+
* room.toCell(engine.player.position); // [3, 5]
|
|
7
|
+
* room.can('table', [3, 5]); // true or a reason: 'occupied' 'outOfBounds' 'notFlat' 'wrongGround' or a layer reason ...
|
|
8
|
+
* engine.ops.run('grid.place', { grid: 'room', item: 'table', cell: [3, 5] });
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
export class Grid {
|
|
12
|
+
/** Grid name (the `grid` arg of the grid.* ops) @type {string} */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Cell edge length (meters) @type {number} */
|
|
15
|
+
cell: number;
|
|
16
|
+
/** World position of the min corner of cell [0, 0] @type {{ x: number, z: number }} */
|
|
17
|
+
origin: {
|
|
18
|
+
x: number;
|
|
19
|
+
z: number;
|
|
20
|
+
};
|
|
21
|
+
/** Cell count [width, depth]; null = unbounded @type {[number, number] | null} */
|
|
22
|
+
size: [number, number] | null;
|
|
23
|
+
/** Level name this grid belongs to (null = everywhere); its tiles show only while engine.world.zone matches @type {string | null} */
|
|
24
|
+
zone: string | null;
|
|
25
|
+
/** Max height difference (m) allowed under a footprint before can() says 'notFlat' @type {number} */
|
|
26
|
+
flat: number;
|
|
27
|
+
/**
|
|
28
|
+
* World position (Vector3 / object / [x, z] / [x, y, z] / (x, z)) -> cell [i, j]
|
|
29
|
+
* @example farm.toCell(engine.player.position)
|
|
30
|
+
* @param {any} x
|
|
31
|
+
* @param {number} [z]
|
|
32
|
+
* @returns {[number, number]}
|
|
33
|
+
*/
|
|
34
|
+
toCell(x: any, z?: number): [number, number];
|
|
35
|
+
/**
|
|
36
|
+
* Center of a footprint in world space, y on the ground (engine.surface). Without size it is the center of one cell
|
|
37
|
+
* @example obj.position.copy(farm.toWorld([3, 5]))
|
|
38
|
+
* @param {[number, number]} cell
|
|
39
|
+
* @param {[number, number]} [size]
|
|
40
|
+
* @param {number} [rotation] quarter turns
|
|
41
|
+
* @returns {{ x: number, y: number, z: number }}
|
|
42
|
+
*/
|
|
43
|
+
toWorld(cell: [number, number], size?: [number, number], rotation?: number): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
z: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Snap a world position to the center of the cell it is in
|
|
50
|
+
* @example mesh.position.copy(farm.snap(hit.point))
|
|
51
|
+
* @param {any} pos
|
|
52
|
+
* @returns {{ x: number, y: number, z: number }}
|
|
53
|
+
*/
|
|
54
|
+
snap(pos: any): {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
z: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Is the cell inside the grid bounds (always true for an unbounded grid)
|
|
61
|
+
* @param {[number, number]} cell
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
inside([i, j]: [number, number]): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Cells covered by a footprint anchored at cell (min corner)
|
|
67
|
+
* @example farm.footprint([2, 2], [2, 1], 1) // [[2,2],[2,3]]: a 2x1 bed turned a quarter covers two cells along z
|
|
68
|
+
* @param {[number, number]} cell
|
|
69
|
+
* @param {[number, number]} [size]
|
|
70
|
+
* @param {number} [rotation] quarter turns
|
|
71
|
+
* @returns {[number, number][]}
|
|
72
|
+
*/
|
|
73
|
+
footprint(cell: [number, number], size?: [number, number], rotation?: number): [number, number][];
|
|
74
|
+
/**
|
|
75
|
+
* Id of the world record occupying a cell, or null
|
|
76
|
+
* @example engine.world.get(farm.at([3, 5]))
|
|
77
|
+
* @param {[number, number]} cell
|
|
78
|
+
* @returns {string | null}
|
|
79
|
+
*/
|
|
80
|
+
at([i, j]: [number, number]): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Ids of the records occupying any cell of an area (each once)
|
|
83
|
+
* @example farm.area([0, 0], [4, 4])
|
|
84
|
+
* @param {[number, number]} cell min corner
|
|
85
|
+
* @param {[number, number]} [size]
|
|
86
|
+
* @returns {string[]}
|
|
87
|
+
*/
|
|
88
|
+
area(cell: [number, number], size?: [number, number]): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Can this go here? Returns true or a reason: outOfBounds, occupied, wrongGround, not<Field> (a layer rule such as notTilled), notFlat, or the item's own can reason.
|
|
91
|
+
* what is an item name registered with engine.grids.define, a size [w, d], or an inline rule { size, ground, layer, flat, can }.
|
|
92
|
+
* @example farm.can('crop', [3, 5]) // 'notTilled' until the soil layer says tilled
|
|
93
|
+
* @example farm.can([2, 1], [0, 0], { rotation: 1 }) // only bounds, occupancy and flatness
|
|
94
|
+
* @param {string | [number, number] | GridRule} what
|
|
95
|
+
* @param {[number, number]} cell
|
|
96
|
+
* @param {{ rotation?: number, ignore?: string }} [opts] ignore: a record id to skip (moving a thing over its own cells)
|
|
97
|
+
* @returns {true | string}
|
|
98
|
+
*/
|
|
99
|
+
can(what: string | [number, number] | GridRule, cell: [number, number], opts?: {
|
|
100
|
+
rotation?: number;
|
|
101
|
+
ignore?: string;
|
|
102
|
+
}): true | string;
|
|
103
|
+
/**
|
|
104
|
+
* can() with the details behind the answer (used by engine.explain): { reason, cell, by } where by is the occupying record id
|
|
105
|
+
* @param {string | [number, number] | GridRule} what
|
|
106
|
+
* @param {[number, number]} cell
|
|
107
|
+
* @param {{ rotation?: number, ignore?: string }} [opts]
|
|
108
|
+
* @returns {{ reason: string | null, cell?: [number, number], by?: string, text?: string }}
|
|
109
|
+
*/
|
|
110
|
+
check(what: string | [number, number] | GridRule, cell: [number, number], { rotation, ignore }?: {
|
|
111
|
+
rotation?: number;
|
|
112
|
+
ignore?: string;
|
|
113
|
+
}): {
|
|
114
|
+
reason: string | null;
|
|
115
|
+
cell?: [number, number];
|
|
116
|
+
by?: string;
|
|
117
|
+
text?: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A named per-cell data layer on this grid (created on first use): soil state, wetness, ownership, anything plain.
|
|
121
|
+
* Writes go through ops like other saved gameplay state; the data is saved with the game (only non-empty cells).
|
|
122
|
+
* @example const soil = farm.layer('soil'); // in an op: soil.set([3, 5], { tilled: true })
|
|
123
|
+
* @example farm.layer('soil', { tiles: false }) // no tile visuals for this layer
|
|
124
|
+
* @param {string} name
|
|
125
|
+
* @param {import('./Layer.js').LayerOptions} [opts] only read on creation
|
|
126
|
+
* @returns {Layer}
|
|
127
|
+
*/
|
|
128
|
+
layer(name: string, opts?: import("./Layer.js").LayerOptions): Layer;
|
|
129
|
+
/** Layers created so far @returns {Layer[]} */
|
|
130
|
+
get layers(): Layer[];
|
|
131
|
+
/** Number of occupied cells @returns {number} */
|
|
132
|
+
get occupied(): number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Placement rule: what engine.grids.define registers, or an inline rule for can()
|
|
136
|
+
*/
|
|
137
|
+
export type GridRule = {
|
|
138
|
+
size?: [number, number];
|
|
139
|
+
kind?: string;
|
|
140
|
+
ground?: string | string[];
|
|
141
|
+
layer?: Record<string, string>;
|
|
142
|
+
flat?: number;
|
|
143
|
+
fields?: Record<string, any>;
|
|
144
|
+
can?: (e: any, info: {
|
|
145
|
+
grid: Grid;
|
|
146
|
+
cell: [number, number];
|
|
147
|
+
rotation: number;
|
|
148
|
+
cells: [number, number][];
|
|
149
|
+
}) => true | string;
|
|
150
|
+
};
|
|
151
|
+
import { Layer } from './Layer.js';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/Layer.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** @experimental */
|
|
3
|
+
export class Layer {
|
|
4
|
+
/** Layer name @type {string} */
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* Data of a cell, or undefined. Read only (frozen in dev builds): change it with set / clear / updateAll
|
|
8
|
+
* @example farm.layer('soil').get([3, 5])?.watered
|
|
9
|
+
* @param {[number, number]} cell
|
|
10
|
+
* @returns {Record<string, any> | undefined}
|
|
11
|
+
*/
|
|
12
|
+
get([i, j]: [number, number]): Record<string, any> | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Merge fields into a cell's data (created if empty); a field set to null / undefined is deleted, and a cell left with no fields is cleared. Returns the data
|
|
15
|
+
* @example farm.layer('soil').set([3, 5], { tilled: true, watered: true })
|
|
16
|
+
* @example farm.layer('soil').set([3, 5], { watered: null }) // dry this one cell
|
|
17
|
+
* @param {[number, number]} cell
|
|
18
|
+
* @param {Record<string, any>} patch
|
|
19
|
+
* @returns {Record<string, any> | undefined}
|
|
20
|
+
*/
|
|
21
|
+
set([i, j]: [number, number], patch: Record<string, any>): Record<string, any> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Empty a cell
|
|
24
|
+
* @param {[number, number]} cell
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
clear([i, j]: [number, number]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Non-empty cells, optionally only those in an area (min corner + size), in i then j order
|
|
30
|
+
* @example farm.layer('soil').query([0, 0], [4, 4]).filter(c => c.data.watered).length
|
|
31
|
+
* @param {[number, number]} [cell]
|
|
32
|
+
* @param {[number, number]} [size]
|
|
33
|
+
* @returns {{ cell: [number, number], data: Record<string, any> }[]}
|
|
34
|
+
*/
|
|
35
|
+
query(cell?: [number, number], size?: [number, number]): {
|
|
36
|
+
cell: [number, number];
|
|
37
|
+
data: Record<string, any>;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* Change every non-empty cell at once (call it inside an op, e.g. a daily reset). fn may edit the data it gets (a copy) in place;
|
|
41
|
+
* returning null clears the cell, returning an object replaces the data. A cell left with no fields is cleared
|
|
42
|
+
* @example farm.layer('soil').updateAll(d => { delete d.watered; })
|
|
43
|
+
* @param {(data: Record<string, any>, cell: [number, number]) => any} fn
|
|
44
|
+
* @returns {number} cells left
|
|
45
|
+
*/
|
|
46
|
+
updateAll(fn: (data: Record<string, any>, cell: [number, number]) => any): number;
|
|
47
|
+
/** Number of non-empty cells @returns {number} */
|
|
48
|
+
get count(): number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options of grid.layer(name, opts)
|
|
52
|
+
*/
|
|
53
|
+
export type LayerOptions = {
|
|
54
|
+
tiles?: boolean | {
|
|
55
|
+
look?: (data: Record<string, any>, cell: [number, number]) => any;
|
|
56
|
+
lift?: number;
|
|
57
|
+
} | ((engine: any, layer: Layer) => {
|
|
58
|
+
update?: (cells: {
|
|
59
|
+
cell: [number, number];
|
|
60
|
+
data: Record<string, any>;
|
|
61
|
+
}[]) => void;
|
|
62
|
+
dispose?: () => void;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
|
|
4
|
+
* @example engine.use(world(), grids())
|
|
5
|
+
* @returns {import('../../../core').ModuleDef<Grids>}
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export function grids(): import("../../../core").ModuleDef<Grids>;
|
|
9
|
+
/**
|
|
10
|
+
* engine.grids: every placement grid, the item rules, previews and the occupancy index
|
|
11
|
+
* @example
|
|
12
|
+
* const farm = engine.grids.add('farm', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
13
|
+
* engine.grids.define('bed', { size: [2, 1], kind: 'furniture', fields: { model: 'bed' } });
|
|
14
|
+
* engine.ops.run('grid.place', { grid: 'farm', item: 'bed', cell: [4, 4], rotation: 1 });
|
|
15
|
+
* @experimental
|
|
16
|
+
*/
|
|
17
|
+
export class Grids {
|
|
18
|
+
/**
|
|
19
|
+
* Create a grid. cell: edge length (m, default 1); origin: world [x, z] of the min corner of cell [0, 0]; size: [cells wide, cells deep] (omit = unbounded);
|
|
20
|
+
* zone: level name (tiles only show there); flat: max height difference under a footprint (m, default 0.5);
|
|
21
|
+
* layers: authored cells { soil: [[i, j, { tilled: true }], ...] } (content/grids.js): the baseline a save diffs against, so a save keeps only changed cells
|
|
22
|
+
* @example const room = engine.grids.add('room', { cell: 0.5, origin: [-3, -3], size: [12, 12], zone: 'house' })
|
|
23
|
+
* @param {string} name
|
|
24
|
+
* @param {{ cell?: number, origin?: any, size?: [number, number], zone?: string, flat?: number, layers?: Record<string, [number, number, Record<string, any>][]> }} [opts]
|
|
25
|
+
* @returns {Grid}
|
|
26
|
+
*/
|
|
27
|
+
add(name: string, opts?: {
|
|
28
|
+
cell?: number;
|
|
29
|
+
origin?: any;
|
|
30
|
+
size?: [number, number];
|
|
31
|
+
zone?: string;
|
|
32
|
+
flat?: number;
|
|
33
|
+
layers?: Record<string, [number, number, Record<string, any>][]>;
|
|
34
|
+
}): Grid;
|
|
35
|
+
/**
|
|
36
|
+
* A grid by name, or null when there is none
|
|
37
|
+
* @param {string} name
|
|
38
|
+
* @returns {Grid | null}
|
|
39
|
+
*/
|
|
40
|
+
get(name: string): Grid | null;
|
|
41
|
+
/** All grids (a new array) @returns {Grid[]} */
|
|
42
|
+
list(): Grid[];
|
|
43
|
+
/**
|
|
44
|
+
* Register what can be placed and its rules. size [w, d] in cells (default [1, 1]); kind of the world record (default the item name);
|
|
45
|
+
* ground: allowed engine.groundType values; layer: { layerName: field } that must be truthy on every cell (reason 'not' + Field, e.g. notTilled);
|
|
46
|
+
* flat: max height difference (overrides the grid's); fields: copied into the record; can(e, { grid, cell, rotation, cells }): your own rule
|
|
47
|
+
* @example engine.grids.define('crop', { size: [1, 1], layer: { soil: 'tilled' }, fields: { plantedAt: 0 } })
|
|
48
|
+
* @example engine.grids.define('shed', { size: [3, 2], ground: ['grass', 'dirt'], flat: 0.2 })
|
|
49
|
+
* @param {string} name
|
|
50
|
+
* @param {import('./Grid.js').GridRule} rule
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
define(name: string, rule: import("./Grid.js").GridRule): void;
|
|
54
|
+
/**
|
|
55
|
+
* Show where an item would go: the target cell under the pointer ('pointer', default), in front of the player ('front') or from your
|
|
56
|
+
* function, turned by the input action rotate (default name 'rotate'; the game binds it, or pass rotateKeys / ...presets.keys.gridRotate, the engine binds no key itself), light when can() passes, dark otherwise (neutral tool colors; style.grid.ok / bad override them).
|
|
57
|
+
* look: false = no visual; (engine) => ({ update(view), hide(), dispose() }) = your own. place() runs grid.place with what is shown
|
|
58
|
+
* @example engine.input.define('place', ['Mouse0']); // the game's own binding
|
|
59
|
+
* const pv = engine.grids.preview({ grid: 'farm', item: 'crop', ...presets.keys.gridRotate });
|
|
60
|
+
* engine.onFrame(() => { if (engine.input.pressed('place')) { const r = pv.place(); if (!r.ok) toast(engine, engine.t('grid.' + r.reason)); } });
|
|
61
|
+
* @param {{ grid: string, item: string, from?: 'pointer' | 'front' | ((e: any) => any), rotate?: string | false, rotateKeys?: string[], rotation?: number, look?: false | ((e: any) => any) }} opts
|
|
62
|
+
* @returns {{ cell: [number, number] | null, rotation: number, ok: boolean, reason: string | null, rotate(n?: number): void, place(fields?: object): { ok: boolean, value?: any, reason?: string }, remove(): void }}
|
|
63
|
+
*/
|
|
64
|
+
preview(opts: {
|
|
65
|
+
grid: string;
|
|
66
|
+
item: string;
|
|
67
|
+
from?: "pointer" | "front" | ((e: any) => any);
|
|
68
|
+
rotate?: string | false;
|
|
69
|
+
rotateKeys?: string[];
|
|
70
|
+
rotation?: number;
|
|
71
|
+
look?: false | ((e: any) => any);
|
|
72
|
+
}): {
|
|
73
|
+
cell: [number, number] | null;
|
|
74
|
+
rotation: number;
|
|
75
|
+
ok: boolean;
|
|
76
|
+
reason: string | null;
|
|
77
|
+
rotate(n?: number): void;
|
|
78
|
+
place(fields?: object): {
|
|
79
|
+
ok: boolean;
|
|
80
|
+
value?: any;
|
|
81
|
+
reason?: string;
|
|
82
|
+
};
|
|
83
|
+
remove(): void;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
import { Grid } from './Grid.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/hlod/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* HLOD (merge far buildings into a few meshes) -> engine.hlod
|
|
4
|
+
* @param {HlodOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Hlod>}
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export function hlod(opts?: HlodOptions): ModuleDef<Hlod>;
|
|
9
|
+
import type { HlodOptions } from '../../../world';
|
|
10
|
+
import type { Hlod } from '../../../world';
|
|
11
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/hud/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Objective markers, counters, progress bars -> engine.hud
|
|
4
|
+
* @param {HudOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Hud>}
|
|
6
|
+
*/
|
|
7
|
+
export function hud(opts?: HudOptions): ModuleDef<Hud>;
|
|
8
|
+
import type { HudOptions } from '../../../gameplay';
|
|
9
|
+
import type { Hud } from '../../../gameplay';
|
|
10
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/lights/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Light pool (many light sources, a fixed number of real lights) -> engine.lightPool
|
|
4
|
+
* @param {LightPoolOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<LightPool>}
|
|
6
|
+
* @example
|
|
7
|
+
* engine.use(lightPool({ point: 8 })); // before engine.start(), so the startup compile covers these lights
|
|
8
|
+
* for (const t of torchMeshes) engine.lightPool.add(t, { color: 0xffa040, intensity: 4, distance: 8, flicker: (time, i) => 0.85 + 0.15 * Math.sin(time * 13 + i) });
|
|
9
|
+
*/
|
|
10
|
+
export function lightPool(opts?: LightPoolOptions): ModuleDef<LightPool>;
|
|
11
|
+
import type { LightPoolOptions } from '../../../world';
|
|
12
|
+
import type { LightPool } from '../../../world';
|
|
13
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/music/Music.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Background music -> engine.music. tracks; rules; fade: default fade seconds (2); duckDialogue: duck the music bus to this level during dialogue (default
|
|
4
|
+
* false = off; e.g. 0.35); duckFade; hold: rule debounce seconds (2)
|
|
5
|
+
* @param {MusicOptions} [opts]
|
|
6
|
+
* @returns {ModuleDef<Music>}
|
|
7
|
+
* @example engine.use(music({ tracks: { explore: '/music/explore.ogg' }, rules: [{ track: 'explore' }] }));
|
|
8
|
+
*/
|
|
9
|
+
export function music(opts?: MusicOptions): ModuleDef<Music>;
|
|
10
|
+
/** engine.music */
|
|
11
|
+
export class Music {
|
|
12
|
+
/** Registered tracks @type {Map<string, { url?: string, volume?: number, loop?: boolean, stems?: { url: string, at?: number[], volume?: number }[] }>} */
|
|
13
|
+
tracks: Map<string, {
|
|
14
|
+
url?: string;
|
|
15
|
+
volume?: number;
|
|
16
|
+
loop?: boolean;
|
|
17
|
+
stems?: {
|
|
18
|
+
url: string;
|
|
19
|
+
at?: number[];
|
|
20
|
+
volume?: number;
|
|
21
|
+
}[];
|
|
22
|
+
}>;
|
|
23
|
+
/** Name of the track playing (or wanted) @type {string | null} */
|
|
24
|
+
current: string | null;
|
|
25
|
+
/** 0-1: how loud each stem of the playing track is (see the stems `at` range); fades in about half a second @type {number} */
|
|
26
|
+
intensity: number;
|
|
27
|
+
/**
|
|
28
|
+
* Register tracks: { name: url | { url, volume, loop, stems } }
|
|
29
|
+
* @param {Record<string, MusicTrack>} map
|
|
30
|
+
* @returns {this}
|
|
31
|
+
*/
|
|
32
|
+
addTracks(map: Record<string, MusicTrack>): this;
|
|
33
|
+
/**
|
|
34
|
+
* Whether audio is usable
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
get ready(): boolean;
|
|
38
|
+
/** Auto track rules are in use */
|
|
39
|
+
get ruled(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* State (for debugging and tests): gain is the playing track's fade level, stems each stem's level
|
|
42
|
+
* @returns {{ current: string | null, playing: string | null, pending: string | null, override: string | null, intensity: number, gain: number, stems:
|
|
43
|
+
* number[] }}
|
|
44
|
+
*/
|
|
45
|
+
get state(): {
|
|
46
|
+
current: string | null;
|
|
47
|
+
playing: string | null;
|
|
48
|
+
pending: string | null;
|
|
49
|
+
override: string | null;
|
|
50
|
+
intensity: number;
|
|
51
|
+
gain: number;
|
|
52
|
+
stems: number[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Play a track (cross-fade over fade seconds). Does nothing if it is already playing; force replays it
|
|
56
|
+
* @param {string | null} name
|
|
57
|
+
* @param {{ fade?: number, force?: boolean }} [opts]
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
play(name: string | null, opts?: {
|
|
61
|
+
fade?: number;
|
|
62
|
+
force?: boolean;
|
|
63
|
+
}): void;
|
|
64
|
+
/**
|
|
65
|
+
* Fade out and stop (fade over fade seconds)
|
|
66
|
+
* @param {number} [fade]
|
|
67
|
+
* @returns {void}
|
|
68
|
+
*/
|
|
69
|
+
stop(fade?: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Layer a one-shot piece (victory, discovered place...); the background dips to `duck` while it plays
|
|
72
|
+
* @param {string} name
|
|
73
|
+
* @param {{ duck?: number, volume?: number }} [opts]
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
stinger(name: string, opts?: {
|
|
77
|
+
duck?: number;
|
|
78
|
+
volume?: number;
|
|
79
|
+
}): void;
|
|
80
|
+
/**
|
|
81
|
+
* Set the auto track rules (null turns them off). opts: hold how many seconds a new result must be stable before switching, fade switch fade seconds,
|
|
82
|
+
* interval check interval
|
|
83
|
+
* @param {MusicRule[] | null} list
|
|
84
|
+
* @param {{ hold?: number, fade?: number, interval?: number }} [opts]
|
|
85
|
+
* @returns {this}
|
|
86
|
+
*/
|
|
87
|
+
rules(list: MusicRule[] | null, opts?: {
|
|
88
|
+
hold?: number;
|
|
89
|
+
fade?: number;
|
|
90
|
+
interval?: number;
|
|
91
|
+
}): this;
|
|
92
|
+
/**
|
|
93
|
+
* Pick a track by hand, pausing the rules; override(null) hands control back
|
|
94
|
+
* @param {string | null} name
|
|
95
|
+
* @param {{ fade?: number, force?: boolean }} [opts]
|
|
96
|
+
* @returns {void}
|
|
97
|
+
*/
|
|
98
|
+
override(name: string | null, opts?: {
|
|
99
|
+
fade?: number;
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}): void;
|
|
102
|
+
/**
|
|
103
|
+
* Which track the current rules would pick (without switching)
|
|
104
|
+
* @returns {string | null | undefined}
|
|
105
|
+
*/
|
|
106
|
+
pick(): string | null | undefined;
|
|
107
|
+
}
|
|
108
|
+
import type { MusicOptions } from '../../../gameplay';
|
|
109
|
+
import type { ModuleDef } from '../../../core';
|
|
110
|
+
import type { MusicRule } from '../../../gameplay';
|
|
111
|
+
import type { MusicTrack } from '../../../gameplay';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/net/Net.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** engine.net (installed by net()): role, who this machine is, connection state and counters. Changes go through engine.ops, never through net. @experimental */
|
|
3
|
+
export class Net {
|
|
4
|
+
/** 'host' or 'client' @type {'host' | 'client'} */
|
|
5
|
+
role: "host" | "client";
|
|
6
|
+
/**
|
|
7
|
+
* This machine's actor id on the host: 'player' on the host, e.g. 'guest-1' on a client (null until the first snapshot).
|
|
8
|
+
* A client calls itself 'player' locally (own avatar record, own bag), so game code rarely needs this; it is for showing names and for logs.
|
|
9
|
+
* @returns {string | null}
|
|
10
|
+
*/
|
|
11
|
+
get actor(): string | null;
|
|
12
|
+
/** Client: has a connection and an up-to-date mirror. Host: always true @returns {boolean} */
|
|
13
|
+
get connected(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Host: connected peers [{ id, actor }] (id from the transport, actor = world record / container id of that player). Client: []
|
|
16
|
+
* @returns {{ id: number, actor: string }[]}
|
|
17
|
+
*/
|
|
18
|
+
get peers(): {
|
|
19
|
+
id: number;
|
|
20
|
+
actor: string;
|
|
21
|
+
}[];
|
|
22
|
+
/** Client: requests sent and not answered yet (seq -> op name). Host: empty @returns {Map<number, string>} */
|
|
23
|
+
get pending(): Map<number, string>;
|
|
24
|
+
/** Message counters: in / out, plus diffs, snapshots, rejected (host) or gaps (client: lost diffs that forced a snapshot) @returns {Record<string, number>} */
|
|
25
|
+
get stats(): Record<string, number>;
|
|
26
|
+
/**
|
|
27
|
+
* Client: attach a new transport after the connection dropped; the host answers with a full snapshot. Pass the old key to keep the same actor (and bag).
|
|
28
|
+
* @param {any} transport
|
|
29
|
+
* @returns {void}
|
|
30
|
+
* @example
|
|
31
|
+
* engine.events.on('net:close', () => setTimeout(() => engine.net.reconnect(webSocket(url, { key: oldKey })), 2000));
|
|
32
|
+
*/
|
|
33
|
+
reconnect(transport: any): void;
|
|
34
|
+
}
|