@jgengine/core 0.9.0 → 0.11.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 +34 -3
- package/LICENSE +203 -661
- package/README.md +1 -1
- package/dist/ai/crowd.d.ts +55 -0
- package/dist/ai/crowd.js +114 -0
- package/dist/ai/flock.d.ts +5 -2
- package/dist/ai/flock.js +5 -2
- package/dist/ai/groupAssist.d.ts +1 -0
- package/dist/ai/groupAssist.js +1 -0
- package/dist/ai/heatSystem.d.ts +76 -0
- package/dist/ai/heatSystem.js +97 -0
- package/dist/ai/interestScheduler.d.ts +107 -0
- package/dist/ai/interestScheduler.js +118 -0
- package/dist/ai/jobBoard.d.ts +1 -0
- package/dist/ai/jobBoard.js +1 -0
- package/dist/ai/laneSelect.d.ts +5 -2
- package/dist/ai/laneSelect.js +5 -2
- package/dist/ai/mobBrain.d.ts +1 -0
- package/dist/ai/mobBrain.js +1 -0
- package/dist/ai/spawnDirector.d.ts +19 -1
- package/dist/ai/spawnDirector.js +53 -26
- package/dist/ai/spawnPoint.d.ts +7 -0
- package/dist/ai/spawnPoint.js +7 -0
- package/dist/ai/targetAcquisition.d.ts +84 -0
- package/dist/ai/targetAcquisition.js +92 -0
- package/dist/anim/easing.d.ts +19 -0
- package/dist/anim/easing.js +19 -0
- package/dist/anim/oscillator.d.ts +12 -0
- package/dist/anim/oscillator.js +25 -0
- package/dist/area/areaEffectField.d.ts +127 -0
- package/dist/area/areaEffectField.js +175 -0
- package/dist/area/stackPolicy.d.ts +47 -0
- package/dist/area/stackPolicy.js +99 -0
- package/dist/audio/audioFalloff.d.ts +5 -2
- package/dist/audio/music.d.ts +53 -0
- package/dist/audio/music.js +34 -0
- package/dist/audio/synth.d.ts +60 -0
- package/dist/audio/synth.js +8 -0
- package/dist/authoring.d.ts +15 -0
- package/dist/authoring.js +15 -0
- package/dist/board/laneBoard.d.ts +13 -0
- package/dist/board/laneBoard.js +13 -0
- package/dist/board/timelineBoard.d.ts +10 -0
- package/dist/board/timelineBoard.js +10 -0
- package/dist/combat/abilityKit.d.ts +18 -0
- package/dist/combat/abilityKit.js +24 -9
- package/dist/combat/animationState.d.ts +5 -0
- package/dist/combat/animationState.js +5 -0
- package/dist/combat/breakMeters.d.ts +10 -0
- package/dist/combat/breakMeters.js +10 -0
- package/dist/combat/castRunner.d.ts +5 -0
- package/dist/combat/castRunner.js +5 -0
- package/dist/combat/comboPoints.d.ts +5 -0
- package/dist/combat/comboPoints.js +5 -0
- package/dist/combat/comboString.d.ts +5 -0
- package/dist/combat/comboString.js +5 -0
- package/dist/combat/damageInterceptors.d.ts +192 -0
- package/dist/combat/damageInterceptors.js +251 -0
- package/dist/combat/damageMatchup.d.ts +68 -0
- package/dist/combat/damageMatchup.js +42 -0
- package/dist/combat/damageResolution.d.ts +63 -0
- package/dist/combat/damageResolution.js +50 -0
- package/dist/combat/death.d.ts +7 -1
- package/dist/combat/death.js +5 -0
- package/dist/combat/deathReason.d.ts +14 -0
- package/dist/combat/deathReason.js +1 -0
- package/dist/combat/defensiveWindow.d.ts +5 -0
- package/dist/combat/defensiveWindow.js +5 -0
- package/dist/combat/dotField.d.ts +47 -0
- package/dist/combat/dotField.js +52 -0
- package/dist/combat/downed.d.ts +5 -0
- package/dist/combat/downed.js +5 -0
- package/dist/combat/effects.d.ts +5 -0
- package/dist/combat/effects.js +5 -0
- package/dist/combat/encounterSequence.d.ts +258 -0
- package/dist/combat/encounterSequence.js +426 -0
- package/dist/combat/hitReaction.d.ts +57 -1
- package/dist/combat/hitReaction.js +45 -5
- package/dist/combat/magazine.d.ts +54 -0
- package/dist/combat/magazine.js +96 -0
- package/dist/combat/projectiles.d.ts +7 -2
- package/dist/combat/projectiles.js +48 -17
- package/dist/combat/receivedDamage.d.ts +117 -0
- package/dist/combat/receivedDamage.js +92 -0
- package/dist/combat/regenShield.d.ts +39 -0
- package/dist/combat/regenShield.js +49 -0
- package/dist/combat/renderCues.d.ts +51 -0
- package/dist/combat/renderCues.js +44 -0
- package/dist/combat/resourcePool.d.ts +5 -0
- package/dist/combat/resourcePool.js +5 -0
- package/dist/combat/rewardAllocation.d.ts +121 -0
- package/dist/combat/rewardAllocation.js +251 -0
- package/dist/combat/shotOrigin.d.ts +30 -1
- package/dist/combat/shotOrigin.js +70 -2
- package/dist/combat/statusApplication.d.ts +96 -0
- package/dist/combat/statusApplication.js +81 -0
- package/dist/combat/telegraph.d.ts +11 -2
- package/dist/combat/telegraph.js +11 -2
- package/dist/combat/thresholdCrossings.d.ts +85 -0
- package/dist/combat/thresholdCrossings.js +116 -0
- package/dist/combat.d.ts +34 -0
- package/dist/combat.js +34 -0
- package/dist/commands/commandRegistry.d.ts +11 -0
- package/dist/commands/commandRegistry.js +9 -2
- package/dist/crafting/crop.d.ts +18 -0
- package/dist/crafting/crop.js +18 -0
- package/dist/crafting/production.d.ts +5 -0
- package/dist/crafting/production.js +5 -0
- package/dist/devtools/rewriteTunables.d.ts +17 -0
- package/dist/devtools/rewriteTunables.js +276 -0
- package/dist/devtools/saveEndpoint.d.ts +46 -0
- package/dist/devtools/saveEndpoint.js +48 -0
- package/dist/devtools/transformTunables.d.ts +3 -0
- package/dist/devtools/transformTunables.js +3 -0
- package/dist/devtools/tunableSchema.d.ts +31 -0
- package/dist/devtools/tunableSchema.js +31 -0
- package/dist/economy/currency.d.ts +12 -1
- package/dist/economy/currency.js +12 -1
- package/dist/economy/listingBook.d.ts +91 -0
- package/dist/economy/listingBook.js +144 -0
- package/dist/economy/resourceLedger.d.ts +222 -0
- package/dist/economy/resourceLedger.js +353 -0
- package/dist/economy/sharedWallet.d.ts +14 -0
- package/dist/economy/sharedWallet.js +14 -0
- package/dist/economy/techTree.d.ts +12 -0
- package/dist/economy/techTree.js +12 -0
- package/dist/economy/wallet.d.ts +26 -2
- package/dist/economy/wallet.js +35 -6
- package/dist/editor/commands.d.ts +248 -0
- package/dist/editor/commands.js +865 -0
- package/dist/editor/document.d.ts +186 -0
- package/dist/editor/document.js +884 -0
- package/dist/editor/grid.d.ts +229 -0
- package/dist/editor/grid.js +366 -0
- package/dist/editor/gridAdapters.d.ts +80 -0
- package/dist/editor/gridAdapters.js +134 -0
- package/dist/editor/index.d.ts +97 -0
- package/dist/editor/index.js +10 -0
- package/dist/editor/liveSync.d.ts +127 -0
- package/dist/editor/liveSync.js +249 -0
- package/dist/editor/runtimeInspector.d.ts +88 -0
- package/dist/editor/runtimeInspector.js +239 -0
- package/dist/editor/types.d.ts +175 -0
- package/dist/editor/types.js +29 -0
- package/dist/faction/reputation.d.ts +5 -0
- package/dist/faction/reputation.js +5 -0
- package/dist/format/distance.d.ts +17 -0
- package/dist/format/distance.js +18 -0
- package/dist/format/duration.d.ts +27 -0
- package/dist/format/duration.js +45 -0
- package/dist/format/speed.d.ts +17 -0
- package/dist/format/speed.js +25 -0
- package/dist/game/connectedPlayers.d.ts +30 -0
- package/dist/game/connectedPlayers.js +21 -0
- package/dist/game/cosmetics.d.ts +9 -0
- package/dist/game/cosmetics.js +16 -0
- package/dist/game/defineGame.d.ts +141 -2
- package/dist/game/defineGame.js +39 -1
- package/dist/game/defineSystem.d.ts +88 -0
- package/dist/game/defineSystem.js +45 -0
- package/dist/game/dialogue.d.ts +33 -0
- package/dist/game/dialogue.js +21 -0
- package/dist/game/events.d.ts +50 -13
- package/dist/game/events.js +5 -0
- package/dist/game/feed.d.ts +33 -0
- package/dist/game/feed.js +35 -2
- package/dist/game/gamePhase.d.ts +11 -0
- package/dist/game/gamePhase.js +16 -0
- package/dist/game/keyValueStore.d.ts +25 -0
- package/dist/game/keyValueStore.js +61 -0
- package/dist/game/leaderboard.d.ts +5 -0
- package/dist/game/leaderboard.js +5 -0
- package/dist/game/levelSequence.d.ts +24 -2
- package/dist/game/levelSequence.js +51 -2
- package/dist/game/loadout.d.ts +5 -0
- package/dist/game/loadout.js +5 -0
- package/dist/game/lootFilter.d.ts +2 -0
- package/dist/game/lootFilter.js +2 -0
- package/dist/game/lootPipeline.d.ts +164 -0
- package/dist/game/lootPipeline.js +216 -0
- package/dist/game/lootTable.d.ts +21 -0
- package/dist/game/lootTable.js +15 -4
- package/dist/game/modelAnimation.d.ts +8 -0
- package/dist/game/modelAnimation.js +18 -0
- package/dist/game/objectives.d.ts +43 -0
- package/dist/game/objectives.js +36 -0
- package/dist/game/paramLayers.d.ts +148 -0
- package/dist/game/paramLayers.js +185 -0
- package/dist/game/ping.d.ts +5 -0
- package/dist/game/ping.js +5 -0
- package/dist/game/playableGame.d.ts +160 -12
- package/dist/game/quest.d.ts +8 -0
- package/dist/game/quest.js +29 -0
- package/dist/game/race.d.ts +141 -0
- package/dist/game/race.js +169 -0
- package/dist/game/recordBook.d.ts +5 -5
- package/dist/game/recordBook.js +4 -1
- package/dist/game/ruleSelection.d.ts +75 -0
- package/dist/game/ruleSelection.js +127 -0
- package/dist/game/runDraft.d.ts +5 -0
- package/dist/game/runDraft.js +5 -0
- package/dist/game/saveStore.d.ts +111 -0
- package/dist/game/saveStore.js +312 -0
- package/dist/game/snapshotHistory.d.ts +67 -0
- package/dist/game/snapshotHistory.js +95 -0
- package/dist/game/social.d.ts +38 -1
- package/dist/game/social.js +71 -0
- package/dist/game/spawnPoints.d.ts +5 -0
- package/dist/game/spawnPoints.js +5 -0
- package/dist/game/systemRuntime.d.ts +50 -0
- package/dist/game/systemRuntime.js +157 -0
- package/dist/game/systemSchedule.d.ts +72 -0
- package/dist/game/systemSchedule.js +242 -0
- package/dist/game/toasts.d.ts +43 -0
- package/dist/game/toasts.js +44 -0
- package/dist/game/trade.d.ts +10 -0
- package/dist/game/trade.js +10 -0
- package/dist/game/unlocks.d.ts +8 -0
- package/dist/game/unlocks.js +16 -0
- package/dist/game/vfxInstance.d.ts +138 -0
- package/dist/game/vfxInstance.js +96 -0
- package/dist/game/worldItem.d.ts +17 -4
- package/dist/game/worldItem.js +17 -4
- package/dist/gameplay.d.ts +91 -0
- package/dist/gameplay.js +91 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -7
- package/dist/input/actionBindings.d.ts +24 -5
- package/dist/input/actionBindings.js +23 -5
- package/dist/input/axisInput.d.ts +13 -1
- package/dist/input/axisInput.js +22 -1
- package/dist/input/controlGroups.d.ts +67 -0
- package/dist/input/controlGroups.js +41 -0
- package/dist/input/touchScheme.d.ts +82 -6
- package/dist/input/touchScheme.js +123 -10
- package/dist/interaction/contextMenu.d.ts +1 -0
- package/dist/interaction/contextMenu.js +1 -0
- package/dist/interaction/lockpick.d.ts +61 -0
- package/dist/interaction/lockpick.js +168 -0
- package/dist/interaction/proximityPrompt.d.ts +5 -1
- package/dist/interaction/proximityPrompt.js +5 -3
- package/dist/interaction/qte.d.ts +5 -0
- package/dist/interaction/qte.js +5 -0
- package/dist/interaction/skillCheck.d.ts +5 -0
- package/dist/interaction/skillCheck.js +5 -0
- package/dist/inventory/inventoryModel.d.ts +12 -0
- package/dist/inventory/inventoryModel.js +12 -0
- package/dist/inventory/shapedGrid.d.ts +16 -0
- package/dist/inventory/shapedGrid.js +16 -0
- package/dist/inventory/slotModel.d.ts +10 -0
- package/dist/inventory/slotModel.js +10 -0
- package/dist/item/durability.d.ts +5 -0
- package/dist/item/durability.js +5 -0
- package/dist/item/itemIdentity.d.ts +171 -0
- package/dist/item/itemIdentity.js +138 -0
- package/dist/item/itemInstanceRegistry.d.ts +32 -0
- package/dist/item/itemInstanceRegistry.js +34 -0
- package/dist/item/itemgen.d.ts +163 -0
- package/dist/item/itemgen.js +151 -0
- package/dist/item/modularItem.d.ts +5 -0
- package/dist/item/modularItem.js +5 -0
- package/dist/item/use.d.ts +5 -0
- package/dist/item/use.js +5 -0
- package/dist/item/useBehavior.d.ts +142 -0
- package/dist/item/useBehavior.js +105 -0
- package/dist/item/weapon.d.ts +5 -0
- package/dist/item/weapon.js +5 -0
- package/dist/math/scalar.d.ts +25 -0
- package/dist/math/scalar.js +47 -0
- package/dist/meta/changelog.d.ts +4 -1
- package/dist/meta/changelog.js +36 -1
- package/dist/movement/avoidance.d.ts +45 -0
- package/dist/movement/avoidance.js +123 -0
- package/dist/movement/cameraRig.d.ts +8 -0
- package/dist/movement/cameraRig.js +8 -0
- package/dist/movement/dash.d.ts +11 -0
- package/dist/movement/dash.js +11 -0
- package/dist/movement/formation.d.ts +135 -0
- package/dist/movement/formation.js +194 -0
- package/dist/movement/glideModel.d.ts +5 -0
- package/dist/movement/glideModel.js +5 -0
- package/dist/movement/grappleSwing.d.ts +5 -0
- package/dist/movement/grappleSwing.js +5 -0
- package/dist/movement/leaderTrail.d.ts +5 -0
- package/dist/movement/leaderTrail.js +5 -0
- package/dist/movement/movementModel.d.ts +38 -7
- package/dist/movement/movementModel.js +54 -13
- package/dist/movement/playerMovement.d.ts +41 -0
- package/dist/movement/playerMovement.js +236 -0
- package/dist/movement/poseState.d.ts +13 -0
- package/dist/movement/poseState.js +16 -0
- package/dist/movement/steering.d.ts +8 -0
- package/dist/movement/steering.js +18 -0
- package/dist/multiplayer/combatSnapshot.d.ts +3 -0
- package/dist/multiplayer/combatSnapshot.js +3 -0
- package/dist/multiplayer/lagCompensation.d.ts +5 -0
- package/dist/multiplayer/lagCompensation.js +5 -0
- package/dist/multiplayer/presenceModel.d.ts +9 -1
- package/dist/multiplayer/presenceModel.js +9 -1
- package/dist/multiplayer/simultaneousCommit.d.ts +3 -0
- package/dist/multiplayer/simultaneousCommit.js +3 -0
- package/dist/multiplayer.d.ts +11 -0
- package/dist/multiplayer.js +11 -0
- package/dist/nav/pathFollow.d.ts +57 -0
- package/dist/nav/pathFollow.js +109 -0
- package/dist/orders/orderKinds.d.ts +156 -0
- package/dist/orders/orderKinds.js +197 -0
- package/dist/orders/orderQueue.d.ts +208 -0
- package/dist/orders/orderQueue.js +211 -0
- package/dist/physics/drivableVehicle.d.ts +29 -0
- package/dist/physics/drivableVehicle.js +16 -0
- package/dist/physics/kinematicVehicle.d.ts +21 -1
- package/dist/physics/kinematicVehicle.js +23 -8
- package/dist/physics/physicsWorld.d.ts +24 -12
- package/dist/physics/physicsWorld.js +11 -5
- package/dist/physics/radialImpulse.d.ts +25 -0
- package/dist/physics/radialImpulse.js +27 -0
- package/dist/procedural.d.ts +3 -0
- package/dist/procedural.js +3 -0
- package/dist/progression/statGraph.d.ts +116 -0
- package/dist/progression/statGraph.js +318 -0
- package/dist/puzzle/cellGrid.d.ts +9 -0
- package/dist/puzzle/cellGrid.js +9 -0
- package/dist/puzzle/fallingPiece.d.ts +9 -0
- package/dist/puzzle/fallingPiece.js +9 -0
- package/dist/puzzle/nonogram.d.ts +39 -0
- package/dist/puzzle/nonogram.js +136 -0
- package/dist/random/nameGen.d.ts +5 -0
- package/dist/random/nameGen.js +5 -0
- package/dist/random/pick.d.ts +8 -0
- package/dist/random/pick.js +31 -0
- package/dist/random/rng.d.ts +24 -0
- package/dist/random/rng.js +30 -8
- package/dist/random/seedLink.d.ts +4 -0
- package/dist/random/seedLink.js +4 -0
- package/dist/relation/keyedValues.d.ts +54 -0
- package/dist/relation/keyedValues.js +115 -0
- package/dist/relation/thresholds.d.ts +62 -0
- package/dist/relation/thresholds.js +62 -0
- package/dist/render/color.d.ts +12 -0
- package/dist/render/color.js +26 -0
- package/dist/render/lookPreset.d.ts +41 -0
- package/dist/render/lookPreset.js +29 -0
- package/dist/render/postProcessing.d.ts +76 -0
- package/dist/render/postProcessing.js +21 -0
- package/dist/rules/predicate.d.ts +53 -0
- package/dist/rules/predicate.js +64 -0
- package/dist/rules/ruleEffects.d.ts +38 -0
- package/dist/rules/ruleEffects.js +37 -0
- package/dist/rules/triggeredRules.d.ts +160 -0
- package/dist/rules/triggeredRules.js +241 -0
- package/dist/runtime/adapter.d.ts +58 -0
- package/dist/runtime/adapter.js +54 -5
- package/dist/runtime/cameraDirector.d.ts +1 -0
- package/dist/runtime/cameraDirector.js +1 -0
- package/dist/runtime/commandRunner.d.ts +1 -0
- package/dist/runtime/commandRunner.js +1 -0
- package/dist/runtime/context/combatFx.d.ts +23 -0
- package/dist/runtime/context/combatFx.js +161 -0
- package/dist/runtime/context/registries.d.ts +13 -0
- package/dist/runtime/context/registries.js +84 -0
- package/dist/runtime/context/worldItems.d.ts +21 -0
- package/dist/runtime/context/worldItems.js +37 -0
- package/dist/runtime/descriptors/baseline.d.ts +48 -0
- package/dist/runtime/descriptors/baseline.js +134 -0
- package/dist/runtime/descriptors/features.d.ts +74 -0
- package/dist/runtime/descriptors/features.js +281 -0
- package/dist/runtime/gameContext.d.ts +163 -19
- package/dist/runtime/gameContext.js +385 -339
- package/dist/runtime/gameRuntime.d.ts +1 -0
- package/dist/runtime/gameRuntime.js +1 -0
- package/dist/runtime/headlessRunner.d.ts +60 -0
- package/dist/runtime/headlessRunner.js +44 -0
- package/dist/runtime/hostPersistence.d.ts +12 -0
- package/dist/runtime/hostPersistence.js +12 -0
- package/dist/runtime/hostedGameRunner.d.ts +54 -0
- package/dist/runtime/hostedGameRunner.js +85 -0
- package/dist/runtime/hostedWorldSession.d.ts +73 -0
- package/dist/runtime/hostedWorldSession.js +64 -0
- package/dist/runtime/inputSnapshot.d.ts +21 -3
- package/dist/runtime/inputSnapshot.js +8 -2
- package/dist/runtime/motionIntents.d.ts +12 -1
- package/dist/runtime/motionIntents.js +26 -1
- package/dist/runtime/perContext.d.ts +15 -0
- package/dist/runtime/perContext.js +21 -0
- package/dist/runtime/runtimeSave.d.ts +79 -0
- package/dist/runtime/runtimeSave.js +105 -0
- package/dist/runtime/save.d.ts +4 -0
- package/dist/runtime/save.js +4 -0
- package/dist/runtime/snapshot.d.ts +7 -0
- package/dist/runtime/snapshot.js +7 -0
- package/dist/runtime/visibility.d.ts +2 -1
- package/dist/runtime/visibility.js +2 -1
- package/dist/runtime/worldChannel.d.ts +62 -0
- package/dist/runtime/worldChannel.js +114 -0
- package/dist/runtime/worldMirror.d.ts +36 -0
- package/dist/runtime/worldMirror.js +44 -0
- package/dist/runtime/worldProjection.d.ts +47 -0
- package/dist/runtime/worldProjection.js +52 -0
- package/dist/runtime/worldReplication.d.ts +69 -0
- package/dist/runtime/worldReplication.js +217 -0
- package/dist/runtime/worldSnapshot.d.ts +44 -0
- package/dist/runtime/worldSnapshot.js +30 -0
- package/dist/scene/assetCatalog.d.ts +22 -0
- package/dist/scene/assetCatalog.js +4 -0
- package/dist/scene/assetDiagnostics.d.ts +69 -0
- package/dist/scene/assetDiagnostics.js +110 -0
- package/dist/scene/assetGenerator.d.ts +65 -0
- package/dist/scene/assetGenerator.js +64 -0
- package/dist/scene/assetSpace.d.ts +137 -0
- package/dist/scene/assetSpace.js +259 -0
- package/dist/scene/authoredTriggers.d.ts +169 -0
- package/dist/scene/authoredTriggers.js +340 -0
- package/dist/scene/behaviorRuntime.d.ts +75 -0
- package/dist/scene/behaviorRuntime.js +217 -0
- package/dist/scene/behaviors.d.ts +14 -2
- package/dist/scene/behaviors.js +7 -2
- package/dist/scene/bodyBind.d.ts +60 -0
- package/dist/scene/bodyBind.js +51 -0
- package/dist/scene/builtinSceneKinds.d.ts +5 -0
- package/dist/scene/builtinSceneKinds.js +62 -0
- package/dist/scene/colliders.d.ts +18 -0
- package/dist/scene/colliders.js +61 -1
- package/dist/scene/entityStats.d.ts +13 -0
- package/dist/scene/entityStats.js +30 -0
- package/dist/scene/entityStore.d.ts +41 -1
- package/dist/scene/entityStore.js +75 -0
- package/dist/scene/facing.d.ts +18 -0
- package/dist/scene/facing.js +26 -0
- package/dist/scene/modelSockets.d.ts +33 -0
- package/dist/scene/modelSockets.js +29 -0
- package/dist/scene/objectQuery.d.ts +2 -0
- package/dist/scene/objectQuery.js +2 -0
- package/dist/scene/objectStore.d.ts +4 -0
- package/dist/scene/objectStore.js +6 -0
- package/dist/scene/possession.d.ts +8 -0
- package/dist/scene/possession.js +14 -0
- package/dist/scene/roster.d.ts +3 -0
- package/dist/scene/roster.js +12 -0
- package/dist/scene/sceneKinds.d.ts +240 -0
- package/dist/scene/sceneKinds.js +214 -0
- package/dist/scene/sceneOwnership.d.ts +169 -0
- package/dist/scene/sceneOwnership.js +179 -0
- package/dist/scene/selectionBookmarks.d.ts +93 -0
- package/dist/scene/selectionBookmarks.js +122 -0
- package/dist/scene/vehicleSeat.d.ts +68 -0
- package/dist/scene/vehicleSeat.js +59 -0
- package/dist/sensor/concealment.d.ts +3 -0
- package/dist/sensor/concealment.js +3 -0
- package/dist/sensor/freezeMonitor.d.ts +1 -0
- package/dist/sensor/freezeMonitor.js +1 -0
- package/dist/sensor/frustumSensor.d.ts +7 -3
- package/dist/sensor/frustumSensor.js +7 -3
- package/dist/sensor/hiddenStateProbe.d.ts +5 -2
- package/dist/sensor/hiddenStateProbe.js +5 -2
- package/dist/sensor/recordingBuffer.d.ts +2 -1
- package/dist/sensor/recordingBuffer.js +2 -1
- package/dist/sensor/replayLoop.d.ts +6 -2
- package/dist/sensor/replayLoop.js +6 -2
- package/dist/sensor/revealQuery.d.ts +2 -1
- package/dist/sensor/revealQuery.js +2 -1
- package/dist/sensor/visionCone.d.ts +10 -3
- package/dist/sensor/visionCone.js +10 -3
- package/dist/session/contestedChannel.d.ts +1 -0
- package/dist/session/contestedChannel.js +1 -0
- package/dist/session/extraction.d.ts +1 -0
- package/dist/session/extraction.js +1 -0
- package/dist/session/roles.d.ts +6 -0
- package/dist/session/roles.js +6 -0
- package/dist/session/roundState.d.ts +8 -0
- package/dist/session/roundState.js +2 -0
- package/dist/settings/settingsModel.d.ts +1 -0
- package/dist/settings/settingsModel.js +1 -0
- package/dist/stats/accumulatorMeter.d.ts +6 -0
- package/dist/stats/accumulatorMeter.js +6 -0
- package/dist/stats/eventMeter.d.ts +5 -0
- package/dist/stats/eventMeter.js +5 -0
- package/dist/stats/rollCheck.d.ts +5 -0
- package/dist/stats/rollCheck.js +5 -0
- package/dist/stats/statModifiers.d.ts +5 -0
- package/dist/stats/statModifiers.js +5 -0
- package/dist/store/defineKeyedStore.d.ts +38 -0
- package/dist/store/defineKeyedStore.js +42 -0
- package/dist/store/defineStore.d.ts +33 -0
- package/dist/store/defineStore.js +35 -0
- package/dist/store/observableKeyedStore.d.ts +9 -0
- package/dist/store/observableKeyedStore.js +43 -2
- package/dist/survival/decayMeter.d.ts +55 -0
- package/dist/survival/decayMeter.js +130 -55
- package/dist/survival/moodle.d.ts +2 -0
- package/dist/survival/regionHealth.d.ts +6 -0
- package/dist/survival/regionHealth.js +5 -0
- package/dist/tactics/fallingGrid.d.ts +6 -4
- package/dist/tactics/fallingGrid.js +6 -4
- package/dist/tactics/predictiveQuery.d.ts +3 -0
- package/dist/tactics/predictiveQuery.js +3 -0
- package/dist/tactics/snapshot.d.ts +2 -0
- package/dist/tactics/snapshot.js +2 -0
- package/dist/tactics/surface.d.ts +1 -0
- package/dist/tactics/surface.js +1 -0
- package/dist/tactics/tacticalGrid.d.ts +1 -0
- package/dist/tactics/tacticalGrid.js +1 -0
- package/dist/time/beatClock.d.ts +14 -4
- package/dist/time/beatClock.js +14 -4
- package/dist/time/calendarClock.d.ts +3 -0
- package/dist/time/calendarClock.js +3 -0
- package/dist/time/idleProgress.d.ts +4 -0
- package/dist/time/idleProgress.js +4 -0
- package/dist/time/simClock.d.ts +2 -0
- package/dist/time/simClock.js +20 -5
- package/dist/ui/actionModel.d.ts +110 -0
- package/dist/ui/actionModel.js +159 -0
- package/dist/ui/gameLayout.d.ts +144 -0
- package/dist/ui/gameLayout.js +148 -0
- package/dist/ui/hudDocument.d.ts +114 -0
- package/dist/ui/hudDocument.js +220 -0
- package/dist/ui/hudLayout.d.ts +33 -1
- package/dist/ui/hudLayout.js +204 -17
- package/dist/ui/orientation.d.ts +39 -0
- package/dist/ui/orientation.js +49 -0
- package/dist/ui/selectionModel.d.ts +92 -0
- package/dist/ui/selectionModel.js +88 -0
- package/dist/ui/swingTimer.d.ts +42 -0
- package/dist/ui/swingTimer.js +38 -0
- package/dist/ui/tooltipModel.d.ts +63 -0
- package/dist/ui/tooltipModel.js +82 -0
- package/dist/ui.d.ts +15 -0
- package/dist/ui.js +15 -0
- package/dist/visibility/bounds.d.ts +8 -1
- package/dist/visibility/bounds.js +8 -1
- package/dist/visibility/frustum.d.ts +12 -3
- package/dist/visibility/frustum.js +12 -3
- package/dist/visibility/spatialIndex.js +34 -20
- package/dist/work/jobQueue.d.ts +201 -0
- package/dist/work/jobQueue.js +253 -0
- package/dist/work/unitTraining.d.ts +58 -0
- package/dist/work/unitTraining.js +52 -0
- package/dist/world/authoredObjects.d.ts +58 -0
- package/dist/world/authoredObjects.js +69 -0
- package/dist/world/buildingGenerator.d.ts +18 -0
- package/dist/world/buildingGenerator.js +62 -0
- package/dist/world/buildings.d.ts +5 -0
- package/dist/world/buildings.js +5 -0
- package/dist/world/catenary.d.ts +22 -0
- package/dist/world/catenary.js +69 -0
- package/dist/world/environmentSummary.d.ts +11 -2
- package/dist/world/environmentSummary.js +11 -1
- package/dist/world/features.d.ts +244 -7
- package/dist/world/features.js +92 -4
- package/dist/world/footprintGrid.d.ts +59 -0
- package/dist/world/footprintGrid.js +141 -0
- package/dist/world/geometry.d.ts +64 -0
- package/dist/world/geometry.js +94 -0
- package/dist/world/grassKind.d.ts +51 -0
- package/dist/world/grassKind.js +101 -0
- package/dist/world/pathInstances.d.ts +27 -0
- package/dist/world/pathInstances.js +27 -0
- package/dist/world/pathTerrain.d.ts +80 -0
- package/dist/world/pathTerrain.js +142 -0
- package/dist/world/placeAsset.d.ts +81 -0
- package/dist/world/placeAsset.js +77 -0
- package/dist/world/placement.d.ts +4 -0
- package/dist/world/placement.js +4 -0
- package/dist/world/placementController.d.ts +6 -0
- package/dist/world/placementController.js +6 -0
- package/dist/world/polyline.d.ts +34 -0
- package/dist/world/polyline.js +81 -0
- package/dist/world/roads.d.ts +55 -0
- package/dist/world/roads.js +184 -0
- package/dist/world/scatterRegion.d.ts +164 -0
- package/dist/world/scatterRegion.js +409 -0
- package/dist/world/sceneShapes.d.ts +43 -0
- package/dist/world/sceneShapes.js +1 -0
- package/dist/world/segment.d.ts +27 -0
- package/dist/world/segment.js +43 -0
- package/dist/world/soilKind.d.ts +48 -0
- package/dist/world/soilKind.js +92 -0
- package/dist/world/spatialSample.d.ts +241 -0
- package/dist/world/spatialSample.js +465 -0
- package/dist/world/streets.d.ts +80 -0
- package/dist/world/streets.js +144 -0
- package/dist/world/terraform.d.ts +213 -1
- package/dist/world/terraform.js +655 -20
- package/dist/world/terrain.d.ts +138 -12
- package/dist/world/terrain.js +346 -28
- package/dist/world/terrainGuides.d.ts +182 -0
- package/dist/world/terrainGuides.js +343 -0
- package/dist/world/vec2.d.ts +81 -0
- package/dist/world/vec2.js +128 -0
- package/dist/world/vec3.d.ts +49 -0
- package/dist/world/vec3.js +76 -0
- package/dist/world/vegetation.d.ts +71 -0
- package/dist/world/vegetation.js +151 -0
- package/dist/world/visibilityField.d.ts +154 -0
- package/dist/world/visibilityField.js +271 -0
- package/dist/world/volumetricClouds.d.ts +52 -0
- package/dist/world/volumetricClouds.js +43 -0
- package/dist/world/walls.d.ts +9 -0
- package/dist/world/walls.js +9 -0
- package/dist/world/waterKind.d.ts +55 -0
- package/dist/world/waterKind.js +99 -0
- package/dist/world.d.ts +132 -0
- package/dist/world.js +132 -0
- package/package.json +32 -8
- package/skills/jgengine/SKILL.md +51 -0
- package/skills/jgengine/api.md +434 -0
- package/skills/jgengine/capabilities.md +29 -0
- package/skills/jgengine/reference-cartridge.md +72 -0
- package/skills/jgengine-combat/SKILL.md +34 -0
- package/skills/jgengine-combat/api.md +549 -0
- package/skills/jgengine-combat/capabilities.md +169 -0
- package/skills/jgengine-combat/reference.md +98 -0
- package/skills/jgengine-gameplay/SKILL.md +39 -0
- package/skills/jgengine-gameplay/api.md +1794 -0
- package/skills/jgengine-gameplay/capabilities.md +378 -0
- package/skills/jgengine-gameplay/reference-systems.md +60 -0
- package/skills/jgengine-world/SKILL.md +38 -0
- package/skills/jgengine-world/api.md +2652 -0
- package/skills/jgengine-world/capabilities.md +370 -0
- package/skills/jgengine-world/reference.md +222 -0
- package/dist/cartridge/runtime.d.ts +0 -15
- package/dist/cartridge/runtime.js +0 -556
- package/dist/cartridge/spec.d.ts +0 -188
- package/dist/cartridge/spec.js +0 -19
- package/dist/cartridge/validate.d.ts +0 -2
- package/dist/cartridge/validate.js +0 -78
- package/dist/store/engineStore.d.ts +0 -22
- package/dist/store/engineStore.js +0 -50
- package/dist/store/features.d.ts +0 -10
- package/dist/store/features.js +0 -23
- package/llms.txt +0 -4983
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function clamp01(value) {
|
|
2
|
+
if (value < 0)
|
|
3
|
+
return 0;
|
|
4
|
+
if (value > 1)
|
|
5
|
+
return 1;
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve one status application: reject on immunity, roll landing chance against injected RNG,
|
|
10
|
+
* scale magnitude/duration by the matchup, then fold into any existing instance per the stacking
|
|
11
|
+
* policy. Deterministic given a seeded `rng`; pure over serializable data, so authority can run it
|
|
12
|
+
* and replicate only the returned `instance`.
|
|
13
|
+
*
|
|
14
|
+
* @capability status-application resolve a data-defined status application with chance, matchup scaling, and stacking policy
|
|
15
|
+
*/
|
|
16
|
+
export function resolveStatusApplication(input) {
|
|
17
|
+
const { spec, scale, current, immunity, source } = input;
|
|
18
|
+
const rng = input.rng ?? Math.random;
|
|
19
|
+
if (immunity?.statuses?.includes(spec.status) === true) {
|
|
20
|
+
return { kind: "immune", instance: current ?? null, chance: 0, roll: null };
|
|
21
|
+
}
|
|
22
|
+
const present = current ?? null;
|
|
23
|
+
const policy = spec.stack ?? { kind: "refresh" };
|
|
24
|
+
if (present !== null && policy.kind === "ignore") {
|
|
25
|
+
return { kind: "ignored", instance: present, chance: 0, roll: null };
|
|
26
|
+
}
|
|
27
|
+
const chance = clamp01((spec.chance ?? 1) * (scale?.applyChance ?? 1));
|
|
28
|
+
const roll = rng();
|
|
29
|
+
if (roll >= chance) {
|
|
30
|
+
return { kind: "missed", instance: present, chance, roll };
|
|
31
|
+
}
|
|
32
|
+
const magnitude = (spec.magnitude ?? 0) * (scale?.magnitude ?? 1);
|
|
33
|
+
const durationMs = (spec.durationMs ?? 0) * (scale?.duration ?? 1);
|
|
34
|
+
const ticks = Math.round((spec.ticks ?? 0) * (scale?.duration ?? 1));
|
|
35
|
+
if (present === null) {
|
|
36
|
+
const instance = {
|
|
37
|
+
status: spec.status,
|
|
38
|
+
stacks: 1,
|
|
39
|
+
remainingMs: durationMs,
|
|
40
|
+
ticks,
|
|
41
|
+
magnitude,
|
|
42
|
+
...(source !== undefined ? { source } : {}),
|
|
43
|
+
};
|
|
44
|
+
return { kind: "applied", instance, chance, roll };
|
|
45
|
+
}
|
|
46
|
+
if (policy.kind === "replace") {
|
|
47
|
+
const instance = {
|
|
48
|
+
status: spec.status,
|
|
49
|
+
stacks: 1,
|
|
50
|
+
remainingMs: durationMs,
|
|
51
|
+
ticks,
|
|
52
|
+
magnitude,
|
|
53
|
+
...(source !== undefined ? { source } : {}),
|
|
54
|
+
};
|
|
55
|
+
return { kind: "replaced", instance, chance, roll };
|
|
56
|
+
}
|
|
57
|
+
if (policy.kind === "stack") {
|
|
58
|
+
const add = policy.add ?? 1;
|
|
59
|
+
const max = policy.max ?? Number.POSITIVE_INFINITY;
|
|
60
|
+
const stacks = Math.min(max, present.stacks + add);
|
|
61
|
+
const instance = {
|
|
62
|
+
status: spec.status,
|
|
63
|
+
stacks,
|
|
64
|
+
remainingMs: durationMs,
|
|
65
|
+
ticks,
|
|
66
|
+
magnitude,
|
|
67
|
+
...(source !== undefined ? { source } : present.source !== undefined ? { source: present.source } : {}),
|
|
68
|
+
};
|
|
69
|
+
return { kind: "stacked", instance, chance, roll };
|
|
70
|
+
}
|
|
71
|
+
// refresh: reset duration/ticks/magnitude, keep stack count.
|
|
72
|
+
const instance = {
|
|
73
|
+
status: spec.status,
|
|
74
|
+
stacks: present.stacks,
|
|
75
|
+
remainingMs: durationMs,
|
|
76
|
+
ticks,
|
|
77
|
+
magnitude,
|
|
78
|
+
...(source !== undefined ? { source } : present.source !== undefined ? { source: present.source } : {}),
|
|
79
|
+
};
|
|
80
|
+
return { kind: "refreshed", instance, chance, roll };
|
|
81
|
+
}
|
|
@@ -23,6 +23,7 @@ export interface TelegraphConfig {
|
|
|
23
23
|
turns?: number;
|
|
24
24
|
kind?: string;
|
|
25
25
|
}
|
|
26
|
+
/** @internal */
|
|
26
27
|
export declare function telegraphProgress(windupMs: number, startedAtMs: number, nowMs: number): number;
|
|
27
28
|
export interface HazardCycleConfig {
|
|
28
29
|
windupMs: number;
|
|
@@ -45,12 +46,20 @@ export interface HazardCycleSample {
|
|
|
45
46
|
* Deterministic repeating hazard timing — windup → active → cooldown as a pure function of absolute
|
|
46
47
|
* time, for recurring flame vents, crushers, lightning rings. Sample `hazardCycleAt` each tick: draw
|
|
47
48
|
* the telegraph during `windup`, apply the effect during `active`, rest through `cooldown`.
|
|
48
|
-
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
49
51
|
export declare function hazardCycleAt(config: HazardCycleConfig, nowMs: number): HazardCycleSample;
|
|
50
|
-
/** Absolute time the hazard's next `active` phase begins at or after `nowMs` — the countdown seam.
|
|
52
|
+
/** Absolute time the hazard's next `active` phase begins at or after `nowMs` — the countdown seam.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
51
55
|
export declare function nextHazardActiveAt(config: HazardCycleConfig, nowMs: number): number;
|
|
56
|
+
/** @internal */
|
|
52
57
|
export declare function telegraphFired(windupMs: number, startedAtMs: number, nowMs: number): boolean;
|
|
58
|
+
/** @internal */
|
|
53
59
|
export declare function telegraphTurnProgress(config: TelegraphConfig, startedTurn: number, currentTurn: number): number;
|
|
60
|
+
/** @internal */
|
|
54
61
|
export declare function telegraphFiredAtTurn(config: TelegraphConfig, startedTurn: number, currentTurn: number): boolean;
|
|
62
|
+
/** @internal */
|
|
55
63
|
export declare function telegraphTurnsRemaining(config: TelegraphConfig, startedTurn: number, currentTurn: number): number;
|
|
64
|
+
/** @internal */
|
|
56
65
|
export declare function pointInTelegraph(config: TelegraphConfig, point: EntityPosition): boolean;
|
package/dist/combat/telegraph.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export function telegraphProgress(windupMs, startedAtMs, nowMs) {
|
|
2
3
|
if (windupMs <= 0)
|
|
3
4
|
return 1;
|
|
@@ -7,7 +8,8 @@ export function telegraphProgress(windupMs, startedAtMs, nowMs) {
|
|
|
7
8
|
* Deterministic repeating hazard timing — windup → active → cooldown as a pure function of absolute
|
|
8
9
|
* time, for recurring flame vents, crushers, lightning rings. Sample `hazardCycleAt` each tick: draw
|
|
9
10
|
* the telegraph during `windup`, apply the effect during `active`, rest through `cooldown`.
|
|
10
|
-
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
11
13
|
export function hazardCycleAt(config, nowMs) {
|
|
12
14
|
const cooldownMs = Math.max(0, config.cooldownMs ?? 0);
|
|
13
15
|
const cycleMs = config.windupMs + config.activeMs + cooldownMs;
|
|
@@ -41,7 +43,9 @@ export function hazardCycleAt(config, nowMs) {
|
|
|
41
43
|
cycleIndex,
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
|
-
/** Absolute time the hazard's next `active` phase begins at or after `nowMs` — the countdown seam.
|
|
46
|
+
/** Absolute time the hazard's next `active` phase begins at or after `nowMs` — the countdown seam.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
45
49
|
export function nextHazardActiveAt(config, nowMs) {
|
|
46
50
|
const sample = hazardCycleAt(config, nowMs);
|
|
47
51
|
if (sample.phase === "windup")
|
|
@@ -50,19 +54,23 @@ export function nextHazardActiveAt(config, nowMs) {
|
|
|
50
54
|
const restMs = sample.phase === "active" ? sample.remainingMs + cooldownMs : sample.remainingMs;
|
|
51
55
|
return nowMs + restMs + config.windupMs;
|
|
52
56
|
}
|
|
57
|
+
/** @internal */
|
|
53
58
|
export function telegraphFired(windupMs, startedAtMs, nowMs) {
|
|
54
59
|
return nowMs - startedAtMs >= windupMs;
|
|
55
60
|
}
|
|
61
|
+
/** @internal */
|
|
56
62
|
export function telegraphTurnProgress(config, startedTurn, currentTurn) {
|
|
57
63
|
const turns = config.turns ?? 0;
|
|
58
64
|
if (turns <= 0)
|
|
59
65
|
return 1;
|
|
60
66
|
return Math.max(0, Math.min(1, (currentTurn - startedTurn) / turns));
|
|
61
67
|
}
|
|
68
|
+
/** @internal */
|
|
62
69
|
export function telegraphFiredAtTurn(config, startedTurn, currentTurn) {
|
|
63
70
|
const turns = config.turns ?? 0;
|
|
64
71
|
return currentTurn - startedTurn >= turns;
|
|
65
72
|
}
|
|
73
|
+
/** @internal */
|
|
66
74
|
export function telegraphTurnsRemaining(config, startedTurn, currentTurn) {
|
|
67
75
|
const turns = config.turns ?? 0;
|
|
68
76
|
return Math.max(0, turns - (currentTurn - startedTurn));
|
|
@@ -70,6 +78,7 @@ export function telegraphTurnsRemaining(config, startedTurn, currentTurn) {
|
|
|
70
78
|
function planarDelta(config, point) {
|
|
71
79
|
return { dx: point[0] - config.at[0], dz: point[2] - config.at[2] };
|
|
72
80
|
}
|
|
81
|
+
/** @internal */
|
|
73
82
|
export function pointInTelegraph(config, point) {
|
|
74
83
|
const { shape } = config;
|
|
75
84
|
const { dx, dz } = planarDelta(config, point);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic numeric threshold-crossing tracker (#931).
|
|
3
|
+
*
|
|
4
|
+
* A reusable state helper that watches a single numeric source (boss HP percent,
|
|
5
|
+
* a resource pool, an armor gauge, an objective counter) and emits ordered
|
|
6
|
+
* crossing events as named thresholds are passed. Supports crossing direction,
|
|
7
|
+
* a hysteresis band to prevent chatter, a once/repeat policy, and skipped
|
|
8
|
+
* threshold handling (a single large jump emits every threshold it passed, in
|
|
9
|
+
* order). Deterministic and fully serializable so save/load round-trips cleanly.
|
|
10
|
+
*
|
|
11
|
+
* This is intentionally NOT boss-specific: health-gating, phase transitions,
|
|
12
|
+
* armor breaks, music stingers, and resource warnings are all the same
|
|
13
|
+
* primitive. Consumers wire emitted crossings to whatever effect they own —
|
|
14
|
+
* e.g. installing an immunity interceptor from `combat/damageInterceptors`.
|
|
15
|
+
*/
|
|
16
|
+
/** A named threshold on the numeric source. */
|
|
17
|
+
export interface ThresholdMark {
|
|
18
|
+
/** Stable identifier emitted on crossing and used in the fired-once ledger. */
|
|
19
|
+
id: string;
|
|
20
|
+
/** The value at which this threshold sits. */
|
|
21
|
+
at: number;
|
|
22
|
+
}
|
|
23
|
+
/** The direction a crossing moved: `falling` = value decreased past the mark, `rising` = increased past it. */
|
|
24
|
+
export type CrossingDirection = "falling" | "rising";
|
|
25
|
+
/** Which directions should emit crossings. */
|
|
26
|
+
export type CrossingTrigger = "falling" | "rising" | "both";
|
|
27
|
+
/** Whether a threshold may fire repeatedly (`repeat`) or at most once per direction (`once`). */
|
|
28
|
+
export type CrossingPolicy = "once" | "repeat";
|
|
29
|
+
/** Caller configuration for a threshold tracker. */
|
|
30
|
+
export interface ThresholdCrossingConfig {
|
|
31
|
+
/** Thresholds to watch; order is irrelevant, the tracker sorts by `at`. */
|
|
32
|
+
thresholds: readonly ThresholdMark[];
|
|
33
|
+
/** Directions that emit crossings; defaults to `"both"`. */
|
|
34
|
+
trigger?: CrossingTrigger;
|
|
35
|
+
/** Symmetric dead-band around each mark that a value must fully clear to flip sides; defaults to `0`. */
|
|
36
|
+
hysteresis?: number;
|
|
37
|
+
/** `repeat` (default) re-fires on every crossing; `once` fires each threshold at most once per direction. */
|
|
38
|
+
policy?: CrossingPolicy;
|
|
39
|
+
/** Seed value. When provided, initial sides are computed from it and no crossing is emitted for the seed. */
|
|
40
|
+
initial?: number;
|
|
41
|
+
}
|
|
42
|
+
/** One emitted crossing: which threshold, which way, and the value span that produced it. */
|
|
43
|
+
export interface ThresholdCrossing {
|
|
44
|
+
/** The crossed threshold's id. */
|
|
45
|
+
id: string;
|
|
46
|
+
/** The crossed threshold's value. */
|
|
47
|
+
at: number;
|
|
48
|
+
/** Direction of the crossing. */
|
|
49
|
+
direction: CrossingDirection;
|
|
50
|
+
/** Value before this update. */
|
|
51
|
+
from: number;
|
|
52
|
+
/** Value after this update. */
|
|
53
|
+
to: number;
|
|
54
|
+
}
|
|
55
|
+
/** Serializable tracker state for save/load. */
|
|
56
|
+
export interface ThresholdTrackerSnapshot {
|
|
57
|
+
/** Last observed value, or `null` before the first observation. */
|
|
58
|
+
last: number | null;
|
|
59
|
+
/** Committed side (`"above"`/`"below"`) per threshold id. */
|
|
60
|
+
sides: Record<string, "above" | "below">;
|
|
61
|
+
/** Fired ledger entries (`"<id>:<direction>"`) for the `once` policy. */
|
|
62
|
+
fired: string[];
|
|
63
|
+
}
|
|
64
|
+
/** A stateful crossing tracker over one numeric source. */
|
|
65
|
+
export interface ThresholdTracker {
|
|
66
|
+
/** Observe a new value and return the crossings it produced, in travel order. */
|
|
67
|
+
update(value: number): ThresholdCrossing[];
|
|
68
|
+
/** The last observed value, or `null` before the first `update`/seed. */
|
|
69
|
+
value(): number | null;
|
|
70
|
+
/** Clear the fired ledger; reseed sides from `initial` if given, else await the next `update`. */
|
|
71
|
+
reset(initial?: number): void;
|
|
72
|
+
/** Serializable snapshot. */
|
|
73
|
+
snapshot(): ThresholdTrackerSnapshot;
|
|
74
|
+
/** Restore from a snapshot. */
|
|
75
|
+
restore(snap: ThresholdTrackerSnapshot): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Track a numeric source against named thresholds and emit ordered crossing
|
|
79
|
+
* events with direction, hysteresis, once/repeat policy, and skipped-threshold
|
|
80
|
+
* handling. Deterministic and serializable; drives phase transitions, armor
|
|
81
|
+
* breaks, resource warnings, and any other threshold consumer.
|
|
82
|
+
*
|
|
83
|
+
* @capability threshold-crossings emit ordered crossing events as a numeric source passes named thresholds with hysteresis and once/repeat policy
|
|
84
|
+
*/
|
|
85
|
+
export declare function createThresholdTracker(config: ThresholdCrossingConfig): ThresholdTracker;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic numeric threshold-crossing tracker (#931).
|
|
3
|
+
*
|
|
4
|
+
* A reusable state helper that watches a single numeric source (boss HP percent,
|
|
5
|
+
* a resource pool, an armor gauge, an objective counter) and emits ordered
|
|
6
|
+
* crossing events as named thresholds are passed. Supports crossing direction,
|
|
7
|
+
* a hysteresis band to prevent chatter, a once/repeat policy, and skipped
|
|
8
|
+
* threshold handling (a single large jump emits every threshold it passed, in
|
|
9
|
+
* order). Deterministic and fully serializable so save/load round-trips cleanly.
|
|
10
|
+
*
|
|
11
|
+
* This is intentionally NOT boss-specific: health-gating, phase transitions,
|
|
12
|
+
* armor breaks, music stingers, and resource warnings are all the same
|
|
13
|
+
* primitive. Consumers wire emitted crossings to whatever effect they own —
|
|
14
|
+
* e.g. installing an immunity interceptor from `combat/damageInterceptors`.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Track a numeric source against named thresholds and emit ordered crossing
|
|
18
|
+
* events with direction, hysteresis, once/repeat policy, and skipped-threshold
|
|
19
|
+
* handling. Deterministic and serializable; drives phase transitions, armor
|
|
20
|
+
* breaks, resource warnings, and any other threshold consumer.
|
|
21
|
+
*
|
|
22
|
+
* @capability threshold-crossings emit ordered crossing events as a numeric source passes named thresholds with hysteresis and once/repeat policy
|
|
23
|
+
*/
|
|
24
|
+
export function createThresholdTracker(config) {
|
|
25
|
+
const trigger = config.trigger ?? "both";
|
|
26
|
+
const hysteresis = Math.max(0, config.hysteresis ?? 0);
|
|
27
|
+
const policy = config.policy ?? "repeat";
|
|
28
|
+
const marks = [...config.thresholds].sort((a, b) => a.at - b.at);
|
|
29
|
+
const sides = new Map();
|
|
30
|
+
const fired = new Set();
|
|
31
|
+
let last = null;
|
|
32
|
+
function sideOf(value, at) {
|
|
33
|
+
return value >= at ? "above" : "below";
|
|
34
|
+
}
|
|
35
|
+
function seed(value) {
|
|
36
|
+
sides.clear();
|
|
37
|
+
for (const mark of marks)
|
|
38
|
+
sides.set(mark.id, sideOf(value, mark.at));
|
|
39
|
+
}
|
|
40
|
+
function allows(direction) {
|
|
41
|
+
return trigger === "both" || trigger === direction;
|
|
42
|
+
}
|
|
43
|
+
if (config.initial !== undefined) {
|
|
44
|
+
seed(config.initial);
|
|
45
|
+
last = config.initial;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
update(value) {
|
|
49
|
+
if (last === null) {
|
|
50
|
+
seed(value);
|
|
51
|
+
last = value;
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const from = last;
|
|
55
|
+
const crossings = [];
|
|
56
|
+
for (const mark of marks) {
|
|
57
|
+
const side = sides.get(mark.id);
|
|
58
|
+
if (side === undefined) {
|
|
59
|
+
sides.set(mark.id, sideOf(value, mark.at));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let next = null;
|
|
63
|
+
let direction = null;
|
|
64
|
+
if (side === "above" && value < mark.at - hysteresis) {
|
|
65
|
+
next = "below";
|
|
66
|
+
direction = "falling";
|
|
67
|
+
}
|
|
68
|
+
else if (side === "below" && value > mark.at + hysteresis) {
|
|
69
|
+
next = "above";
|
|
70
|
+
direction = "rising";
|
|
71
|
+
}
|
|
72
|
+
if (next === null || direction === null)
|
|
73
|
+
continue;
|
|
74
|
+
sides.set(mark.id, next);
|
|
75
|
+
if (!allows(direction))
|
|
76
|
+
continue;
|
|
77
|
+
const key = `${mark.id}:${direction}`;
|
|
78
|
+
if (policy === "once" && fired.has(key))
|
|
79
|
+
continue;
|
|
80
|
+
fired.add(key);
|
|
81
|
+
crossings.push({ id: mark.id, at: mark.at, direction, from, to: value });
|
|
82
|
+
}
|
|
83
|
+
last = value;
|
|
84
|
+
// Emit in travel order: falling crosses higher marks first, rising crosses lower marks first.
|
|
85
|
+
const falling = value < from;
|
|
86
|
+
crossings.sort((a, b) => (falling ? b.at - a.at : a.at - b.at));
|
|
87
|
+
return crossings;
|
|
88
|
+
},
|
|
89
|
+
value() {
|
|
90
|
+
return last;
|
|
91
|
+
},
|
|
92
|
+
reset(initial) {
|
|
93
|
+
fired.clear();
|
|
94
|
+
if (initial === undefined) {
|
|
95
|
+
sides.clear();
|
|
96
|
+
last = null;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
seed(initial);
|
|
100
|
+
last = initial;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
snapshot() {
|
|
104
|
+
return { last, sides: Object.fromEntries(sides), fired: [...fired] };
|
|
105
|
+
},
|
|
106
|
+
restore(snap) {
|
|
107
|
+
last = snap.last;
|
|
108
|
+
sides.clear();
|
|
109
|
+
for (const [id, side] of Object.entries(snap.sides))
|
|
110
|
+
sides.set(id, side);
|
|
111
|
+
fired.clear();
|
|
112
|
+
for (const key of snap.fired)
|
|
113
|
+
fired.add(key);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/dist/combat.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { createAbilityKit, type AbilityKit, type AbilitySlotSnapshot, type AbilitySlotState, } from "./combat/abilityKit.js";
|
|
2
|
+
export { type AnimationClip, type FrameRange } from "./combat/animationState.js";
|
|
3
|
+
export { attackMeta, counters, isBlockable, isDodgeable, isParryable } from "./combat/attackTags.js";
|
|
4
|
+
export { createBuildupMeter, createStaggerMeter, type BuildupProc } from "./combat/breakMeters.js";
|
|
5
|
+
export { createCastRunner } from "./combat/castRunner.js";
|
|
6
|
+
export { createComboPoints } from "./combat/comboPoints.js";
|
|
7
|
+
export { advanceCombo, createComboRunner, type ComboStep } from "./combat/comboString.js";
|
|
8
|
+
export { MAX_INTERCEPT_STEPS, createAntiOneShotPolicy, createDamageClamp, createDamagePipeline, createImmunityWindow, resolveDamage, type AntiOneShotConfig, type AntiOneShotPolicy, type DamageClampConfig, type DamageInterceptor, type DamagePipeline, type DamageResolution, type ImmunityWindow, type InterceptContext, type InterceptDecision, type InterceptRecord, type PendingDamage, } from "./combat/damageInterceptors.js";
|
|
9
|
+
export { resolveMatchup, type DamageChannelId, type DamageMatchup, type MatchupOutputs, type ResolvedMatchup, type TargetTraitId, } from "./combat/damageMatchup.js";
|
|
10
|
+
export { resolveDamageHit, type DamageHitInput, type DamageHitResolution } from "./combat/damageResolution.js";
|
|
11
|
+
export { createDeathSystem, type OnDeathSpec } from "./combat/death.js";
|
|
12
|
+
export { type DeathReason } from "./combat/deathReason.js";
|
|
13
|
+
export { createDefensiveWindow, resolveDefense } from "./combat/defensiveWindow.js";
|
|
14
|
+
export { createDotField } from "./combat/dotField.js";
|
|
15
|
+
export { createDownedState } from "./combat/downed.js";
|
|
16
|
+
export { createEffectSystem, type ReceiveMap } from "./combat/effects.js";
|
|
17
|
+
export { BUILTIN_COMPLETION_PREDICATES, BUILTIN_SPAWN_PROVIDERS, activePhaseId, createEncounterState, encounterProgress, forceCompletePhase, injectPhase, phaseStatus, startEncounter, updateEncounter, type CompletionPredicate, type EncounterConfig, type EncounterContext, type EncounterEvent, type EncounterPhase, type EncounterSignals, type EncounterSpawnRequest, type EncounterState, type EncounterStep, type PhaseCompletionRef, type PhaseInjectAt, type PhaseRuntime, type PhaseSpawnRef, type PhaseStatus, type PredicateContext, type SpawnProvider, type SpawnProviderContext, } from "./combat/encounterSequence.js";
|
|
18
|
+
export { impactPresets, resolveHitReaction, type HitReactionConfig } from "./combat/hitReaction.js";
|
|
19
|
+
export { createMagazine, type Magazine, type MagazineReserve } from "./combat/magazine.js";
|
|
20
|
+
export { createProjectileSystem, type ObjectRaycastHit, type ProjectileSystemDeps, type RaycastHit, } from "./combat/projectiles.js";
|
|
21
|
+
export { resolveReceivedDamage, type DamageContext, type DamagePredicate, type ReceivedDamageResult, type ReceivedModifier, type ReceivedPolicy, } from "./combat/receivedDamage.js";
|
|
22
|
+
export { createRegenShield } from "./combat/regenShield.js";
|
|
23
|
+
export { DEFAULT_FIRE_PULSE_SECONDS, DEFAULT_HIT_PULSE_SECONDS, DEFAULT_RENDER_CUES, advanceMotionCues, applyRenderAnimationEvent, applyRenderDeathEvent, applyRenderHitEvent, type EntityRenderCues, type RenderCueTuning, } from "./combat/renderCues.js";
|
|
24
|
+
export { resistanceScale, resolveResistance } from "./combat/resistance.js";
|
|
25
|
+
export { createResourcePool, type ResourcePool } from "./combat/resourcePool.js";
|
|
26
|
+
export { allocateRewards, filterOutcomeFor, resolveClaim, type AllocationOutcome, type AllocationRequest, type ClaimOutcome, type ClaimablePool, type RewardClaimSpec, type RewardGrant, type RewardPolicyKind, type RewardRecipient, type RewardResult, type RewardShare, } from "./combat/rewardAllocation.js";
|
|
27
|
+
export { DEFAULT_EYE_HEIGHT, convergeShot, eyeHeightFromColliders, resolveShot, type ShotOriginPolicy, } from "./combat/shotOrigin.js";
|
|
28
|
+
export { resolveStatusApplication, type StatusApplicationOutcome, type StatusApplicationSpec, type StatusImmunity, type StatusInstance, type StatusStackPolicy, } from "./combat/statusApplication.js";
|
|
29
|
+
export { type TelegraphConfig, type TelegraphShape } from "./combat/telegraph.js";
|
|
30
|
+
export { createThresholdTracker, type CrossingDirection, type CrossingPolicy, type CrossingTrigger, type ThresholdCrossing, type ThresholdCrossingConfig, type ThresholdMark, type ThresholdTracker, type ThresholdTrackerSnapshot, } from "./combat/thresholdCrossings.js";
|
|
31
|
+
export { createAccumulatorMeter, tierAt, type MeterAddResult } from "./stats/accumulatorMeter.js";
|
|
32
|
+
export { createEventMeter, type EventMeter, type EventMeterFeedResult } from "./stats/eventMeter.js";
|
|
33
|
+
export { rollCheck, type CheckAdvantage, type CheckResult } from "./stats/rollCheck.js";
|
|
34
|
+
export { createStats, type Stats } from "./stats/statModifiers.js";
|
package/dist/combat.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { createAbilityKit, } from "./combat/abilityKit.js";
|
|
2
|
+
export {} from "./combat/animationState.js";
|
|
3
|
+
export { attackMeta, counters, isBlockable, isDodgeable, isParryable } from "./combat/attackTags.js";
|
|
4
|
+
export { createBuildupMeter, createStaggerMeter } from "./combat/breakMeters.js";
|
|
5
|
+
export { createCastRunner } from "./combat/castRunner.js";
|
|
6
|
+
export { createComboPoints } from "./combat/comboPoints.js";
|
|
7
|
+
export { advanceCombo, createComboRunner } from "./combat/comboString.js";
|
|
8
|
+
export { MAX_INTERCEPT_STEPS, createAntiOneShotPolicy, createDamageClamp, createDamagePipeline, createImmunityWindow, resolveDamage, } from "./combat/damageInterceptors.js";
|
|
9
|
+
export { resolveMatchup, } from "./combat/damageMatchup.js";
|
|
10
|
+
export { resolveDamageHit } from "./combat/damageResolution.js";
|
|
11
|
+
export { createDeathSystem } from "./combat/death.js";
|
|
12
|
+
export {} from "./combat/deathReason.js";
|
|
13
|
+
export { createDefensiveWindow, resolveDefense } from "./combat/defensiveWindow.js";
|
|
14
|
+
export { createDotField } from "./combat/dotField.js";
|
|
15
|
+
export { createDownedState } from "./combat/downed.js";
|
|
16
|
+
export { createEffectSystem } from "./combat/effects.js";
|
|
17
|
+
export { BUILTIN_COMPLETION_PREDICATES, BUILTIN_SPAWN_PROVIDERS, activePhaseId, createEncounterState, encounterProgress, forceCompletePhase, injectPhase, phaseStatus, startEncounter, updateEncounter, } from "./combat/encounterSequence.js";
|
|
18
|
+
export { impactPresets, resolveHitReaction } from "./combat/hitReaction.js";
|
|
19
|
+
export { createMagazine } from "./combat/magazine.js";
|
|
20
|
+
export { createProjectileSystem, } from "./combat/projectiles.js";
|
|
21
|
+
export { resolveReceivedDamage, } from "./combat/receivedDamage.js";
|
|
22
|
+
export { createRegenShield } from "./combat/regenShield.js";
|
|
23
|
+
export { DEFAULT_FIRE_PULSE_SECONDS, DEFAULT_HIT_PULSE_SECONDS, DEFAULT_RENDER_CUES, advanceMotionCues, applyRenderAnimationEvent, applyRenderDeathEvent, applyRenderHitEvent, } from "./combat/renderCues.js";
|
|
24
|
+
export { resistanceScale, resolveResistance } from "./combat/resistance.js";
|
|
25
|
+
export { createResourcePool } from "./combat/resourcePool.js";
|
|
26
|
+
export { allocateRewards, filterOutcomeFor, resolveClaim, } from "./combat/rewardAllocation.js";
|
|
27
|
+
export { DEFAULT_EYE_HEIGHT, convergeShot, eyeHeightFromColliders, resolveShot, } from "./combat/shotOrigin.js";
|
|
28
|
+
export { resolveStatusApplication, } from "./combat/statusApplication.js";
|
|
29
|
+
export {} from "./combat/telegraph.js";
|
|
30
|
+
export { createThresholdTracker, } from "./combat/thresholdCrossings.js";
|
|
31
|
+
export { createAccumulatorMeter, tierAt } from "./stats/accumulatorMeter.js";
|
|
32
|
+
export { createEventMeter } from "./stats/eventMeter.js";
|
|
33
|
+
export { rollCheck } from "./stats/rollCheck.js";
|
|
34
|
+
export { createStats } from "./stats/statModifiers.js";
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export interface CommandRejection {
|
|
2
2
|
reason: string;
|
|
3
3
|
}
|
|
4
|
+
export type CommandDecodeResult<TInput> = {
|
|
5
|
+
ok: true;
|
|
6
|
+
value: TInput;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
/** Parses raw `unknown` transport input into `TInput`, rejecting anything that doesn't match the command's declared shape. Runs before `validate`/`apply`, so a malformed payload never reaches game logic. */
|
|
12
|
+
export type CommandDecoder<TInput> = (input: unknown) => CommandDecodeResult<TInput>;
|
|
4
13
|
export interface CommandDefinition<TState, TInput> {
|
|
14
|
+
/** Runtime codec for this command's input. Declaring one turns the boundary strict: a payload that fails to decode is rejected before `validate`/`apply` ever see it. Omit to keep passing raw input through unchanged (existing behavior). */
|
|
15
|
+
decode?: CommandDecoder<TInput>;
|
|
5
16
|
validate?(state: TState, input: TInput): CommandRejection | null;
|
|
6
17
|
apply(state: TState, input: TInput): TState | void;
|
|
7
18
|
}
|
|
@@ -17,10 +17,17 @@ export function createCommandRegistry() {
|
|
|
17
17
|
const definition = definitions.get(name);
|
|
18
18
|
if (!definition)
|
|
19
19
|
return { status: "unknown-command" };
|
|
20
|
-
|
|
20
|
+
let decoded = input;
|
|
21
|
+
if (definition.decode) {
|
|
22
|
+
const result = definition.decode(input);
|
|
23
|
+
if (!result.ok)
|
|
24
|
+
return { status: "rejected", reason: result.reason };
|
|
25
|
+
decoded = result.value;
|
|
26
|
+
}
|
|
27
|
+
const rejection = definition.validate?.(state, decoded) ?? null;
|
|
21
28
|
if (rejection)
|
|
22
29
|
return { status: "rejected", reason: rejection.reason };
|
|
23
|
-
const next = definition.apply(state,
|
|
30
|
+
const next = definition.apply(state, decoded);
|
|
24
31
|
return { status: "applied", state: next === undefined ? state : next };
|
|
25
32
|
},
|
|
26
33
|
};
|
package/dist/crafting/crop.d.ts
CHANGED
|
@@ -16,36 +16,53 @@ export interface CropTileState {
|
|
|
16
16
|
harvestable: boolean;
|
|
17
17
|
}
|
|
18
18
|
export type CropCatalog = (cropId: string) => CropDef | null;
|
|
19
|
+
/** @internal */
|
|
19
20
|
export declare function emptyTile(): CropTileState;
|
|
21
|
+
/** @internal */
|
|
20
22
|
export declare function canTill(state: CropTileState): boolean;
|
|
23
|
+
/** @internal */
|
|
21
24
|
export declare function tillTile(state: CropTileState): CropTileState;
|
|
25
|
+
/** @internal */
|
|
22
26
|
export declare function canPlant(state: CropTileState): boolean;
|
|
27
|
+
/** @internal */
|
|
23
28
|
export declare function plantCrop(state: CropTileState, cropId: string): CropTileState;
|
|
29
|
+
/** @internal */
|
|
24
30
|
export declare function waterTile(state: CropTileState): CropTileState;
|
|
31
|
+
/** @internal */
|
|
25
32
|
export declare function maturityDays(def: CropDef): number;
|
|
33
|
+
/** @internal */
|
|
26
34
|
export declare function advanceCropDay(def: CropDef, state: CropTileState): CropTileState;
|
|
27
35
|
export interface HarvestResult {
|
|
28
36
|
state: CropTileState;
|
|
29
37
|
yield: RecipeItem | null;
|
|
30
38
|
}
|
|
39
|
+
/** @internal */
|
|
31
40
|
export declare function harvestCrop(def: CropDef, state: CropTileState): HarvestResult;
|
|
32
41
|
export type TileCoord = readonly [number, number];
|
|
33
42
|
export type TilePattern = readonly TileCoord[];
|
|
43
|
+
/** @internal */
|
|
34
44
|
export declare function tileKey(coord: TileCoord): string;
|
|
45
|
+
/** @internal */
|
|
35
46
|
export declare function singleTile(): TilePattern;
|
|
47
|
+
/** @internal */
|
|
36
48
|
export declare function squarePattern(radius: number): TilePattern;
|
|
49
|
+
/** @internal */
|
|
37
50
|
export declare function diamondPattern(radius: number): TilePattern;
|
|
51
|
+
/** @internal */
|
|
38
52
|
export declare function rectPattern(width: number, depth: number): TilePattern;
|
|
53
|
+
/** @internal */
|
|
39
54
|
export declare function patternAt(center: TileCoord, pattern: TilePattern): TileCoord[];
|
|
40
55
|
export interface ApplyToolResult {
|
|
41
56
|
tiles: Map<string, CropTileState>;
|
|
42
57
|
changed: TileCoord[];
|
|
43
58
|
}
|
|
59
|
+
/** @internal */
|
|
44
60
|
export declare function applyToolToTiles(tiles: ReadonlyMap<string, CropTileState>, center: TileCoord, pattern: TilePattern, apply: (state: CropTileState, coord: TileCoord) => CropTileState, fill?: () => CropTileState): ApplyToolResult;
|
|
45
61
|
export interface DayTicker {
|
|
46
62
|
tick(currentDay: number): number;
|
|
47
63
|
day(): number;
|
|
48
64
|
}
|
|
65
|
+
/** @internal */
|
|
49
66
|
export declare function createDayTicker(startDay?: number): DayTicker;
|
|
50
67
|
export interface CropField {
|
|
51
68
|
get(coord: TileCoord): CropTileState;
|
|
@@ -56,4 +73,5 @@ export interface CropField {
|
|
|
56
73
|
advanceDay(days?: number): void;
|
|
57
74
|
tiles(): ReadonlyMap<string, CropTileState>;
|
|
58
75
|
}
|
|
76
|
+
/** @internal */
|
|
59
77
|
export declare function createCropField(catalog?: CropCatalog): CropField;
|
package/dist/crafting/crop.js
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export function emptyTile() {
|
|
2
3
|
return { soil: "untilled", watered: false, cropId: null, stage: 0, stageProgress: 0, harvestable: false };
|
|
3
4
|
}
|
|
5
|
+
/** @internal */
|
|
4
6
|
export function canTill(state) {
|
|
5
7
|
return state.soil === "untilled" && state.cropId === null;
|
|
6
8
|
}
|
|
9
|
+
/** @internal */
|
|
7
10
|
export function tillTile(state) {
|
|
8
11
|
if (!canTill(state))
|
|
9
12
|
return state;
|
|
10
13
|
return { ...state, soil: "tilled" };
|
|
11
14
|
}
|
|
15
|
+
/** @internal */
|
|
12
16
|
export function canPlant(state) {
|
|
13
17
|
return state.soil === "tilled" && state.cropId === null;
|
|
14
18
|
}
|
|
19
|
+
/** @internal */
|
|
15
20
|
export function plantCrop(state, cropId) {
|
|
16
21
|
if (!canPlant(state))
|
|
17
22
|
return state;
|
|
18
23
|
return { ...state, cropId, stage: 0, stageProgress: 0, harvestable: false };
|
|
19
24
|
}
|
|
25
|
+
/** @internal */
|
|
20
26
|
export function waterTile(state) {
|
|
21
27
|
if (state.soil !== "tilled" || state.watered)
|
|
22
28
|
return state;
|
|
23
29
|
return { ...state, watered: true };
|
|
24
30
|
}
|
|
31
|
+
/** @internal */
|
|
25
32
|
export function maturityDays(def) {
|
|
26
33
|
return def.stages.reduce((sum, days) => sum + Math.max(0, days), 0);
|
|
27
34
|
}
|
|
35
|
+
/** @internal */
|
|
28
36
|
export function advanceCropDay(def, state) {
|
|
29
37
|
const rested = state.watered ? { ...state, watered: false } : state;
|
|
30
38
|
if (state.cropId === null)
|
|
@@ -49,6 +57,7 @@ export function advanceCropDay(def, state) {
|
|
|
49
57
|
}
|
|
50
58
|
return rested;
|
|
51
59
|
}
|
|
60
|
+
/** @internal */
|
|
52
61
|
export function harvestCrop(def, state) {
|
|
53
62
|
if (!state.harvestable || state.cropId === null)
|
|
54
63
|
return { state, yield: null };
|
|
@@ -64,12 +73,15 @@ export function harvestCrop(def, state) {
|
|
|
64
73
|
yield: produce,
|
|
65
74
|
};
|
|
66
75
|
}
|
|
76
|
+
/** @internal */
|
|
67
77
|
export function tileKey(coord) {
|
|
68
78
|
return `${coord[0]},${coord[1]}`;
|
|
69
79
|
}
|
|
80
|
+
/** @internal */
|
|
70
81
|
export function singleTile() {
|
|
71
82
|
return [[0, 0]];
|
|
72
83
|
}
|
|
84
|
+
/** @internal */
|
|
73
85
|
export function squarePattern(radius) {
|
|
74
86
|
const r = Math.max(0, Math.floor(radius));
|
|
75
87
|
const tiles = [];
|
|
@@ -78,6 +90,7 @@ export function squarePattern(radius) {
|
|
|
78
90
|
tiles.push([dx, dz]);
|
|
79
91
|
return tiles;
|
|
80
92
|
}
|
|
93
|
+
/** @internal */
|
|
81
94
|
export function diamondPattern(radius) {
|
|
82
95
|
const r = Math.max(0, Math.floor(radius));
|
|
83
96
|
const tiles = [];
|
|
@@ -87,6 +100,7 @@ export function diamondPattern(radius) {
|
|
|
87
100
|
tiles.push([dx, dz]);
|
|
88
101
|
return tiles;
|
|
89
102
|
}
|
|
103
|
+
/** @internal */
|
|
90
104
|
export function rectPattern(width, depth) {
|
|
91
105
|
const w = Math.max(1, Math.floor(width));
|
|
92
106
|
const d = Math.max(1, Math.floor(depth));
|
|
@@ -98,9 +112,11 @@ export function rectPattern(width, depth) {
|
|
|
98
112
|
tiles.push([x0 + dx, z0 + dz]);
|
|
99
113
|
return tiles;
|
|
100
114
|
}
|
|
115
|
+
/** @internal */
|
|
101
116
|
export function patternAt(center, pattern) {
|
|
102
117
|
return pattern.map(([dx, dz]) => [center[0] + dx, center[1] + dz]);
|
|
103
118
|
}
|
|
119
|
+
/** @internal */
|
|
104
120
|
export function applyToolToTiles(tiles, center, pattern, apply, fill = emptyTile) {
|
|
105
121
|
const next = new Map(tiles);
|
|
106
122
|
const changed = [];
|
|
@@ -115,6 +131,7 @@ export function applyToolToTiles(tiles, center, pattern, apply, fill = emptyTile
|
|
|
115
131
|
}
|
|
116
132
|
return { tiles: next, changed };
|
|
117
133
|
}
|
|
134
|
+
/** @internal */
|
|
118
135
|
export function createDayTicker(startDay = 0) {
|
|
119
136
|
let last = Math.floor(startDay);
|
|
120
137
|
return {
|
|
@@ -127,6 +144,7 @@ export function createDayTicker(startDay = 0) {
|
|
|
127
144
|
day: () => last,
|
|
128
145
|
};
|
|
129
146
|
}
|
|
147
|
+
/** @internal */
|
|
130
148
|
export function createCropField(catalog = () => null) {
|
|
131
149
|
let grid = new Map();
|
|
132
150
|
function read(coord) {
|
|
@@ -27,6 +27,11 @@ export interface ProductionTickInput {
|
|
|
27
27
|
powered?: boolean;
|
|
28
28
|
}
|
|
29
29
|
export declare function productionBuilding(config: ProductionBuildingConfig): ProductionBuildingDef;
|
|
30
|
+
/**
|
|
31
|
+
* A production building that converts input items into outputs over time — factory/crafting station.
|
|
32
|
+
*
|
|
33
|
+
* @capability production-building a factory building converting inputs to outputs over time
|
|
34
|
+
*/
|
|
30
35
|
export declare function createProductionState(): ProductionState;
|
|
31
36
|
export declare function acceptsInput(def: ProductionBuildingDef, state: ProductionState, itemId: string): boolean;
|
|
32
37
|
export declare function feedProduction(def: ProductionBuildingDef, state: ProductionState, itemId: string, count: number): {
|