@v12-engine/engine 0.1.1 → 0.4.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/dist/abilities/amounts.d.ts +28 -0
- package/dist/abilities/amounts.js +74 -0
- package/dist/abilities/amounts.js.map +1 -0
- package/dist/abilities/buffs.d.ts +106 -6
- package/dist/abilities/buffs.js +443 -0
- package/dist/abilities/buffs.js.map +1 -0
- package/dist/abilities/castTold.d.ts +2 -0
- package/dist/abilities/castTold.js +66 -0
- package/dist/abilities/castTold.js.map +1 -0
- package/dist/abilities/chance.d.ts +38 -0
- package/dist/abilities/chance.js +77 -0
- package/dist/abilities/chance.js.map +1 -0
- package/dist/abilities/charges.d.ts +18 -0
- package/dist/abilities/charges.js +101 -0
- package/dist/abilities/charges.js.map +1 -0
- package/dist/abilities/control.d.ts +28 -0
- package/dist/abilities/control.js +113 -0
- package/dist/abilities/control.js.map +1 -0
- package/dist/abilities/dispel.js +51 -0
- package/dist/abilities/dispel.js.map +1 -0
- package/dist/abilities/effectFields.d.ts +1 -1
- package/dist/abilities/effectFields.js +676 -0
- package/dist/abilities/effectFields.js.map +1 -0
- package/dist/abilities/effectIndex.d.ts +27 -0
- package/dist/abilities/effectIndex.js +64 -0
- package/dist/abilities/effectIndex.js.map +1 -0
- package/dist/abilities/effects/buff.d.ts +9 -3
- package/dist/abilities/effects/buff.js +84 -0
- package/dist/abilities/effects/buff.js.map +1 -0
- package/dist/abilities/effects/conditions.d.ts +2 -0
- package/dist/abilities/effects/conditions.js +41 -0
- package/dist/abilities/effects/conditions.js.map +1 -0
- package/dist/abilities/effects/core.js +54 -0
- package/dist/abilities/effects/core.js.map +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -1
- package/dist/abilities/effects/damage.js +43 -0
- package/dist/abilities/effects/damage.js.map +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -2
- package/dist/abilities/effects/heal.js +51 -0
- package/dist/abilities/effects/heal.js.map +1 -0
- package/dist/abilities/effects/missile.d.ts +13 -1
- package/dist/abilities/effects/missile.js +104 -0
- package/dist/abilities/effects/missile.js.map +1 -0
- package/dist/abilities/effects/morph.d.ts +5 -0
- package/dist/abilities/effects/morph.js +43 -0
- package/dist/abilities/effects/morph.js.map +1 -0
- package/dist/abilities/effects/moves.d.ts +16 -4
- package/dist/abilities/effects/moves.js +212 -0
- package/dist/abilities/effects/moves.js.map +1 -0
- package/dist/abilities/effects/passives.d.ts +19 -9
- package/dist/abilities/effects/passives.js +131 -0
- package/dist/abilities/effects/passives.js.map +1 -0
- package/dist/abilities/effects/proxy.d.ts +5 -0
- package/dist/abilities/effects/proxy.js +60 -0
- package/dist/abilities/effects/proxy.js.map +1 -0
- package/dist/abilities/effects/sight.d.ts +2 -2
- package/dist/abilities/effects/sight.js +39 -0
- package/dist/abilities/effects/sight.js.map +1 -0
- package/dist/abilities/effects/spawn.d.ts +5 -2
- package/dist/abilities/effects/spawn.js +40 -0
- package/dist/abilities/effects/spawn.js.map +1 -0
- package/dist/abilities/effects/timed.d.ts +2 -2
- package/dist/abilities/effects/timed.js +96 -0
- package/dist/abilities/effects/timed.js.map +1 -0
- package/dist/abilities/effects/trade.d.ts +1 -1
- package/dist/abilities/effects/trade.js +25 -0
- package/dist/abilities/effects/trade.js.map +1 -0
- package/dist/abilities/effects.d.ts +97 -23
- package/dist/abilities/effects.js +860 -0
- package/dist/abilities/effects.js.map +1 -0
- package/dist/abilities/land.d.ts +38 -4
- package/dist/abilities/land.js +189 -0
- package/dist/abilities/land.js.map +1 -0
- package/dist/abilities/recast.d.ts +45 -0
- package/dist/abilities/recast.js +118 -0
- package/dist/abilities/recast.js.map +1 -0
- package/dist/abilities/scaled.js +40 -0
- package/dist/abilities/scaled.js.map +1 -0
- package/dist/abilities/screen.d.ts +6 -0
- package/dist/abilities/screen.js +83 -0
- package/dist/abilities/screen.js.map +1 -0
- package/dist/abilities/shapes.d.ts +66 -0
- package/dist/abilities/shapes.js +122 -0
- package/dist/abilities/shapes.js.map +1 -0
- package/dist/abilities/text.d.ts +14 -2
- package/dist/abilities/text.js +204 -0
- package/dist/abilities/text.js.map +1 -0
- package/dist/abilities/triggers.d.ts +98 -0
- package/dist/abilities/triggers.js +351 -0
- package/dist/abilities/triggers.js.map +1 -0
- package/dist/abilityChanges.d.ts +131 -0
- package/dist/abilityChanges.js +345 -0
- package/dist/abilityChanges.js.map +1 -0
- package/dist/ai/area.d.ts +4 -1
- package/dist/ai/brain.d.ts +4 -1
- package/dist/ai/brain.js +844 -0
- package/dist/ai/brain.js.map +1 -0
- package/dist/ai/budget.js +74 -0
- package/dist/ai/budget.js.map +1 -0
- package/dist/ai/checks.d.ts +9 -1
- package/dist/ai/checks.js +242 -0
- package/dist/ai/checks.js.map +1 -0
- package/dist/ai/computer.d.ts +11 -4
- package/dist/ai/computer.js +251 -0
- package/dist/ai/computer.js.map +1 -0
- package/dist/ai/defence.d.ts +4 -0
- package/dist/ai/defence.js +430 -0
- package/dist/ai/defence.js.map +1 -0
- package/dist/ai/define.d.ts +3 -2
- package/dist/ai/define.js +31 -0
- package/dist/ai/define.js.map +1 -0
- package/dist/ai/economy.d.ts +10 -7
- package/dist/ai/economy.js +780 -0
- package/dist/ai/economy.js.map +1 -0
- package/dist/ai/geometry.js +38 -0
- package/dist/ai/geometry.js.map +1 -0
- package/dist/ai/goals.d.ts +1 -0
- package/dist/ai/goals.js +560 -0
- package/dist/ai/goals.js.map +1 -0
- package/dist/ai/knowledge.d.ts +72 -7
- package/dist/ai/knowledge.js +804 -0
- package/dist/ai/knowledge.js.map +1 -0
- package/dist/ai/lanes.d.ts +10 -2
- package/dist/ai/lanes.js +715 -0
- package/dist/ai/lanes.js.map +1 -0
- package/dist/ai/melee/build.js +264 -0
- package/dist/ai/melee/build.js.map +1 -0
- package/dist/ai/melee/goals.d.ts +7 -0
- package/dist/ai/melee/goals.js +720 -0
- package/dist/ai/melee/goals.js.map +1 -0
- package/dist/ai/melee/heroes.js +68 -0
- package/dist/ai/melee/heroes.js.map +1 -0
- package/dist/ai/melee/index.d.ts +1 -1
- package/dist/ai/melee/index.js +51 -0
- package/dist/ai/melee/index.js.map +1 -0
- package/dist/ai/melee/production.js +29 -0
- package/dist/ai/melee/production.js.map +1 -0
- package/dist/ai/melee/surrender.js +64 -0
- package/dist/ai/melee/surrender.js.map +1 -0
- package/dist/ai/micro.d.ts +9 -0
- package/dist/ai/micro.js +1316 -0
- package/dist/ai/micro.js.map +1 -0
- package/dist/ai/mission.d.ts +9 -2
- package/dist/ai/mission.js +538 -0
- package/dist/ai/mission.js.map +1 -0
- package/dist/ai/missionRules.d.ts +1 -1
- package/dist/ai/missionRules.js +26 -0
- package/dist/ai/missionRules.js.map +1 -0
- package/dist/ai/module.d.ts +6 -2
- package/dist/ai/module.js +37 -0
- package/dist/ai/module.js.map +1 -0
- package/dist/ai/options.d.ts +3 -3
- package/dist/ai/plans/build.d.ts +20 -1
- package/dist/ai/plans/build.js +608 -0
- package/dist/ai/plans/build.js.map +1 -0
- package/dist/ai/plans/placement.d.ts +4 -1
- package/dist/ai/plans/placement.js +295 -0
- package/dist/ai/plans/placement.js.map +1 -0
- package/dist/ai/plans/plans.d.ts +9 -0
- package/dist/ai/plans/plans.js +110 -0
- package/dist/ai/plans/plans.js.map +1 -0
- package/dist/ai/plans/production.d.ts +14 -2
- package/dist/ai/plans/production.js +434 -0
- package/dist/ai/plans/production.js.map +1 -0
- package/dist/ai/plans/purse.d.ts +6 -3
- package/dist/ai/plans/purse.js +139 -0
- package/dist/ai/plans/purse.js.map +1 -0
- package/dist/ai/plans/tech.d.ts +6 -0
- package/dist/ai/plans/tech.js +122 -0
- package/dist/ai/plans/tech.js.map +1 -0
- package/dist/ai/profiles.d.ts +4 -4
- package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
- package/dist/ai/profiles.js.map +1 -0
- package/dist/ai/reach.js +54 -0
- package/dist/ai/reach.js.map +1 -0
- package/dist/ai/report.d.ts +8 -0
- package/dist/ai/report.js +87 -0
- package/dist/ai/report.js.map +1 -0
- package/dist/ai/roles.d.ts +4 -0
- package/dist/ai/roles.js +207 -0
- package/dist/ai/roles.js.map +1 -0
- package/dist/ai/rules.d.ts +8 -2
- package/dist/ai/rules.js +416 -0
- package/dist/ai/rules.js.map +1 -0
- package/dist/ai/scouting.d.ts +6 -0
- package/dist/ai/scouting.js +324 -0
- package/dist/ai/scouting.js.map +1 -0
- package/dist/ai/settings.js +99 -0
- package/dist/ai/settings.js.map +1 -0
- package/dist/ai/squads.d.ts +21 -2
- package/dist/ai/squads.js +916 -0
- package/dist/ai/squads.js.map +1 -0
- package/dist/ai/strength.js +320 -0
- package/dist/ai/strength.js.map +1 -0
- package/dist/ai/task.d.ts +3 -1
- package/dist/ai/task.js +17 -0
- package/dist/ai/task.js.map +1 -0
- package/dist/ai/tasks/attack.js +24 -0
- package/dist/ai/tasks/attack.js.map +1 -0
- package/dist/ai/tasks/capture.d.ts +3 -3
- package/dist/ai/tasks/capture.js +37 -0
- package/dist/ai/tasks/capture.js.map +1 -0
- package/dist/ai/tasks/creep.js +29 -0
- package/dist/ai/tasks/creep.js.map +1 -0
- package/dist/ai/tasks/defend.js +61 -0
- package/dist/ai/tasks/defend.js.map +1 -0
- package/dist/ai/tasks/drop.js +81 -0
- package/dist/ai/tasks/drop.js.map +1 -0
- package/dist/ai/tasks/escort.js +59 -0
- package/dist/ai/tasks/escort.js.map +1 -0
- package/dist/ai/tasks/gather.js +48 -0
- package/dist/ai/tasks/gather.js.map +1 -0
- package/dist/ai/tasks/harass.js +39 -0
- package/dist/ai/tasks/harass.js.map +1 -0
- package/dist/ai/tasks/hold.js +32 -0
- package/dist/ai/tasks/hold.js.map +1 -0
- package/dist/ai/tasks/index.js +34 -0
- package/dist/ai/tasks/index.js.map +1 -0
- package/dist/ai/tasks/move.js +26 -0
- package/dist/ai/tasks/move.js.map +1 -0
- package/dist/ai/tasks/patrol.js +59 -0
- package/dist/ai/tasks/patrol.js.map +1 -0
- package/dist/ai/tasks/retreat.js +28 -0
- package/dist/ai/tasks/retreat.js.map +1 -0
- package/dist/ai/tasks/scout.js +73 -0
- package/dist/ai/tasks/scout.js.map +1 -0
- package/dist/ai/tasks/shared.d.ts +1 -1
- package/dist/ai/tasks/shared.js +137 -0
- package/dist/ai/tasks/shared.js.map +1 -0
- package/dist/ai/team.d.ts +18 -1
- package/dist/ai/team.js +492 -0
- package/dist/ai/team.js.map +1 -0
- package/dist/ai/threat.d.ts +6 -0
- package/dist/ai/threat.js +206 -0
- package/dist/ai/threat.js.map +1 -0
- package/dist/ai/view.d.ts +21 -7
- package/dist/ai/view.js +677 -0
- package/dist/ai/view.js.map +1 -0
- package/dist/ai/waves.d.ts +6 -0
- package/dist/ai/waves.js +410 -0
- package/dist/ai/waves.js.map +1 -0
- package/dist/ai.js +54 -6239
- package/dist/aiTesting.d.ts +6 -3
- package/dist/aiTesting.js +229 -0
- package/dist/aiTesting.js.map +1 -0
- package/dist/areas.d.ts +4 -1
- package/dist/areas.js +295 -0
- package/dist/areas.js.map +1 -0
- package/dist/attacks.d.ts +3 -3
- package/dist/attacks.js +127 -0
- package/dist/attacks.js.map +1 -0
- package/dist/burning.d.ts +267 -0
- package/dist/burning.js +795 -0
- package/dist/burning.js.map +1 -0
- package/dist/bytes.js +21 -0
- package/dist/bytes.js.map +1 -0
- package/dist/callings.d.ts +71 -0
- package/dist/callings.js +157 -0
- package/dist/callings.js.map +1 -0
- package/dist/cameraOrders.d.ts +78 -0
- package/dist/cameraOrders.js +114 -0
- package/dist/cameraOrders.js.map +1 -0
- package/dist/camps.d.ts +70 -4
- package/dist/camps.js +501 -0
- package/dist/camps.js.map +1 -0
- package/dist/capture.d.ts +15 -3
- package/dist/capture.js +304 -0
- package/dist/capture.js.map +1 -0
- package/dist/cellLayers.d.ts +78 -13
- package/dist/cellLayers.js +275 -0
- package/dist/cellLayers.js.map +1 -0
- package/dist/cellPatches.d.ts +24 -0
- package/dist/cellPatches.js +73 -0
- package/dist/cellPatches.js.map +1 -0
- package/dist/cinematics.d.ts +10 -5
- package/dist/cinematics.js +161 -0
- package/dist/cinematics.js.map +1 -0
- package/dist/clock.d.ts +2 -2
- package/dist/clock.js +78 -0
- package/dist/clock.js.map +1 -0
- package/dist/commands.d.ts +36 -4
- package/dist/commands.js +636 -0
- package/dist/commands.js.map +1 -0
- package/dist/components.d.ts +31 -10
- package/dist/components.js +74 -0
- package/dist/components.js.map +1 -0
- package/dist/computers.d.ts +4 -4
- package/dist/computers.js +194 -0
- package/dist/computers.js.map +1 -0
- package/dist/concealment.d.ts +25 -2
- package/dist/concealment.js +409 -0
- package/dist/concealment.js.map +1 -0
- package/dist/coreComponents.js +130 -0
- package/dist/coreComponents.js.map +1 -0
- package/dist/createGame.d.ts +306 -0
- package/dist/createGame.js +405 -0
- package/dist/createGame.js.map +1 -0
- package/dist/dashing.d.ts +18 -2
- package/dist/dashing.js +41 -0
- package/dist/dashing.js.map +1 -0
- package/dist/debug.d.ts +8 -0
- package/dist/debug.js +5 -3
- package/dist/debug2.js +76 -0
- package/dist/debug2.js.map +1 -0
- package/dist/debugCommands.d.ts +6 -6
- package/dist/debugCommands.js +537 -0
- package/dist/debugCommands.js.map +1 -0
- package/dist/debugging.d.ts +1 -0
- package/dist/defaultSets.d.ts +183 -0
- package/dist/defaultSets.js +216 -0
- package/dist/defaultSets.js.map +1 -0
- package/dist/definitions.d.ts +6 -0
- package/dist/definitions.js +78 -0
- package/dist/definitions.js.map +1 -0
- package/dist/defs.d.ts +1895 -165
- package/dist/defs.js +380 -0
- package/dist/defs.js.map +1 -0
- package/dist/denying.d.ts +4 -4
- package/dist/denying.js +106 -0
- package/dist/denying.js.map +1 -0
- package/dist/destructibles.d.ts +2 -2
- package/dist/destructibles.js +36 -0
- package/dist/destructibles.js.map +1 -0
- package/dist/determinism.d.ts +4 -4
- package/dist/determinism.js +247 -0
- package/dist/determinism.js.map +1 -0
- package/dist/dialog.d.ts +17 -2
- package/dist/dialog.js +108 -0
- package/dist/dialog.js.map +1 -0
- package/dist/effectRefs.js +28 -0
- package/dist/effectRefs.js.map +1 -0
- package/dist/effects.d.ts +27 -11
- package/dist/effects.js +110 -0
- package/dist/effects.js.map +1 -0
- package/dist/endings.d.ts +1 -1
- package/dist/endings.js +78 -0
- package/dist/endings.js.map +1 -0
- package/dist/engagement.d.ts +40 -6
- package/dist/engagement.js +530 -0
- package/dist/engagement.js.map +1 -0
- package/dist/engineEvents.d.ts +72 -9
- package/dist/engineEvents.js +520 -0
- package/dist/engineEvents.js.map +1 -0
- package/dist/entity.d.ts +275 -26
- package/dist/entity.js +441 -0
- package/dist/entity.js.map +1 -0
- package/dist/entityIndex.d.ts +10 -3
- package/dist/entityIndex.js +149 -0
- package/dist/entityIndex.js.map +1 -0
- package/dist/errors.d.ts +6 -2
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +11 -5
- package/dist/events.js +158 -0
- package/dist/events.js.map +1 -0
- package/dist/exactMath.js +273 -0
- package/dist/exactMath.js.map +1 -0
- package/dist/features.d.ts +1 -1
- package/dist/features.js +127 -0
- package/dist/features.js.map +1 -0
- package/dist/fields.d.ts +25 -5
- package/dist/fields.js +140 -0
- package/dist/fields.js.map +1 -0
- package/dist/fixture.d.ts +3 -3
- package/dist/fixture.js +512 -0
- package/dist/fixture.js.map +1 -0
- package/dist/fog.d.ts +26 -3
- package/dist/fog.js +333 -0
- package/dist/fog.js.map +1 -0
- package/dist/foliage.d.ts +476 -0
- package/dist/foliage.js +1478 -0
- package/dist/foliage.js.map +1 -0
- package/dist/foliageDebug.d.ts +57 -0
- package/dist/foliageDebug.js +172 -0
- package/dist/foliageDebug.js.map +1 -0
- package/dist/foliageRegrowth.d.ts +20 -0
- package/dist/foliageRegrowth.js +332 -0
- package/dist/foliageRegrowth.js.map +1 -0
- package/dist/formState.d.ts +67 -0
- package/dist/formState.js +65 -0
- package/dist/formState.js.map +1 -0
- package/dist/formation.d.ts +46 -8
- package/dist/formation.js +297 -0
- package/dist/formation.js.map +1 -0
- package/dist/forms.d.ts +58 -0
- package/dist/forms.js +146 -0
- package/dist/forms.js.map +1 -0
- package/dist/friendlyFire.d.ts +2 -2
- package/dist/friendlyFire.js +37 -0
- package/dist/friendlyFire.js.map +1 -0
- package/dist/game.d.ts +141 -48
- package/dist/game.js +834 -0
- package/dist/game.js.map +1 -0
- package/dist/gameData.d.ts +96 -22
- package/dist/gameData.js +1690 -0
- package/dist/gameData.js.map +1 -0
- package/dist/gameFiles.d.ts +3 -3
- package/dist/gameFiles.js +14 -0
- package/dist/gameFiles.js.map +1 -0
- package/dist/gates.js +92 -0
- package/dist/gates.js.map +1 -0
- package/dist/generate.d.ts +28 -1
- package/dist/generate.js +1062 -0
- package/dist/generate.js.map +1 -0
- package/dist/generateWorker.d.ts +7 -3
- package/dist/generateWorker.js +86 -0
- package/dist/generateWorker.js.map +1 -0
- package/dist/grid.d.ts +9 -0
- package/dist/grid.js +102 -0
- package/dist/grid.js.map +1 -0
- package/dist/ground.d.ts +17 -1
- package/dist/ground.js +375 -0
- package/dist/ground.js.map +1 -0
- package/dist/groundObjects.d.ts +70 -0
- package/dist/groundObjects.js +371 -0
- package/dist/groundObjects.js.map +1 -0
- package/dist/groundSpeed.d.ts +20 -3
- package/dist/groundSpeed.js +117 -0
- package/dist/groundSpeed.js.map +1 -0
- package/dist/hero.d.ts +126 -10
- package/dist/hero.js +432 -0
- package/dist/hero.js.map +1 -0
- package/dist/holds.d.ts +94 -0
- package/dist/holds.js +305 -0
- package/dist/holds.js.map +1 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.js +30 -0
- package/dist/home.js.map +1 -0
- package/dist/hooks.d.ts +339 -57
- package/dist/hooks.js +105 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hotReload.d.ts +6 -5
- package/dist/hotReload.js +145 -0
- package/dist/hotReload.js.map +1 -0
- package/dist/ids.d.ts +3 -3
- package/dist/ids.js +30 -0
- package/dist/ids.js.map +1 -0
- package/dist/idsFile.d.ts +36 -0
- package/dist/idsFile.js +134 -0
- package/dist/idsFile.js.map +1 -0
- package/dist/index.d.ts +105 -68
- package/dist/index.js +194 -4701
- package/dist/inspect.d.ts +29 -2
- package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
- package/dist/inspect.js.map +1 -0
- package/dist/inventory.d.ts +14 -1
- package/dist/inventory.js +84 -0
- package/dist/inventory.js.map +1 -0
- package/dist/items.d.ts +136 -8
- package/dist/items.js +585 -0
- package/dist/items.js.map +1 -0
- package/dist/lanes.d.ts +12 -3
- package/dist/lanes.js +496 -0
- package/dist/lanes.js.map +1 -0
- package/dist/life.d.ts +6 -2
- package/dist/life.js +287 -0
- package/dist/life.js.map +1 -0
- package/dist/log.d.ts +26 -3
- package/dist/log.js +192 -0
- package/dist/log.js.map +1 -0
- package/dist/manaBurn.d.ts +2 -2
- package/dist/manaBurn.js +75 -0
- package/dist/manaBurn.js.map +1 -0
- package/dist/map/file.d.ts +56 -3
- package/dist/map/file.js +264 -0
- package/dist/map/file.js.map +1 -0
- package/dist/map/images.js +61 -0
- package/dist/map/images.js.map +1 -0
- package/dist/map/look.d.ts +1 -1
- package/dist/map/look.js +30 -0
- package/dist/map/look.js.map +1 -0
- package/dist/map/pathProfile.js +183 -0
- package/dist/map/pathProfile.js.map +1 -0
- package/dist/map/resize.d.ts +4 -0
- package/dist/map/resize.js +136 -0
- package/dist/map/resize.js.map +1 -0
- package/dist/map/schema.js +257 -0
- package/dist/map/schema.js.map +1 -0
- package/dist/map/terrain.js +214 -0
- package/dist/map/terrain.js.map +1 -0
- package/dist/map/types.d.ts +92 -13
- package/dist/map/types.js +251 -0
- package/dist/map/types.js.map +1 -0
- package/dist/mapCheck/cells.js +94 -0
- package/dist/mapCheck/cells.js.map +1 -0
- package/dist/mapCheck/rules/foliage.d.ts +9 -0
- package/dist/mapCheck/rules/foliage.js +83 -0
- package/dist/mapCheck/rules/foliage.js.map +1 -0
- package/dist/mapCheck/rules/names.js +39 -0
- package/dist/mapCheck/rules/names.js.map +1 -0
- package/dist/mapCheck/rules/objects.d.ts +1 -1
- package/dist/mapCheck/rules/objects.js +56 -0
- package/dist/mapCheck/rules/objects.js.map +1 -0
- package/dist/mapCheck/rules/paths.js +32 -0
- package/dist/mapCheck/rules/paths.js.map +1 -0
- package/dist/mapCheck/rules/players.js +20 -0
- package/dist/mapCheck/rules/players.js.map +1 -0
- package/dist/mapCheck/rules/races.js +56 -0
- package/dist/mapCheck/rules/races.js.map +1 -0
- package/dist/mapCheck/rules/random.js +47 -0
- package/dist/mapCheck/rules/random.js.map +1 -0
- package/dist/mapCheck/rules/regions.js +30 -0
- package/dist/mapCheck/rules/regions.js.map +1 -0
- package/dist/mapCheck/rules/targets.js +31 -0
- package/dist/mapCheck/rules/targets.js.map +1 -0
- package/dist/mapCheck/rules/walking.js +45 -0
- package/dist/mapCheck/rules/walking.js.map +1 -0
- package/dist/mapCheck.d.ts +2 -2
- package/dist/mapCheck.js +63 -0
- package/dist/mapCheck.js.map +1 -0
- package/dist/mapFields.d.ts +25 -2
- package/dist/mapFields.js +134 -0
- package/dist/mapFields.js.map +1 -0
- package/dist/mapFile.js +176 -0
- package/dist/mapFile.js.map +1 -0
- package/dist/mapMeasure.d.ts +8 -0
- package/dist/mapMeasure.js +283 -0
- package/dist/mapMeasure.js.map +1 -0
- package/dist/mapMerge.d.ts +1 -0
- package/dist/mapMerge.js +172 -0
- package/dist/mapMerge.js.map +1 -0
- package/dist/mapObjectives.js +138 -0
- package/dist/mapObjectives.js.map +1 -0
- package/dist/mapObjects.js +80 -0
- package/dist/mapObjects.js.map +1 -0
- package/dist/math.d.ts +37 -7
- package/dist/math.js +155 -0
- package/dist/math.js.map +1 -0
- package/dist/messages.d.ts +71 -4
- package/dist/messages.js +29 -0
- package/dist/messages.js.map +1 -0
- package/dist/missionRules.d.ts +10 -2
- package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
- package/dist/missionRules.js.map +1 -0
- package/dist/mods.d.ts +39 -20
- package/dist/mods.js +271 -0
- package/dist/mods.js.map +1 -0
- package/dist/moves.d.ts +87 -0
- package/dist/moves.js +539 -0
- package/dist/moves.js.map +1 -0
- package/dist/names.d.ts +7 -0
- package/dist/names.js +122 -0
- package/dist/names.js.map +1 -0
- package/dist/navigation/agentParams.js +14 -0
- package/dist/navigation/agentParams.js.map +1 -0
- package/dist/navigation/air.d.ts +7 -3
- package/dist/navigation/air.js +401 -0
- package/dist/navigation/air.js.map +1 -0
- package/dist/navigation/builds.d.ts +34 -2
- package/dist/navigation/builds.js +287 -0
- package/dist/navigation/builds.js.map +1 -0
- package/dist/navigation/groundAreas.d.ts +59 -1
- package/dist/navigation/groundAreas.js +407 -0
- package/dist/navigation/groundAreas.js.map +1 -0
- package/dist/navigation/navigation.d.ts +98 -9
- package/dist/navigation/recast.d.ts +194 -18
- package/dist/navigation/recast.js +1379 -0
- package/dist/navigation/recast.js.map +1 -0
- package/dist/navigation/sidePaths.d.ts +8 -3
- package/dist/navigation/sidePaths.js +241 -0
- package/dist/navigation/sidePaths.js.map +1 -0
- package/dist/navigation/sized.js +243 -0
- package/dist/navigation/sized.js.map +1 -0
- package/dist/nearest.js +32 -0
- package/dist/nearest.js.map +1 -0
- package/dist/noise.js +59 -0
- package/dist/noise.js.map +1 -0
- package/dist/objectives.d.ts +12 -3
- package/dist/objectives.js +144 -0
- package/dist/objectives.js.map +1 -0
- package/dist/orders/basic.d.ts +5 -5
- package/dist/orders/basic.js +417 -0
- package/dist/orders/basic.js.map +1 -0
- package/dist/orders/build.js +278 -0
- package/dist/orders/build.js.map +1 -0
- package/dist/orders/cast.d.ts +13 -3
- package/dist/orders/cast.js +558 -0
- package/dist/orders/cast.js.map +1 -0
- package/dist/orders/facts.js +16 -0
- package/dist/orders/facts.js.map +1 -0
- package/dist/orders/harvest.d.ts +21 -5
- package/dist/orders/harvest.js +540 -0
- package/dist/orders/harvest.js.map +1 -0
- package/dist/orders/idle.d.ts +3 -1
- package/dist/orders/idle.js +234 -0
- package/dist/orders/idle.js.map +1 -0
- package/dist/orders/items.js +92 -0
- package/dist/orders/items.js.map +1 -0
- package/dist/orders/queue.js +108 -0
- package/dist/orders/queue.js.map +1 -0
- package/dist/orders/waiting.d.ts +39 -0
- package/dist/orders/waiting.js +149 -0
- package/dist/orders/waiting.js.map +1 -0
- package/dist/pack.schema.js +13 -0
- package/dist/pack.schema.js.map +1 -0
- package/dist/pack.schema.json +7622 -841
- package/dist/packs/director/index.d.ts +13 -5
- package/dist/packs/director/index.js +204 -0
- package/dist/packs/director/index.js.map +1 -0
- package/dist/packs/heroes/campaign.d.ts +3 -2
- package/dist/packs/heroes/campaign.js +241 -0
- package/dist/packs/heroes/campaign.js.map +1 -0
- package/dist/packs/heroes/carry.d.ts +6 -0
- package/dist/packs/heroes/carry.js +112 -0
- package/dist/packs/heroes/carry.js.map +1 -0
- package/dist/packs/heroes/commands.js +115 -0
- package/dist/packs/heroes/commands.js.map +1 -0
- package/dist/packs/heroes/fallen.d.ts +43 -0
- package/dist/packs/heroes/fallen.js +61 -0
- package/dist/packs/heroes/fallen.js.map +1 -0
- package/dist/packs/heroes/hire.js +60 -0
- package/dist/packs/heroes/hire.js.map +1 -0
- package/dist/packs/heroes/index.d.ts +7 -6
- package/dist/packs/heroes/index.js +130 -0
- package/dist/packs/heroes/index.js.map +1 -0
- package/dist/packs/heroes/loop.d.ts +95 -0
- package/dist/packs/heroes/loop.js +250 -0
- package/dist/packs/heroes/loop.js.map +1 -0
- package/dist/packs/heroes/making.d.ts +6 -3
- package/dist/packs/heroes/making.js +55 -0
- package/dist/packs/heroes/making.js.map +1 -0
- package/dist/packs/heroes/respawn.d.ts +3 -3
- package/dist/packs/heroes/respawn.js +87 -0
- package/dist/packs/heroes/respawn.js.map +1 -0
- package/dist/packs/heroes/sets.d.ts +32 -0
- package/dist/packs/heroes/sets.js +51 -0
- package/dist/packs/heroes/sets.js.map +1 -0
- package/dist/packs/heroes/spells.d.ts +16 -0
- package/dist/packs/heroes/spells.js +269 -0
- package/dist/packs/heroes/spells.js.map +1 -0
- package/dist/packs/items/defaults.d.ts +43 -0
- package/dist/packs/items/defaults.js +1504 -0
- package/dist/packs/items/defaults.js.map +1 -0
- package/dist/packs/items/index.d.ts +27 -0
- package/dist/packs/items/index.js +214 -0
- package/dist/packs/items/index.js.map +1 -0
- package/dist/packs/moba/index.d.ts +3 -3
- package/dist/packs/moba/index.js +174 -0
- package/dist/packs/moba/index.js.map +1 -0
- package/dist/packs/pack.d.ts +15 -15
- package/dist/packs/pack.js +14 -0
- package/dist/packs/pack.js.map +1 -0
- package/dist/packs.d.ts +15 -7
- package/dist/packs.js +222 -0
- package/dist/packs.js.map +1 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +109 -0
- package/dist/paths.js.map +1 -0
- package/dist/plain.js +57 -0
- package/dist/plain.js.map +1 -0
- package/dist/player.d.ts +33 -10
- package/dist/player.js +159 -0
- package/dist/player.js.map +1 -0
- package/dist/portals.d.ts +1 -1
- package/dist/portals.js +194 -0
- package/dist/portals.js.map +1 -0
- package/dist/prefabs.d.ts +25 -2
- package/dist/prefabs.js +239 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/presetBuildings.js +58 -0
- package/dist/presetBuildings.js.map +1 -0
- package/dist/presetFoliage.d.ts +27 -0
- package/dist/presetFoliage.js +98 -0
- package/dist/presetFoliage.js.map +1 -0
- package/dist/presetGround.js +65 -0
- package/dist/presetGround.js.map +1 -0
- package/dist/proxies.d.ts +12 -0
- package/dist/proxies.js +79 -0
- package/dist/proxies.js.map +1 -0
- package/dist/query.d.ts +56 -0
- package/dist/query.js +88 -0
- package/dist/query.js.map +1 -0
- package/dist/races.d.ts +15 -14
- package/dist/races.js +172 -0
- package/dist/races.js.map +1 -0
- package/dist/randomGroups.js +91 -0
- package/dist/randomGroups.js.map +1 -0
- package/dist/registry.d.ts +117 -53
- package/dist/registry.js +323 -0
- package/dist/registry.js.map +1 -0
- package/dist/remains.d.ts +11 -9
- package/dist/remains.js +188 -0
- package/dist/remains.js.map +1 -0
- package/dist/replication.d.ts +12 -7
- package/dist/replication.js +100 -0
- package/dist/replication.js.map +1 -0
- package/dist/rng.d.ts +2 -0
- package/dist/rng.js +40 -0
- package/dist/rng.js.map +1 -0
- package/dist/rules.d.ts +186 -99
- package/dist/rules.js +179 -0
- package/dist/rules.js.map +1 -0
- package/dist/rulesCheck.d.ts +5 -4
- package/dist/rulesCheck.js +693 -0
- package/dist/rulesCheck.js.map +1 -0
- package/dist/runes.d.ts +2 -2
- package/dist/runes.js +80 -0
- package/dist/runes.js.map +1 -0
- package/dist/save.d.ts +37 -12
- package/dist/save.js +532 -0
- package/dist/save.js.map +1 -0
- package/dist/scenario.d.ts +2 -2
- package/dist/scenario.js +99 -0
- package/dist/scenario.js.map +1 -0
- package/dist/scheduler.d.ts +3 -0
- package/dist/scheduler.js +156 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/score.d.ts +19 -19
- package/dist/score.js +709 -0
- package/dist/score.js.map +1 -0
- package/dist/sequences.d.ts +10 -6
- package/dist/sequences.js +206 -0
- package/dist/sequences.js.map +1 -0
- package/dist/server/doorman.js +154 -0
- package/dist/server/doorman.js.map +1 -0
- package/dist/server/gameServer.d.ts +16 -1
- package/dist/server/gameServer.js +643 -0
- package/dist/server/gameServer.js.map +1 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/lobby.js +199 -0
- package/dist/server/lobby.js.map +1 -0
- package/dist/server/log.js +18 -0
- package/dist/server/log.js.map +1 -0
- package/dist/server/match.js +267 -0
- package/dist/server/match.js.map +1 -0
- package/dist/server/mode.d.ts +18 -9
- package/dist/server/mode.js +220 -0
- package/dist/server/mode.js.map +1 -0
- package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
- package/dist/server/navigation-worker.js.map +1 -0
- package/dist/server/navigation.js +39 -0
- package/dist/server/navigation.js.map +1 -0
- package/dist/server/ops.d.ts +4 -0
- package/dist/server/ops.js +137 -0
- package/dist/server/ops.js.map +1 -0
- package/dist/server/packs.d.ts +3 -3
- package/dist/server/packs.js +32 -0
- package/dist/server/packs.js.map +1 -0
- package/dist/server/ratings.d.ts +5 -0
- package/dist/server/ratings.js +104 -0
- package/dist/server/ratings.js.map +1 -0
- package/dist/server/relay.d.ts +12 -2
- package/dist/server/relay.js +144 -0
- package/dist/server/relay.js.map +1 -0
- package/dist/server/rooms.d.ts +9 -2
- package/dist/server/rooms.js +442 -0
- package/dist/server/rooms.js.map +1 -0
- package/dist/server/seat.js +116 -0
- package/dist/server/seat.js.map +1 -0
- package/dist/server/seatSettings.d.ts +3 -3
- package/dist/server/seatSettings.js +63 -0
- package/dist/server/seatSettings.js.map +1 -0
- package/dist/server/secret.js +13 -0
- package/dist/server/secret.js.map +1 -0
- package/dist/server/start.d.ts +13 -6
- package/dist/server/start.js +76 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/websocket.d.ts +9 -1
- package/dist/server/websocket.js +306 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server.js +15 -2861
- package/dist/session/can.js +26 -0
- package/dist/session/can.js.map +1 -0
- package/dist/session/commandReplay.d.ts +8 -2
- package/dist/session/commandReplay.js +293 -0
- package/dist/session/commandReplay.js.map +1 -0
- package/dist/session/debug.js +151 -0
- package/dist/session/debug.js.map +1 -0
- package/dist/session/delay.js +62 -0
- package/dist/session/delay.js.map +1 -0
- package/dist/session/delta.d.ts +14 -1
- package/dist/session/delta.js +407 -0
- package/dist/session/delta.js.map +1 -0
- package/dist/session/entityState.js +415 -0
- package/dist/session/entityState.js.map +1 -0
- package/dist/session/local.d.ts +47 -5
- package/dist/session/local.js +670 -0
- package/dist/session/local.js.map +1 -0
- package/dist/session/memory.d.ts +20 -2
- package/dist/session/memory.js +131 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/protocol.d.ts +325 -31
- package/dist/session/protocol.js +55 -0
- package/dist/session/protocol.js.map +1 -0
- package/dist/session/remote.d.ts +74 -12
- package/dist/session/remote.js +1394 -0
- package/dist/session/remote.js.map +1 -0
- package/dist/session/replay.d.ts +11 -2
- package/dist/session/replay.js +160 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/seed.js +12 -0
- package/dist/session/seed.js.map +1 -0
- package/dist/session/share.d.ts +5 -1
- package/dist/session/share.js +94 -0
- package/dist/session/share.js.map +1 -0
- package/dist/session/socket.d.ts +1 -1
- package/dist/session/socket.js +29 -0
- package/dist/session/socket.js.map +1 -0
- package/dist/session/wire.d.ts +5 -0
- package/dist/session/wire.js +84 -0
- package/dist/session/wire.js.map +1 -0
- package/dist/session/worker.d.ts +77 -12
- package/dist/session/worker.js +499 -0
- package/dist/session/worker.js.map +1 -0
- package/dist/shared.d.ts +31 -5
- package/dist/shared.js +166 -0
- package/dist/shared.js.map +1 -0
- package/dist/sides.d.ts +9 -3
- package/dist/sides.js +149 -0
- package/dist/sides.js.map +1 -0
- package/dist/sight.js +85 -0
- package/dist/sight.js.map +1 -0
- package/dist/simulate-worker.js +1 -1
- package/dist/simulate.d.ts +12 -8
- package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
- package/dist/simulate.js.map +1 -0
- package/dist/smart.js +77 -0
- package/dist/smart.js.map +1 -0
- package/dist/spatial.d.ts +32 -16
- package/dist/spatial.js +234 -0
- package/dist/spatial.js.map +1 -0
- package/dist/spawning.d.ts +1 -0
- package/dist/spawning.js +224 -0
- package/dist/spawning.js.map +1 -0
- package/dist/stances.d.ts +6 -3
- package/dist/stances.js +169 -0
- package/dist/stances.js.map +1 -0
- package/dist/start.d.ts +10 -10
- package/dist/start.js +75 -0
- package/dist/start.js.map +1 -0
- package/dist/stats.d.ts +42 -16
- package/dist/stats.js +290 -0
- package/dist/stats.js.map +1 -0
- package/dist/summoned.d.ts +52 -0
- package/dist/summoned.js +38 -0
- package/dist/summoned.js.map +1 -0
- package/dist/summons.d.ts +10 -13
- package/dist/summons.js +271 -0
- package/dist/summons.js.map +1 -0
- package/dist/systems/abilities.js +224 -0
- package/dist/systems/abilities.js.map +1 -0
- package/dist/systems/combat.d.ts +35 -1
- package/dist/systems/combat.js +677 -0
- package/dist/systems/combat.js.map +1 -0
- package/dist/systems/combatTold.d.ts +3 -1
- package/dist/systems/combatTold.js +85 -0
- package/dist/systems/combatTold.js.map +1 -0
- package/dist/systems/construction.js +80 -0
- package/dist/systems/construction.js.map +1 -0
- package/dist/systems/economy.d.ts +0 -6
- package/dist/systems/economy.js +128 -0
- package/dist/systems/economy.js.map +1 -0
- package/dist/systems/fog.d.ts +1 -1
- package/dist/systems/fog.js +120 -0
- package/dist/systems/fog.js.map +1 -0
- package/dist/systems/life.js +32 -0
- package/dist/systems/life.js.map +1 -0
- package/dist/systems/movement.d.ts +24 -12
- package/dist/systems/movement.js +1247 -0
- package/dist/systems/movement.js.map +1 -0
- package/dist/systems/orders.js +64 -0
- package/dist/systems/orders.js.map +1 -0
- package/dist/systems/production.js +322 -0
- package/dist/systems/production.js.map +1 -0
- package/dist/systems/productionQueue.js +120 -0
- package/dist/systems/productionQueue.js.map +1 -0
- package/dist/systems/victory.d.ts +1 -1
- package/dist/systems/victory.js +56 -0
- package/dist/systems/victory.js.map +1 -0
- package/dist/talk.d.ts +6 -6
- package/dist/talk.js +153 -0
- package/dist/talk.js.map +1 -0
- package/dist/targeting.d.ts +142 -0
- package/dist/targeting.js +49 -0
- package/dist/targeting.js.map +1 -0
- package/dist/tech.d.ts +20 -3
- package/dist/tech.js +239 -0
- package/dist/tech.js.map +1 -0
- package/dist/techTree.d.ts +7 -0
- package/dist/techTree.js +90 -0
- package/dist/techTree.js.map +1 -0
- package/dist/terrain.d.ts +59 -7
- package/dist/terrain.js +389 -0
- package/dist/terrain.js.map +1 -0
- package/dist/terrainSave.d.ts +6 -0
- package/dist/terrainSave.js +74 -0
- package/dist/terrainSave.js.map +1 -0
- package/dist/testing.d.ts +8 -7
- package/dist/testing.js +13 -739
- package/dist/testing.js.map +1 -1
- package/dist/tiles.d.ts +1 -1
- package/dist/tiles.js +43 -0
- package/dist/tiles.js.map +1 -0
- package/dist/timers.d.ts +29 -4
- package/dist/timers.js +242 -0
- package/dist/timers.js.map +1 -0
- package/dist/tomes.d.ts +4 -4
- package/dist/tomes.js +94 -0
- package/dist/tomes.js.map +1 -0
- package/dist/trade.js +103 -0
- package/dist/trade.js.map +1 -0
- package/dist/transport.d.ts +6 -1
- package/dist/transport.js +281 -0
- package/dist/transport.js.map +1 -0
- package/dist/tunables.d.ts +10 -3
- package/dist/tunables.js +56 -0
- package/dist/tunables.js.map +1 -0
- package/dist/unitResources.d.ts +67 -0
- package/dist/unitResources.js +266 -0
- package/dist/unitResources.js.map +1 -0
- package/dist/upkeep.d.ts +6 -1
- package/dist/upkeep.js +26 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/veterancy.d.ts +8 -3
- package/dist/veterancy.js +131 -0
- package/dist/veterancy.js.map +1 -0
- package/dist/vision.d.ts +36 -0
- package/dist/vision.js +133 -0
- package/dist/vision.js.map +1 -0
- package/dist/walls.d.ts +1 -1
- package/dist/walls.js +278 -0
- package/dist/walls.js.map +1 -0
- package/dist/world.d.ts +606 -88
- package/dist/world.js +1263 -0
- package/dist/world.js.map +1 -0
- package/package.json +2 -2
- package/dist/ai.js.map +0 -1
- package/dist/attributes.d.ts +0 -66
- package/dist/brain-BvVdUhX8.js +0 -7659
- package/dist/brain-BvVdUhX8.js.map +0 -1
- package/dist/builds-C6LfgvEU.js +0 -460
- package/dist/builds-C6LfgvEU.js.map +0 -1
- package/dist/coreComponents-syuh2fPG.js +0 -5149
- package/dist/coreComponents-syuh2fPG.js.map +0 -1
- package/dist/debugCommands-CzjrSm66.js +0 -14739
- package/dist/debugCommands-CzjrSm66.js.map +0 -1
- package/dist/determinism-BCymQwiE.js +0 -518
- package/dist/determinism-BCymQwiE.js.map +0 -1
- package/dist/game-DiJEN-Ks.js +0 -5800
- package/dist/game-DiJEN-Ks.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspect-D9dWHmZ0.js.map +0 -1
- package/dist/local-Dkovq42k.js +0 -1379
- package/dist/local-Dkovq42k.js.map +0 -1
- package/dist/missionRules-C-bGxm0Q.js.map +0 -1
- package/dist/navigation-worker.js.map +0 -1
- package/dist/packs-g5thvmGn.js +0 -3199
- package/dist/packs-g5thvmGn.js.map +0 -1
- package/dist/profiles-B3NS9jwk.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/simulate-oXBiw1Ff.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recast.js","names":[],"sources":["../../src/navigation/recast.ts"],"sourcesContent":["import {\n\ttype BoxObstacle,\n\tCrowd,\n\ttype CrowdAgent,\n\tDebugDrawerUtils,\n\timportTileCache,\n\ttype NavMesh,\n\tNavMeshQuery,\n\ttype Obstacle,\n\tRaw,\n\ttype TileCache,\n\tTileCacheMeshProcess\n} from '@recast-navigation/core'\nimport { createDefaultTileCacheMeshProcess } from '@recast-navigation/generators'\nimport { addTileLayer, columnTileCache, groundMeshProcess, groundTileLayers, layerOf, setAreaCosts, type TileCut, tileGridOf, tileKey } from './groundAreas'\nimport {\n\tbuildNavigationData,\n\tbuildNavigationNow,\n\tinitRecast,\n\tinTurn,\n\ttype NavigationBuild,\n\ttype NavigationBuildConfig,\n\ttype NavigationBuilds,\n\ttype NavigationSpeeds,\n\tnavigationData\n} from './builds'\nimport type { Rect, Vec2 } from '#engine/math'\nimport { type Terrain, walkedCell } from '#engine/terrain'\nimport type { AgentMirrors, AgentMotion, AgentParams, AgentSave, AgentState, CellArea, NavDebugGeometry, Navigation } from './navigation'\n\n/**\n * The options a Recast navigation is made with: who builds it, the agents' size and slope limits, and the room for agents, obstacles and path steps\n *\n * @beta\n */\nexport interface RecastNavigationOptions {\n\t/** Who builds it and where what was built is kept: this thread and the process's memory when left out */\n\tbuilds?: NavigationBuilds\n\t/** Navmesh is eroded by this radius, so it has to cover the largest unit */\n\tagentRadius?: number\n\t/** Steepest slope units can walk, in degrees */\n\tmaxSlope?: number\n\t/**\n\t * How many agents the crowd makes room for at first: 512 when left out. It is not a limit: a crowd that is full makes\n\t * room for twice as many, and the agents go on as they were. A game that knows it brings thousands says so, to save\n\t * those moves\n\t */\n\tmaxAgents?: number\n\t/**\n\t * How many obstacles (buildings, shut gates) there is room for: past it, placing one is refused. From the map's\n\t * size when left out: half its cells, at least 8192, at most 65535\n\t */\n\tmaxObstacles?: number\n\t/**\n\t * How many steps a path search takes before it gives up with the best it found: a long path on a large map needs\n\t * more. From the map's size when left out: a quarter of its cells, at least 4096, at most 65535\n\t */\n\tmaxNodes?: number\n\t/**\n\t * Navigations cut for units of these sizes, each unit on the one for the biggest size it is not smaller than: a\n\t * big unit keeps from walls as far as it needs, where all keep 0.5 when left out. Each size is a navigation of its\n\t * own, with its own crowd, and the units of the other sizes stand in that crowd as mirrors, so they keep apart as on\n\t * one navigation (see `SizedNavigation`)\n\t */\n\tradii?: number[]\n\t/** How big a cell is, in world units; the engine's own when left out */\n\tcellSize?: number\n\t/**\n\t * What it is a navigation of: the ground, walked on, or the deep water, sailed on (`Terrain.buildWaterMesh`), at\n\t * the height of its surface. The ground when left out\n\t */\n\tsurface?: 'ground' | 'water'\n\t/**\n\t * How agents steer around each other (Detour's obstacle avoidance): a level (`AVOIDANCE_LEVELS`: how carefully a\n\t * crowd samples the velocities it might go at, `'medium'` being Detour's own), or the parts of `AvoidanceParams`\n\t * to change, Detour's own for the rest. `'medium'` when left out. `'low'` crosses and gathers crowds as well\n\t * in the measured cases for about a quarter less of a tick with a thousand walking, but it plays out other games\n\t * differently (six of the example's tuned AI tests), so it is a game's choice\n\t *\n\t * @beta\n\t */\n\tavoidance?: AvoidanceLevel | Partial<AvoidanceParams>\n\t/**\n\t * How hard agents push each other apart as they walk near each other (within eight radii), 0 for not at all:\n\t * Detour's separation weight. 0.5 when left out: at Detour's 1.5, a unit walking past standing ones is pushed off\n\t * its line and loses a tenth of its speed to it\n\t */\n\tseparation?: number\n\t/**\n\t * How a walking agent minds the walls, the edges of the ground it may walk (cliffs, buildings, trees). `'soft'` when\n\t * left out: an agent steers among velocities (Detour's obstacle avoidance) only while another agent, walking or\n\t * standing, is within its reach (eight of its radii), and otherwise follows its path, still pushed apart from those near it\n\t * (`separation`); where it does steer, a wall ahead weighs less (`SOFT_WALLS`). It keeps its speed between trees and\n\t * round corners. `'detour'` is Detour's own: every walking agent steers every tick, by `DEFAULT_AVOIDANCE`, and one\n\t * in a gap or hugging a corner, on ground cut its radius from every wall, goes slower or sideways for it\n\t *\n\t * @beta\n\t */\n\twalls?: 'soft' | 'detour'\n\t/**\n\t * How fast one on foot goes over the ground at a point, as a multiplier (`groundSpeedOfCell`): what a path weighs,\n\t * so that a way around slow ground wins where it is quicker (EN2). Asked as the ground is cut, and again for the tiles\n\t * a slowing layer changed on (`groundChanged`). Every cell 1 when left out; never asked of the water\n\t */\n\tspeedAt?: (x: number, z: number) => number\n}\n\n/**\n * How agents steer around each other: Detour's obstacle avoidance parameters, which weigh the velocities an agent\n * samples each tick. The one that costs least wins: going the speed it wants (`weightDesVel`), going as it went\n * (`weightCurVel`), passing on its preferred side (`weightSide`), and how soon it would hit something\n * (`weightToi`, within `horizTime` seconds). `velBias` is how far the samples stray from the velocity it wants, 0..1\n *\n * @beta\n */\nexport interface AvoidanceParams {\n\t/** How far the velocity samples may stray from the velocity the agent wants, 0..1 */\n\tvelBias: number\n\t/** How much a sample is penalised for differing from the speed the agent wants */\n\tweightDesVel: number\n\t/** How much a sample is penalised for differing from the velocity the agent has */\n\tweightCurVel: number\n\t/** How much a sample is penalised for not passing on the preferred side */\n\tweightSide: number\n\t/** How much a sample is penalised for hitting something soon */\n\tweightToi: number\n\t/** How many seconds ahead a sample is checked for hitting something */\n\thorizTime: number\n\t/** Samples a side in the grid sampling, odd. Only the adaptive sampling is used by the engine, which goes by the three below */\n\tgridSize: number\n\t/** How many divisions the adaptive sampling's pattern has */\n\tadaptiveDivs: number\n\t/** How many rings of samples the adaptive sampling has */\n\tadaptiveRings: number\n\t/** How many times the adaptive sampling is refined around the best sample */\n\tadaptiveDepth: number\n}\n\n/**\n * The engine's avoidance (`RecastNavigationOptions.avoidance`): Detour's own numbers, which `AVOIDANCE_LEVELS` change the sampling of\n *\n * @internal\n */\nexport const DEFAULT_AVOIDANCE: Readonly<AvoidanceParams> = Object.freeze({\n\tvelBias: 0.4,\n\tweightDesVel: 2,\n\tweightCurVel: 0.75,\n\tweightSide: 0.75,\n\tweightToi: 2.5,\n\thorizTime: 2.5,\n\tgridSize: 33,\n\tadaptiveDivs: 7,\n\tadaptiveRings: 2,\n\tadaptiveDepth: 5\n})\n\n/**\n * What `walls: 'soft'` changes of `DEFAULT_AVOIDANCE`, under the level and a game's own numbers: what is ahead counts\n * within 1.5 s (Detour's 2.5) and weighs 1.5 (2.5), and going the speed it wants weighs 3 (2), so that a slower\n * velocity that would touch a wall a little later no longer wins\n *\n * @beta\n */\nexport const SOFT_WALLS: Readonly<Partial<AvoidanceParams>> = Object.freeze({ horizTime: 1.5, weightToi: 1.5, weightDesVel: 3 })\n\n/**\n * How carefully a crowd steers: `'low'` samples fewer velocities, a cost a tick that grows with the crowd, `'high'` more\n *\n * @beta\n */\nexport type AvoidanceLevel = 'low' | 'medium' | 'high'\n\n/**\n * What each `AvoidanceLevel` changes of `DEFAULT_AVOIDANCE`: the sampling (`adaptiveDivs`, `adaptiveRings` and\n * `adaptiveDepth`, which what an agent costs a tick goes by)\n *\n * @beta\n */\nexport const AVOIDANCE_LEVELS: Readonly<Record<AvoidanceLevel, Readonly<Partial<AvoidanceParams>>>> = Object.freeze({\n\tlow: Object.freeze({ adaptiveDivs: 5, adaptiveRings: 1, adaptiveDepth: 3 }),\n\tmedium: Object.freeze({}),\n\thigh: Object.freeze({ adaptiveDivs: 7, adaptiveRings: 3, adaptiveDepth: 7 })\n})\n\nconst ANTICIPATE_TURNS = 1\nconst OBSTACLE_AVOIDANCE = 2\nconst SEPARATION = 4\nconst OPTIMIZE_VIS = 8\nconst OPTIMIZE_TOPO = 16\n\nconst DEFAULT_FLAGS = ANTICIPATE_TURNS | OBSTACLE_AVOIDANCE | SEPARATION | OPTIMIZE_VIS | OPTIMIZE_TOPO\nconst GHOST_FLAGS = ANTICIPATE_TURNS | OPTIMIZE_VIS | OPTIMIZE_TOPO\n/**\n * An agent with nowhere to go: no velocity sampled among its neighbours, which for one that wants to stand still comes to\n * standing still all the same (a crowd of idle units: EN1, the same hashes). It is pushed as any agent is\n */\nconst RESTING_FLAGS = ANTICIPATE_TURNS | SEPARATION | OPTIMIZE_VIS | OPTIMIZE_TOPO\n/** What an agent's target is while its path is still being looked for: requesting, waiting for the queue, waiting for the path */\nconst PLANNING = new Set([3, 4, 5])\n/** How fast an agent with no speed left comes to a halt, in ground units per second squared */\nconst BRAKING = 60\n/**\n * Detour's states of an agent. An invalid one is left out of every step of the crowd (no path checked, no neighbours\n * looked for, no velocity sampled, not moved, not pushed) but stays in the grid the others look for neighbours in: it\n * is what an anchored agent is, asleep where it stands, while everyone else still goes around it\n */\nconst INVALID = 0\nconst WALKING = 1\n\ninterface AgentEntry {\n\tagent: CrowdAgent\n\tradius: number\n\tanchored: boolean\n\tanchorX: number\n\tanchorZ: number\n\tghost: boolean\n\t/**\n\t * It walks through everyone and everyone through it (`setPhasing`): on a crowd of its own (`phasers`), with nobody\n\t * else in it, so it is neither anyone's neighbour nor has any\n\t */\n\tphasing?: boolean\n\t/** Where it was last sent, snapped: kept for a save, which cannot read it back from the crowd */\n\ttarget: Vec2 | null\n\t/** The flags it steers by now: with obstacle avoidance or without, as its neighbours are (`walls: 'soft'`) */\n\tflags: number\n}\n\n/**\n * Where the mirror of an agent that phases is kept (`setMirrorPhasing`): far from anyone, so that it is nobody's\n * neighbour, and still in its place among the crowd's agents\n */\nconst PARKED = -100000\n\n/** An agent of another crowd (`AgentMirrors`): asleep in this one, where only `moveMirror` moves it */\ninterface Mirror extends AgentEntry {\n\ty: number\n\tvx: number\n\tvz: number\n}\n\n/** Each cell's speed on the ground, as a build is told it: none where every cell is 1 (the ground cut as it always was) */\nfunction speedsOf(terrain: Terrain, speedAt: (x: number, z: number) => number): NavigationSpeeds | undefined {\n\tconst { width, depth } = terrain\n\tconst values = new Float32Array(width * depth)\n\tlet slow = false\n\tfor (let z = 0; z < depth; z++) {\n\t\tfor (let x = 0; x < width; x++) {\n\t\t\tconst speed = speedAt(x + 0.5, z + 0.5)\n\t\t\tvalues[z * width + x] = speed\n\t\t\tif (speed !== 1) slow = true\n\t\t}\n\t}\n\treturn slow ? { width, depth, values } : undefined\n}\n\n/** The least of one coordinate (0 x, 2 z) of the vertices a mesh's triangles use: where its tiles start, as Recast's bounds do */\nfunction minOf(positions: Float32Array, indices: Uint32Array, axis: number): number {\n\tlet least = Infinity\n\tfor (let i = 0; i < indices.length; i++) least = Math.min(least, positions[indices[i] * 3 + axis])\n\treturn least\n}\n\n/** A limit from the map's size, never less than it was before the map's size counted, never past what Detour counts to */\nconst limitFor = (wanted: number, least: number) => Math.min(Math.max(Math.ceil(wanted), least), 65535)\n\n/** How many requests the tile cache queues, and how many tiles it makes again from one batch of them, at most (Detour's) */\nconst MAX_REQUESTS = 64\n/** Half of Detour's 64: a column of the tile grid may hold more than one layer, and each is a tile of its own */\nconst MAX_HELD_COLUMNS = 32\n\n/**\n * The walkable ground about some tiles (their keys), as `Terrain.buildMesh(true)` and `speedsOf` give it whole: the\n * triangles of the cells within a tile's border (and a cell more) of each, in the whole mesh's order, and the speed of\n * the cell a point is in, so that each of those tiles is made from it as from the whole (`groundTileLayers` takes a\n * tile's triangles by where they reach). As much as those tiles need, however big the map\n */\nfunction groundPart(\n\tterrain: Terrain,\n\tconfig: NavigationBuildConfig,\n\tspeedAt: (x: number, z: number) => number,\n\tkeys: readonly number[],\n\tgrid: { bbMin: readonly number[]; tileSize: number; border: number }\n): { build: NavigationBuild; speedOf: (x: number, z: number) => number } {\n\tconst { width, depth, vertsX } = terrain\n\tconst reach = grid.border + 1\n\tconst near: number[] = []\n\tfor (const key of keys) {\n\t\tconst tx = Math.floor(key / 65536)\n\t\tconst ty = key % 65536\n\t\tconst x0 = Math.max(0, Math.floor(grid.bbMin[0] + tx * grid.tileSize - reach))\n\t\tconst x1 = Math.min(width - 1, Math.ceil(grid.bbMin[0] + (tx + 1) * grid.tileSize + reach))\n\t\tconst z0 = Math.max(0, Math.floor(grid.bbMin[2] + ty * grid.tileSize - reach))\n\t\tconst z1 = Math.min(depth - 1, Math.ceil(grid.bbMin[2] + (ty + 1) * grid.tileSize + reach))\n\t\tfor (let iz = z0; iz <= z1; iz++) for (let ix = x0; ix <= x1; ix++) near.push(iz * width + ix)\n\t}\n\t// in the whole mesh's order, row by row, each cell once: as a tile cut alone from the whole is given them\n\tnear.sort((a, b) => a - b)\n\tconst speeds = new Map<number, number>()\n\tconst vertices = new Map<number, number>()\n\tconst positions: number[] = []\n\tconst indices: number[] = []\n\tconst vertex = (v: number) => {\n\t\tlet at = vertices.get(v)\n\t\tif (at === undefined) {\n\t\t\tat = vertices.size\n\t\t\tvertices.set(v, at)\n\t\t\tpositions.push(v % vertsX, terrain.heights[v], Math.floor(v / vertsX))\n\t\t}\n\t\treturn at\n\t}\n\tfor (let i = 0; i < near.length; i++) {\n\t\tconst cell = near[i]\n\t\tif (cell === near[i - 1]) continue\n\t\tconst ix = cell % width\n\t\tconst iz = (cell - ix) / width\n\t\tif (!walkedCell(terrain, ix, iz)) continue\n\t\tspeeds.set(cell, speedAt(ix + 0.5, iz + 0.5))\n\t\tconst a = iz * vertsX + ix\n\t\tconst [va, vb, vc, vd] = [vertex(a), vertex(a + 1), vertex(a + vertsX), vertex(a + vertsX + 1)]\n\t\tindices.push(va, vc, vb, vb, vc, vd)\n\t}\n\treturn {\n\t\tbuild: { positions: Float32Array.from(positions), indices: Uint32Array.from(indices), config },\n\t\tspeedOf: (x, z) => speeds.get(Math.floor(z) * width + Math.floor(x)) ?? 1\n\t}\n}\n\n/**\n * The tiles of a navigation made again alone since its ground was last cut whole (`RecastNavigation.groundChanged`,\n * `reshape` of a part): the compressed layers of each column of the grid, by its key (`tileKey`). The whole's tile\n * cache keeps its own layers there (Recast cannot take a tile out of one), of the ground as it was: the navmesh's tiles\n * of such a column are made from these instead, through a tile cache of the column alone with the obstacles on it\n * (`buildColumn`)\n */\ntype Overridden = Map<number, Uint8Array[]>\n\n/**\n * More than this share of the tiles reshaped at once is cut whole, and nothing kept apart after. Only a reshape: a\n * slowing layer painted is never cut whole (`groundChanged`), its tiles alone being quicker\n */\nconst MOST_TILES = 0.5\n\n/** Where the tiles are: their size and where the first starts, in ground units */\ninterface TileGrid {\n\tsize: number\n\toriginX: number\n\toriginZ: number\n}\n\n/** The slot of the crowd's obstacle avoidance parameters every agent uses */\nconst AVOIDANCE_SLOT = 3\n\n/**\n * A crowd on the navmesh with room for `maxAgents` agents, of any radius up to twice the one it was cut for, steering\n * as `avoidance` says\n */\nfunction crowdOf(navMesh: NavMesh, maxAgents: number, agentRadius: number, avoidance: Readonly<AvoidanceParams>, weighs: boolean): Crowd {\n\tconst crowd = new Crowd(navMesh, { maxAgents, maxAgentRadius: Math.max(agentRadius * 2, 1) })\n\tcrowd.navMeshQuery.defaultQueryHalfExtents = { x: 2, y: 6, z: 2 }\n\t// the paths its agents plan pay for slow ground as the navigation's own searches do\n\tif (weighs) setAreaCosts(crowd.getFilter(0))\n\tconst params = new Raw.Module.dtObstacleAvoidanceParams()\n\tparams.velBias = avoidance.velBias\n\tparams.weightDesVel = avoidance.weightDesVel\n\tparams.weightCurVel = avoidance.weightCurVel\n\tparams.weightSide = avoidance.weightSide\n\tparams.weightToi = avoidance.weightToi\n\tparams.horizTime = avoidance.horizTime\n\tparams.gridSize = avoidance.gridSize\n\tparams.adaptiveDivs = avoidance.adaptiveDivs\n\tparams.adaptiveRings = avoidance.adaptiveRings\n\tparams.adaptiveDepth = avoidance.adaptiveDepth\n\tcrowd.raw.setObstacleAvoidanceParams(AVOIDANCE_SLOT, params)\n\tRaw.destroy(params)\n\treturn crowd\n}\n\n/**\n * What the ground's changes asked of a navigation and it has not done yet (`RecastNavigation.groundChanged`, `reshape`):\n * done together at the first thing asked of it after them, or as the tick ends (`settleGround`)\n */\ninterface GroundAsked {\n\t/** How many asks: the version goes up by as many, as it would have one by one */\n\tasks: number\n\t/** A whole cut asked: of no part, or of a part reaching most of the tiles. Nothing else is then needed */\n\twhole: boolean\n\t/** The tiles a part of the ground reshaped reaches (`reshape`): cut again from the whole ground as it is now */\n\treshaped: Set<number>\n\t/** The tiles a slowing layer changed on (`groundChanged`): cut again from the ground about them alone, where nothing is reshaped */\n\tpainted: Set<number>\n}\n\nexport class RecastNavigation implements Navigation, AgentMirrors {\n\t/** One more each time walkable space changes (`version`) */\n\tprivate changes = 0\n\t/** What the ground's changes asked and is not done yet: none, mostly */\n\tprivate asked: GroundAsked | undefined\n\n\tprivate agents = new Map<number, AgentEntry>()\n\tprivate mirrors = new Map<number, Mirror>()\n\t/**\n\t * The crowd of the agents that walk through others (`setPhasing`), on the same navmesh, made as the first comes:\n\t * Detour has no way to keep an agent out of the others' neighbours, so it walks where there are none. Walls,\n\t * cliffs and obstacles are the navmesh's, and stop it as they stop anyone\n\t */\n\tprivate phasers: Crowd | undefined\n\t/** How many agents the crowd of those that phase has room for now */\n\tprivate phasersRoom = 0\n\tprivate obstacles = new Map<number, Obstacle>()\n\t/** The room the crowd was first made with: a crowd made anew (`reseat`) starts there, as a loaded world's does */\n\tprivate firstMaxAgents = 0\n\tprivate obstaclesDirty = false\n\t/** Obstacles are put down many at once (`holdObstacles`): their requests wait in the tile cache to be made into tiles together */\n\tprivate holding = false\n\t/** Requests waiting while held, and the columns of the tile grid they touch (x * 65536 + z) */\n\tprivate held = 0\n\tprivate readonly heldColumns = new Set<number>()\n\t/** Points handed to the module, which copies them in: one, and a second for a path's end */\n\tprivate readonly scratch = { x: 0, y: 0, z: 0 }\n\tprivate readonly scratchEnd = { x: 0, y: 0, z: 0 }\n\t/** How far `closestPoint` looks, set for each ask */\n\tprivate readonly closestQuery = { halfExtents: { x: 0, y: 8, z: 0 } }\n\t/** What `steer` works in each tick, kept: the agents that count, where they are, and a grid of them */\n\tprivate readonly near: AgentEntry[] = []\n\tprivate nearX = new Float64Array(0)\n\tprivate nearZ = new Float64Array(0)\n\tprivate nearNext = new Int32Array(0)\n\tprivate readonly nearHeads = new Map<number, number>()\n\t/** The tiles made again alone since the ground was last cut whole (`groundChanged`, `reshape` of a part) */\n\tprivate overridden: Overridden | undefined\n\t/**\n\t * The obstacles about each column of the grid (`columnsOf`), by their keys, in the order they were put down: what a\n\t * column made alone is made with. Kept while tiles are made alone, made from `obstacles` as the first is\n\t */\n\tprivate byColumn: Map<number, Set<number>> | undefined\n\t/** The grid the whole was cut on (`tileGridOf`): a part is made again alone only where the ground is cut on the same */\n\tprivate grid: ReturnType<typeof tileGridOf> | undefined\n\t/** Columns of the grid obstacles were put down or taken up on, while tiles are made alone: made again from theirs */\n\tprivate readonly requested = new Set<number>()\n\n\tprivate constructor(\n\t\tprivate readonly terrain: Terrain,\n\t\tprivate navMesh: NavMesh,\n\t\tprivate tileCache: TileCache,\n\t\tprivate crowd: Crowd,\n\t\tprivate query: NavMeshQuery,\n\t\tprivate readonly agentRadius: number,\n\t\t/** How many agents the crowd has room for now: twice as many each time it is full */\n\t\tprivate maxAgents: number,\n\t\t/** How many obstacles the tile cache was made with room for */\n\t\tprivate readonly maxObstacles: number,\n\t\t/** How many steps a path search takes at most */\n\t\tprivate readonly maxNodes: number,\n\t\t/** What Recast's import made besides the navmesh and the tile cache, which the tile cache uses as long as it lives */\n\t\tprivate owned: readonly unknown[],\n\t\t/** How its agents steer around each other, and how hard they push apart (`RecastNavigationOptions`) */\n\t\treadonly avoidance: Readonly<AvoidanceParams>,\n\t\treadonly separation: number,\n\t\t/** How its agents mind the walls (`RecastNavigationOptions.walls`) */\n\t\treadonly walls: 'soft' | 'detour',\n\t\t/** Where its tiles are: to make again those a slowing layer changed on, and to know which an obstacle touches */\n\t\tprivate tiles: TileGrid,\n\t\t/** The height of what it is a navigation of, at a point: the ground, or the water's surface */\n\t\tprivate readonly heightAt: (x: number, z: number) => number = (x, z) => terrain.heightAt(x, z),\n\t\t/** What a path weighs (`speedAt`), and how the ground was cut (`config`): to cut a part of it again (`groundChanged`) */\n\t\tprivate readonly ground?: { speedAt: (x: number, z: number) => number; config: NavigationBuildConfig },\n\t\t/** What it is cut from, the ground as it is now, the way it was first cut: to cut it again (`reshape`) */\n\t\tprivate readonly cut?: () => { build: NavigationBuild; tiles: TileGrid }\n\t) {\n\t\tthis.firstMaxAgents = maxAgents\n\t}\n\n\tstatic async create(terrain: Terrain, options: RecastNavigationOptions = {}): Promise<RecastNavigation> {\n\t\t// built in a worker: asked side by side, each read here as it comes. Built on this thread, one after another, each\n\t\t// read before the next is built: Recast's WebAssembly broke (memory out of bounds, a tile cache that would not be\n\t\t// let go of) where one navigation was built between another's build and its reading (a world's ground's and its\n\t\t// water's, asked at once)\n\t\tconst builder = options.builds?.builder\n\t\tif (builder && builder !== buildNavigationData) return RecastNavigation.made(terrain, options)\n\t\treturn inTurn(() => RecastNavigation.made(terrain, options))\n\t}\n\n\tprivate static async made(terrain: Terrain, options: RecastNavigationOptions): Promise<RecastNavigation> {\n\t\tawait initRecast()\n\n\t\tconst cells = terrain.width * terrain.depth\n\t\tconst {\n\t\t\tagentRadius = 0.5,\n\t\t\tmaxSlope = 38,\n\t\t\tmaxAgents = 512,\n\t\t\t// as many as there are cells: a map can be wooded all over (a tree a cell), and a refused one blocks nothing\n\t\t\tmaxObstacles = limitFor(cells, 8192),\n\t\t\tmaxNodes = limitFor(cells / 4, 4096),\n\t\t\tcellSize = 0.25,\n\t\t\tsurface = 'ground',\n\t\t\tseparation = 0.5,\n\t\t\twalls = 'soft'\n\t\t} = options\n\t\tconst avoidance: Readonly<AvoidanceParams> = Object.freeze({\n\t\t\t...DEFAULT_AVOIDANCE,\n\t\t\t...(walls === 'soft' && SOFT_WALLS),\n\t\t\t...AVOIDANCE_LEVELS[typeof options.avoidance === 'string' ? options.avoidance : 'medium'],\n\t\t\t...(typeof options.avoidance === 'object' && options.avoidance)\n\t\t})\n\t\tconst cellHeight = 0.2\n\t\tconst water = surface === 'water'\n\t\tconst config: NavigationBuildConfig = {\n\t\t\tcs: cellSize,\n\t\t\tch: cellHeight,\n\t\t\ttileSize: 48,\n\t\t\twalkableSlopeAngle: maxSlope,\n\t\t\twalkableHeight: Math.ceil(2 / cellHeight),\n\t\t\twalkableClimb: Math.ceil(0.6 / cellHeight),\n\t\t\twalkableRadius: Math.ceil(agentRadius / cellSize),\n\t\t\tmaxSimplificationError: 1.1,\n\t\t\tmergeRegionArea: 20,\n\t\t\tmaxVertsPerPoly: 6,\n\t\t\tdetailSampleDist: 4,\n\t\t\tdetailSampleMaxError: 0.5,\n\t\t\texpectedLayersPerTile: 1,\n\t\t\tmaxObstacles\n\t\t}\n\t\t// slow ground, weighed by paths (EN2): the water is sailed at one speed\n\t\tconst speedAt = water ? undefined : options.speedAt\n\t\t// what it is cut from, the ground as it is: now, and again as it is reshaped\n\t\tconst cut = () => {\n\t\t\tconst { positions, indices } = water ? terrain.buildWaterMesh() : terrain.buildMesh(true)\n\t\t\tconst speeds = speedAt && speedsOf(terrain, speedAt)\n\t\t\treturn {\n\t\t\t\tbuild: { positions, indices, config, ...(speeds && { speeds }) },\n\t\t\t\ttiles: { size: config.tileSize * cellSize, originX: minOf(positions, indices, 0), originZ: minOf(positions, indices, 2) }\n\t\t\t}\n\t\t}\n\t\tconst first = cut()\n\t\t// built here or in a worker, or kept from a build of the same ground before (S37): read from what was built\n\t\t// either way, so the two are the same navigation\n\t\tconst data = await navigationData(first.build, options.builds)\n\t\t// what makes a tile again when an obstacle comes or goes: as the build made it, each polygon's area the speed\n\t\t// under it as the ground is now\n\t\tconst process = speedAt ? groundMeshProcess(speedAt) : createDefaultTileCacheMeshProcess()\n\t\tconst { navMesh, tileCache, allocator, compressor } = importTileCache(data, process)\n\t\tconst query = new NavMeshQuery(navMesh, { maxNodes })\n\t\tquery.defaultQueryHalfExtents = { x: 2, y: 6, z: 2 }\n\t\tif (speedAt) setAreaCosts(query.defaultFilter)\n\t\tconst crowd = crowdOf(navMesh, maxAgents, agentRadius, avoidance, !!speedAt)\n\t\tconst navigation = new RecastNavigation(\n\t\t\tterrain,\n\t\t\tnavMesh,\n\t\t\ttileCache,\n\t\t\tcrowd,\n\t\t\tquery,\n\t\t\tagentRadius,\n\t\t\tmaxAgents,\n\t\t\tmaxObstacles,\n\t\t\tmaxNodes,\n\t\t\t[process, allocator, compressor],\n\t\t\tavoidance,\n\t\t\tseparation,\n\t\t\twalls,\n\t\t\tfirst.tiles,\n\t\t\twater ? (x, z) => terrain.waterHeightAt(x, z) : undefined,\n\t\t\tspeedAt && { speedAt, config },\n\t\t\tcut\n\t\t)\n\t\t// the grid it is cut on, for a part reshaped to be cut again alone on it\n\t\tif (first.build.indices.length) navigation.grid = tileGridOf(first.build)\n\t\treturn navigation\n\t}\n\n\t/** One more each time walkable space changes: what the ground's changes asked of it done first (`settleGround`) */\n\tget version(): number {\n\t\tif (this.asked) this.settleGround()\n\t\treturn this.changes\n\t}\n\n\t/**\n\t * The ground it is a navigation of was reshaped (`World.reshapeGround`): cut again from the ground as it is now, on\n\t * this thread, as it was cut first (its options, its slow ground); what is in the way put down again where it was, in\n\t * the order it was, and every agent moved over as it stood, as a crowd that grows is. Every machine cuts it the same.\n\t *\n\t * Told the part that changed (`area`, in cells), only the tiles it reaches are cut again (`reshapeTiles`), where the\n\t * ground is still cut on the same grid and that is under half of the tiles: the rest of the navmesh, what is in the\n\t * way and every agent stay as they are, and an agent whose way went over a tile cut again finds it again, as when a\n\t * building goes up on it.\n\t *\n\t * Not at once: at the first thing asked of it after, or as the tick ends (`settleGround`), with what the other\n\t * changes of the ground asked before then (a slowing layer painted on the same part, `groundChanged`), each tile once.\n\t * Nothing asked of it sees the ground as it was. True where it has a ground to cut again; one that cannot be cut as it\n\t * is now (no water left) is left as it was when the time comes\n\t */\n\treshape(area?: CellArea): boolean {\n\t\tif (!this.cut) return false\n\t\tconst asked = this.ask()\n\t\tconst grid = this.grid\n\t\tif (!area || !grid || asked.whole) {\n\t\t\tasked.whole = true\n\t\t\treturn true\n\t\t}\n\t\t// the tiles the part reaches: its cells grown by two (a vertex moved changes the cells round it, and the climb and\n\t\t// the slope look a little further) and by a tile's border\n\t\tconst reach = 2 + grid.border\n\t\tconst column = (x: number, origin: number, count: number) => Math.min(count - 1, Math.max(0, Math.floor((x - origin) / grid.tileSize)))\n\t\tconst tx0 = column(area.x - reach, grid.bbMin[0], grid.tileWidth)\n\t\tconst tx1 = column(area.x + area.width + reach, grid.bbMin[0], grid.tileWidth)\n\t\tconst ty0 = column(area.z - reach, grid.bbMin[2], grid.tileHeight)\n\t\tconst ty1 = column(area.z + area.depth + reach, grid.bbMin[2], grid.tileHeight)\n\t\tif ((tx1 - tx0 + 1) * (ty1 - ty0 + 1) > grid.tileWidth * grid.tileHeight * MOST_TILES) asked.whole = true\n\t\telse for (let tx = tx0; tx <= tx1; tx++) for (let ty = ty0; ty <= ty1; ty++) asked.reshaped.add(tileKey(tx, ty))\n\t\treturn true\n\t}\n\n\t/** What the ground's changes ask of it, one more ask */\n\tprivate ask(): GroundAsked {\n\t\tconst asked = (this.asked ??= { asks: 0, whole: false, reshaped: new Set(), painted: new Set() })\n\t\tasked.asks++\n\t\treturn asked\n\t}\n\n\t/**\n\t * Does what the ground's changes asked of it and it has not done yet (`reshape`, `groundChanged`), all together: a\n\t * tile reached by several once, from the ground as it is now. Each ask was weighed as it came (cut whole, or its\n\t * tiles), so that what comes out is what doing them one by one makes, tile for tile: where a part of the ground was\n\t * reshaped, the tiles it reaches cut again of the whole ground as it is now, with those a layer was painted on; a\n\t * layer painted alone, of the ground about its tiles (`groundPart`). The version goes up once for each ask, as it\n\t * would have. Asked before anything else is asked of it, and by the world as each tick ends\n\t */\n\tsettleGround(): void {\n\t\tconst asked = this.asked\n\t\tif (!asked) return\n\t\t// let go of first: what is done below asks things of the navigation itself\n\t\tthis.asked = undefined\n\t\tconst grid = this.grid\n\t\tif (!asked.whole && grid) {\n\t\t\tif (asked.reshaped.size) {\n\t\t\t\tconst { build } = this.cut!()\n\t\t\t\tif (this.reshapeTiles(build, [...asked.reshaped, ...asked.painted])) {\n\t\t\t\t\tthis.changes += asked.asks\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// in order, so that every machine makes them the same way\n\t\t\t\tconst keys = [...asked.painted].sort((a, b) => a - b)\n\t\t\t\tconst { build, speedOf } = groundPart(this.terrain, this.ground!.config, this.ground!.speedAt, keys, grid)\n\t\t\t\tif (this.retile(build, keys, grid.cut, speedOf)) {\n\t\t\t\t\tthis.changes += asked.asks\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.cutWhole()) this.changes += asked.asks\n\t}\n\n\t/** Cut again whole, of the ground as it is now, what is in the way and every agent put back as they were: false where it cannot be */\n\tprivate cutWhole(): boolean {\n\t\tif (!this.cut) return false\n\t\tthis.drain()\n\t\tconst { build, tiles } = this.cut()\n\t\tlet made: ReturnType<typeof importTileCache>\n\t\ttry {\n\t\t\tmade = importTileCache(buildNavigationNow(build), this.owned[0] as Parameters<typeof importTileCache>[1])\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t\tconst boxes = [...this.obstacles].flatMap(([key, obstacle]) =>\n\t\t\tobstacle.type === 'box'\n\t\t\t\t? [\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: obstacle.position.x,\n\t\t\t\t\t\t\t\tz: obstacle.position.z,\n\t\t\t\t\t\t\t\thw: obstacle.halfExtents.x - this.agentRadius,\n\t\t\t\t\t\t\t\thd: obstacle.halfExtents.z - this.agentRadius\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t] as const\n\t\t\t\t\t]\n\t\t\t\t: []\n\t\t)\n\t\tconst agents = [...this.agents.keys()].map((id) => [id, this.saveAgent(id)!] as const)\n\t\t// cut whole: nothing kept apart\n\t\tthis.dropOverridden()\n\t\tthis.grid = build.indices.length ? tileGridOf(build) : undefined\n\t\tconst old = [this.crowd, this.query, this.tileCache, this.navMesh]\n\t\tthis.navMesh = made.navMesh\n\t\tthis.tileCache = made.tileCache\n\t\tthis.owned = [this.owned[0], made.allocator, made.compressor]\n\t\tthis.tiles = tiles\n\t\tthis.query = new NavMeshQuery(made.navMesh, { maxNodes: this.maxNodes })\n\t\tthis.query.defaultQueryHalfExtents = { x: 2, y: 6, z: 2 }\n\t\tif (this.ground) setAreaCosts(this.query.defaultFilter)\n\t\tthis.crowd = crowdOf(made.navMesh, this.maxAgents, this.agentRadius, this.avoidance, !!this.ground)\n\t\tthis.obstacles.clear()\n\t\tthis.agents.clear()\n\t\t// those that phase walk the old navmesh too: their crowd let go of before it, and made anew on the new one as the\n\t\t// first comes back\n\t\tthis.phasers?.destroy()\n\t\tthis.phasers = undefined\n\t\tfor (const each of old) each.destroy()\n\t\t// put down together, a tile made once however many are on it, as a world being made puts them down\n\t\tthis.holding = false\n\t\tthis.held = 0\n\t\tthis.heldColumns.clear()\n\t\tthis.obstaclesDirty = false\n\t\tthis.holdObstacles(true)\n\t\tfor (const [key, rect] of boxes) this.addObstacle(key, rect)\n\t\tthis.holdObstacles(false)\n\t\tfor (const [id, save] of agents) this.restoreAgent(id, save)\n\t\tthis.remakeMirrors()\n\t\treturn true\n\t}\n\n\t/**\n\t * A slowing layer of cells changed on these cells (`World.setCells`): the tiles they are in are cut again alone from\n\t * the ground as it is now (`retile`), its triangles marked with their cells' speeds as a whole\n\t * cut marks them, so that the polygons part where the speed does now and the navmesh is the one a world made or\n\t * loaded now cuts whole, tile for tile and area for area: a game saved after it plays out the same loaded. Only the\n\t * ground about those tiles is read (`groundPart`). Where the change may have made cells walkable or not\n\t * (`walkability`, a thicket), the tiles whose border reaches them too: the ground kept from them by the agents' radius\n\t * reaches over the tile's edge. Never cut whole, however many tiles: cutting them alone is quicker, even all of them\n\t * (half the time of a whole cut on a 128 x 128 map, which also puts every obstacle and agent back). Not at once: with\n\t * what the other changes of the ground asked, before the next thing asked of it or as the tick ends (`settleGround`)\n\t */\n\tgroundChanged(cells: readonly number[], walkability = false): void {\n\t\tif (!this.ground || !cells.length) return\n\t\t// a ground with no tiles yet may have some once a reshape asked before is done: that first, as it would have been\n\t\tif (!this.grid && this.asked) this.settleGround()\n\t\tconst grid = this.grid\n\t\tif (!grid) return\n\t\tconst { width } = this.terrain\n\t\tconst column = (x: number, origin: number, count: number) => Math.min(count - 1, Math.max(0, Math.floor((x - origin) / grid.tileSize)))\n\t\t// the tiles the cells are in: a cell's speed is only an area of its ground's spans, which a tile's layers keep of\n\t\t// its own cells and none of its border's (what is walked, and so the layers' shape, is not the speed's). Where it is\n\t\t// what is walked, every tile whose border (what it is rasterised with) the cell is in\n\t\tconst reach = walkability ? grid.border : 0\n\t\tconst tiles = new Set<number>()\n\t\tfor (const cell of cells) {\n\t\t\tconst x = cell % width\n\t\t\tconst z = (cell - x) / width\n\t\t\tif (!reach) {\n\t\t\t\ttiles.add(tileKey(column(x + 0.5, grid.bbMin[0], grid.tileWidth), column(z + 0.5, grid.bbMin[2], grid.tileHeight)))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst tx1 = column(x + 1 + reach, grid.bbMin[0], grid.tileWidth)\n\t\t\tconst ty1 = column(z + 1 + reach, grid.bbMin[2], grid.tileHeight)\n\t\t\tfor (let tx = column(x - reach, grid.bbMin[0], grid.tileWidth); tx <= tx1; tx++) {\n\t\t\t\tfor (let ty = column(z - reach, grid.bbMin[2], grid.tileHeight); ty <= ty1; ty++) tiles.add(tileKey(tx, ty))\n\t\t\t}\n\t\t}\n\t\tconst asked = this.ask()\n\t\tif (asked.whole) return\n\t\tfor (const key of tiles) asked.painted.add(key)\n\t}\n\n\t/** The navmesh's tiles of a column of the grid made again: from its layers made alone where it is one of them */\n\tprivate buildTilesAt(key: number): void {\n\t\tconst layers = this.overridden?.get(key)\n\t\tif (layers) this.buildColumn(key, layers)\n\t\telse this.tileCache.buildNavMeshTilesAt(Math.floor(key / 65536), key % 65536, this.navMesh)\n\t}\n\n\t/** Takes every layer of a column out of the navmesh */\n\tprivate removeTilesAt(tx: number, ty: number): void {\n\t\tfor (let layer = 0; layer < 32; layer++) {\n\t\t\tconst ref = this.navMesh.getTileRefAt(tx, ty, layer)\n\t\t\tif (ref) this.navMesh.removeTile(ref)\n\t\t}\n\t}\n\n\t/**\n\t * Cuts again only these tiles (their keys: those a part of the ground reshaped reaches, `reshape`, and those a slowing\n\t * layer was painted on, `groundChanged`) of the whole ground as it is now (`retile`). False, with nothing changed,\n\t * where it cannot be (the ground cut on another grid now): it is cut whole\n\t */\n\tprivate reshapeTiles(build: NavigationBuild, tiles: readonly number[]): boolean {\n\t\tconst grid = this.grid\n\t\tif (!grid || !build.indices.length) return false\n\t\tconst now = tileGridOf(build)\n\t\tconst same = (a: readonly number[], b: readonly number[]) => a.every((value, i) => value === b[i])\n\t\tif (now.tileWidth !== grid.tileWidth || now.tileHeight !== grid.tileHeight || !same(now.bbMin, grid.bbMin) || !same(now.bbMax, grid.bbMax)) return false\n\t\t// each once, in order, so that every machine makes them the same way\n\t\tconst keys = [...new Set(tiles)].sort((a, b) => a - b)\n\t\treturn this.retile(build, keys, now.cut)\n\t}\n\n\t/**\n\t * Cuts these columns of the grid again alone (their keys, in order), each from the build as a whole cut of it would\n\t * make it (`groundTileLayers`; `speedOf` where the build is a part of the ground), and keeps their layers apart from\n\t * the whole's tile cache (`overridden`, which Recast cannot take a tile out of): the navmesh's tiles there made again\n\t * from them with the obstacles on them, in order (`buildColumn`). Only what these columns need is done, however many\n\t * were made alone before. False, with nothing changed, where they could not be made: it is cut whole\n\t */\n\tprivate retile(build: NavigationBuild, keys: readonly number[], cut: TileCut, speedOf?: (x: number, z: number) => number): boolean {\n\t\tconst made = groundTileLayers(build, keys, cut, speedOf)\n\t\tif (!made) return false\n\t\t// what was asked of the whole's tile cache is in its tiles first\n\t\tthis.drain()\n\t\tfor (let i = 0; this.obstaclesDirty; i++) {\n\t\t\tif (i > 100000) throw new Error('Navigation: the obstacles never settled')\n\t\t\tthis.obstaclesDirty = !this.updateTiles()\n\t\t}\n\t\tif (!this.overridden) {\n\t\t\tthis.overridden = new Map()\n\t\t\t// the obstacles about each column, from now on followed as they come and go\n\t\t\tthis.byColumn = new Map()\n\t\t\tfor (const [key, obstacle] of this.obstacles) if (obstacle.type === 'box') this.indexObstacle(key, obstacle, true)\n\t\t}\n\t\tfor (const key of keys) {\n\t\t\tthis.overridden.set(key, made.get(key)!)\n\t\t\tthis.buildColumn(key, made.get(key)!)\n\t\t}\n\t\treturn true\n\t}\n\n\t/**\n\t * The navmesh's tiles of a column made alone (`retile`) made again from its layers, as the whole's tile cache makes a\n\t * tile: through a tile cache of that column alone, in the whole's allocator and compressor, with every obstacle about\n\t * it put down on it (Detour carves an obstacle into the tiles it touches as it is put down, so the layers go in\n\t * first), a batch at a time as Detour queues them. Every layer of the column taken out of the navmesh first: the\n\t * ground as it is now may have fewer than it had. Every layer is made again, each once: those an obstacle touches by\n\t * Detour as it puts it down, the rest after (an obstacle `columnsOf` puts about a column may touch none of it)\n\t */\n\tprivate buildColumn(key: number, layers: readonly Uint8Array[]): void {\n\t\tconst tx = Math.floor(key / 65536)\n\t\tconst ty = key % 65536\n\t\tthis.removeTilesAt(tx, ty)\n\t\tif (!layers.length) return\n\t\tconst near = [...(this.byColumn?.get(key) ?? [])]\n\t\tconst tileCache = columnTileCache(\n\t\t\tthis.grid!.cut,\n\t\t\tthis.owned[0] as TileCacheMeshProcess,\n\t\t\t{ tiles: layers.length, obstacles: Math.max(1, near.length) },\n\t\t\tthis.owned[1] as InstanceType<typeof Raw.RecastLinearAllocator>,\n\t\t\tthis.owned[2] as InstanceType<typeof Raw.RecastFastLZCompressor>\n\t\t)\n\t\tif (!tileCache) throw new Error(`Navigation: a tile cache for the tiles at ${tx}, ${ty} could not be made`)\n\t\tconst copies: { destroy(): void }[] = []\n\t\ttry {\n\t\t\tfor (const bytes of layers) {\n\t\t\t\tconst data = addTileLayer(tileCache, bytes)\n\t\t\t\tif (!data) throw new Error(`Navigation: the tiles at ${tx}, ${ty} could not be made again`)\n\t\t\t\tcopies.push(data)\n\t\t\t}\n\t\t\tif (!near.length) {\n\t\t\t\ttileCache.buildNavMeshTilesAt(tx, ty, this.navMesh)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst settle = () => {\n\t\t\t\tfor (let i = 0; !tileCache.update(this.navMesh).upToDate; i++) {\n\t\t\t\t\tif (i > 100000) throw new Error('Navigation: the obstacles never settled')\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet queued = 0\n\t\t\tfor (const each of near) {\n\t\t\t\t// only boxes are kept by column\n\t\t\t\tconst obstacle = this.obstacles.get(each) as BoxObstacle\n\t\t\t\tif (queued === MAX_REQUESTS) {\n\t\t\t\t\tsettle()\n\t\t\t\t\tqueued = 0\n\t\t\t\t}\n\t\t\t\ttileCache.addBoxObstacle(obstacle.position, obstacle.halfExtents, obstacle.angle)\n\t\t\t\tqueued++\n\t\t\t}\n\t\t\t// Detour makes the tiles an obstacle touches as it judges it, which is less than `columnsOf` says may be: the\n\t\t\t// obstacle's own bounds (1.41 of its half side) against the columns they fall in, and then against the layers'\n\t\t\t// ground (their walkable cells and heights), so one about a column may touch none of it. A layer left out is\n\t\t\t// made here, whatever the obstacles about it: with those Detour carves into it (the ones it judged touch it),\n\t\t\t// as the whole's tile cache makes it\n\t\t\tsettle()\n\t\t\tif (layers.some((bytes) => !this.navMesh.getTileRefAt(tx, ty, layerOf(bytes)))) tileCache.buildNavMeshTilesAt(tx, ty, this.navMesh)\n\t\t} finally {\n\t\t\ttileCache.destroy()\n\t\t\tfor (const each of copies) each.destroy()\n\t\t}\n\t}\n\n\t/** An obstacle put in the columns it is about (`byColumn`), or taken out of them */\n\tprivate indexObstacle(key: number, obstacle: Obstacle, add: boolean): void {\n\t\tconst byColumn = this.byColumn\n\t\tif (!byColumn || obstacle.type !== 'box') return\n\t\tconst { position, halfExtents } = obstacle\n\t\tfor (const column of this.columnsOf(position.x, position.z, halfExtents.x, halfExtents.z)) {\n\t\t\tlet keys = byColumn.get(column)\n\t\t\tif (add) {\n\t\t\t\tif (!keys) byColumn.set(column, (keys = new Set()))\n\t\t\t\tkeys.add(key)\n\t\t\t} else {\n\t\t\t\tkeys?.delete(key)\n\t\t\t\tif (keys?.size === 0) byColumn.delete(column)\n\t\t\t}\n\t\t}\n\t}\n\n\t/** The tiles made alone let go of: the whole's tile cache is the navmesh's again */\n\tprivate dropOverridden(): void {\n\t\tthis.overridden = undefined\n\t\tthis.byColumn = undefined\n\t\tthis.requested.clear()\n\t}\n\n\t/**\n\t * A step of the whole's tile cache's work on what was put down or taken up. Once it is done, the columns made alone\n\t * that it made again from its own layers, or that an obstacle came to or went from (`requested`), are made again from\n\t * theirs. Whether the whole's is done\n\t */\n\tprivate updateTiles(): boolean {\n\t\tconst upToDate = this.tileCache.update(this.navMesh).upToDate\n\t\tconst overridden = this.overridden\n\t\tif (!overridden) return upToDate\n\t\tif (upToDate && this.requested.size) {\n\t\t\tconst columns = [...this.requested].filter((key) => overridden.has(key)).sort((a, b) => a - b)\n\t\t\tthis.requested.clear()\n\t\t\tfor (const key of columns) this.buildTilesAt(key)\n\t\t}\n\t\treturn upToDate\n\t}\n\n\t/** The limits it was made with, from the map's size or the options: obstacles, and the steps of a path search */\n\tget limits(): { maxObstacles: number; maxNodes: number } {\n\t\treturn { maxObstacles: this.maxObstacles, maxNodes: this.maxNodes }\n\t}\n\n\t/** How many agents the crowd has room for before it has to make more */\n\tget capacity(): number {\n\t\treturn this.maxAgents\n\t}\n\n\t/**\n\t * Makes room for twice as many agents. A crowd (Detour's) is made for a number of agents and cannot grow, so a new\n\t * one is made and every agent moved over as it is: where it is, how fast it goes, where to\n\t */\n\tprivate grow(): void {\n\t\t// those that phase walk on a crowd of their own, which stays as it is: kept in their place among the others\n\t\tconst entries = [...this.agents]\n\t\tconst saves = entries.map(([id, entry]) => [id, entry.phasing ? entry : this.saveAgent(id)!] as const)\n\t\tconst old = this.crowd\n\t\tthis.maxAgents *= 2\n\t\tthis.crowd = crowdOf(this.navMesh, this.maxAgents, this.agentRadius, this.avoidance, !!this.ground)\n\t\tthis.agents.clear()\n\t\tfor (const [id, kept] of saves) {\n\t\t\tif ('agent' in kept) this.agents.set(id, kept)\n\t\t\telse this.restoreAgent(id, kept)\n\t\t}\n\t\tthis.remakeMirrors()\n\t\told.destroy()\n\t}\n\n\t/** Makes room for twice as many agents that phase, as `grow` does for the others: their crowd made anew */\n\tprivate growPhasers(): void {\n\t\tconst saves = [...this.agents].map(([id, entry]) => [id, entry.phasing ? this.saveAgent(id)! : entry] as const)\n\t\tconst old = this.phasers!\n\t\tthis.phasersRoom *= 2\n\t\tthis.phasers = crowdOf(this.navMesh, this.phasersRoom, this.agentRadius, this.avoidance, !!this.ground)\n\t\tthis.agents.clear()\n\t\tfor (const [id, kept] of saves) {\n\t\t\tif ('agent' in kept) this.agents.set(id, kept)\n\t\t\telse this.restoreAgent(id, kept)\n\t\t}\n\t\told.destroy()\n\t}\n\n\t/** The crowd an agent walks on: the one of those that phase, or everyone's */\n\tprivate crowdFor(entry: AgentEntry): Crowd {\n\t\treturn entry.phasing ? this.phasers! : this.crowd\n\t}\n\n\tprivate toVec3(p: Vec2, into = this.scratch) {\n\t\tinto.x = p.x\n\t\tinto.y = this.heightAt(p.x, p.z)\n\t\tinto.z = p.z\n\t\treturn into\n\t}\n\n\taddAgent(id: number, position: Vec2, params: AgentParams): void {\n\t\tif (this.asked) this.settleGround()\n\t\tthis.place(id, position, params, false)\n\t}\n\n\t/** An agent put on the crowd, or on the crowd of those that phase (`setPhasing`) */\n\tprivate place(id: number, position: Vec2, params: AgentParams, phasing: boolean): void {\n\t\tif (this.agents.has(id)) this.removeAgent(id)\n\t\tconst start = this.closestPoint(position, 8) ?? position\n\t\tconst agentParams = {\n\t\t\tradius: params.radius,\n\t\t\theight: 2,\n\t\t\tmaxSpeed: params.speed,\n\t\t\tmaxAcceleration: params.speed * 10,\n\t\t\tcollisionQueryRange: params.radius * 8,\n\t\t\tpathOptimizationRange: params.radius * 30,\n\t\t\tseparationWeight: this.separation,\n\t\t\tupdateFlags: phasing ? GHOST_FLAGS : RESTING_FLAGS,\n\t\t\tobstacleAvoidanceType: AVOIDANCE_SLOT\n\t\t}\n\t\tif (phasing) agentParams.collisionQueryRange = 0.01\n\t\tconst agent = phasing ? this.seatPhasing(start, agentParams) : this.seat(start, agentParams)\n\t\tthis.agents.set(id, {\n\t\t\tagent,\n\t\t\tradius: params.radius,\n\t\t\tanchored: false,\n\t\t\tanchorX: start.x,\n\t\t\tanchorZ: start.z,\n\t\t\tghost: false,\n\t\t\t...(phasing && { phasing: true }),\n\t\t\ttarget: null,\n\t\t\tflags: phasing ? GHOST_FLAGS : RESTING_FLAGS\n\t\t})\n\t}\n\n\t/** An agent put on the crowd of those that phase: made as the first comes, and made bigger as it fills, as `seat` does */\n\tprivate seatPhasing(at: Vec2, params: Parameters<Crowd['addAgent']>[1]): CrowdAgent {\n\t\tif (!this.phasers) {\n\t\t\tthis.phasersRoom = Math.min(this.firstMaxAgents, 64)\n\t\t\tthis.phasers = crowdOf(this.navMesh, this.phasersRoom, this.agentRadius, this.avoidance, !!this.ground)\n\t\t}\n\t\tconst agent = this.phasers.addAgent(this.toVec3(at), params)\n\t\tif (agent.agentIndex >= 0) return agent\n\t\tthis.growPhasers()\n\t\tconst again = this.phasers.addAgent(this.toVec3(at), params)\n\t\tif (again.agentIndex < 0) throw new Error(`Navigation: the crowd of those that phase has room for ${this.phasersRoom} agents and takes no more`)\n\t\treturn again\n\t}\n\n\t/**\n\t * An agent walks through every other and every other through it (`BuffDef.phasing`), or no longer does: moved over to\n\t * the crowd of those that phase, or back, as it stands (where, how fast, where to)\n\t */\n\tsetPhasing(id: number, phasing: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry || !!entry.phasing === phasing) return\n\t\tconst save = this.saveAgent(id)!\n\t\tthis.restoreAgent(id, { ...save, phasing: phasing || undefined })\n\t}\n\n\t/** An agent put on the crowd. A full crowd says so with an index of -1, and an agent like that never moves: room is made, and it goes in again */\n\tprivate seat(at: Vec2, params: Parameters<Crowd['addAgent']>[1]): CrowdAgent {\n\t\tconst agent = this.crowd.addAgent(this.toVec3(at), params)\n\t\tif (agent.agentIndex >= 0) return agent\n\t\tthis.grow()\n\t\tconst again = this.crowd.addAgent(this.toVec3(at), params)\n\t\tif (again.agentIndex < 0) throw new Error(`Navigation: the crowd has room for ${this.maxAgents} agents and takes no more`)\n\t\treturn again\n\t}\n\n\tremoveAgent(id: number): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return\n\t\tthis.crowdFor(entry).removeAgent(entry.agent)\n\t\tthis.agents.delete(id)\n\t}\n\n\treadMotion(id: number, out: AgentMotion): boolean {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return false\n\t\tconst { raw } = entry.agent\n\t\tout.x = raw.get_npos(0)\n\t\tout.y = raw.get_npos(1)\n\t\tout.z = raw.get_npos(2)\n\t\tout.vx = raw.get_vel(0)\n\t\tout.vz = raw.get_vel(2)\n\t\treturn true\n\t}\n\n\taddMirror(id: number, motion: AgentMotion, radius: number, ghost: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tthis.removeMirror(id)\n\t\tconst mirror = this.mirrorAt({ x: motion.x, z: motion.z }, radius, ghost)\n\t\tthis.mirrors.set(id, mirror)\n\t\tthis.moveMirrorTo(mirror, motion)\n\t}\n\n\t/** Asleep from the first (Detour's `INVALID`, as an anchored agent is): of the crowd's step it is only ever a neighbour */\n\tprivate mirrorAt(at: Vec2, radius: number, ghost: boolean): Mirror {\n\t\tconst agent = this.seat(at, {\n\t\t\tradius,\n\t\t\theight: 2,\n\t\t\tmaxSpeed: 0,\n\t\t\tmaxAcceleration: 0,\n\t\t\tcollisionQueryRange: 0.01,\n\t\t\tpathOptimizationRange: 0.01,\n\t\t\tseparationWeight: 0,\n\t\t\tupdateFlags: 0,\n\t\t\tobstacleAvoidanceType: AVOIDANCE_SLOT\n\t\t})\n\t\tagent.raw.state = INVALID\n\t\treturn {\n\t\t\tagent,\n\t\t\tradius,\n\t\t\tanchored: true,\n\t\t\tanchorX: Number.NaN,\n\t\t\tanchorZ: Number.NaN,\n\t\t\tghost,\n\t\t\ttarget: null,\n\t\t\tflags: 0,\n\t\t\ty: Number.NaN,\n\t\t\tvx: Number.NaN,\n\t\t\tvz: Number.NaN\n\t\t}\n\t}\n\n\tmoveMirror(id: number, motion: AgentMotion): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst mirror = this.mirrors.get(id)\n\t\tif (mirror) this.moveMirrorTo(mirror, motion)\n\t}\n\n\t/** Written only where it changed, each number a call into WebAssembly: one standing still costs nothing */\n\tprivate moveMirrorTo(mirror: Mirror, { x, y, z, vx, vz }: AgentMotion): void {\n\t\tconst { raw } = mirror.agent\n\t\tif (x !== mirror.anchorX || y !== mirror.y || z !== mirror.anchorZ) {\n\t\t\tmirror.anchorX = x\n\t\t\tmirror.y = y\n\t\t\tmirror.anchorZ = z\n\t\t\t// one that phases is kept where it is parked, and put back where it is once it no longer does\n\t\t\tif (!mirror.phasing) {\n\t\t\t\traw.set_npos(0, x)\n\t\t\t\traw.set_npos(1, y)\n\t\t\t\traw.set_npos(2, z)\n\t\t\t}\n\t\t}\n\t\tif (vx !== mirror.vx || vz !== mirror.vz) {\n\t\t\tmirror.vx = vx\n\t\t\tmirror.vz = vz\n\t\t\traw.set_vel(0, vx)\n\t\t\traw.set_vel(2, vz)\n\t\t\traw.set_dvel(0, vx)\n\t\t\traw.set_dvel(2, vz)\n\t\t}\n\t}\n\n\tsetMirrorGhost(id: number, ghost: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst mirror = this.mirrors.get(id)\n\t\tif (mirror) mirror.ghost = ghost\n\t}\n\n\tsetMirrorPhasing(id: number, phasing: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst mirror = this.mirrors.get(id)\n\t\tif (!mirror || !!mirror.phasing === phasing) return\n\t\tif (phasing) mirror.phasing = true\n\t\telse delete mirror.phasing\n\t\tconst { raw } = mirror.agent\n\t\traw.set_npos(0, phasing ? PARKED : mirror.anchorX)\n\t\traw.set_npos(1, mirror.y)\n\t\traw.set_npos(2, phasing ? PARKED : mirror.anchorZ)\n\t}\n\n\tremoveMirror(id: number): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst mirror = this.mirrors.get(id)\n\t\tif (!mirror) return\n\t\tthis.crowd.removeAgent(mirror.agent)\n\t\tthis.mirrors.delete(id)\n\t}\n\n\t/** The mirrors put on a crowd made anew, after its agents and in the order they were, as they stood */\n\tprivate remakeMirrors(): void {\n\t\tconst mirrors = [...this.mirrors]\n\t\tthis.mirrors.clear()\n\t\tfor (const [id, { anchorX: x, y, anchorZ: z, vx, vz, radius, ghost, phasing }] of mirrors) {\n\t\t\tconst mirror = this.mirrorAt({ x, z }, radius, ghost)\n\t\t\tthis.mirrors.set(id, mirror)\n\t\t\tthis.moveMirrorTo(mirror, { x, y, z, vx, vz })\n\t\t\tif (phasing) this.setMirrorPhasing(id, true)\n\t\t}\n\t}\n\n\thasAgent(id: number): boolean {\n\t\treturn this.agents.has(id)\n\t}\n\n\tsetDestination(id: number, target: Vec2): boolean {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return false\n\t\tconst snapped = this.closestPoint(target, 6)\n\t\tif (!snapped) return false\n\t\tthis.wake(entry)\n\t\tif (!entry.target && !entry.ghost && !entry.phasing) this.setFlags(entry, DEFAULT_FLAGS)\n\t\tentry.target = snapped\n\t\treturn entry.agent.requestMoveTarget(this.toVec3(snapped))\n\t}\n\n\tclearDestination(id: number): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return\n\t\tif (entry.target && !entry.ghost && !entry.phasing) this.setFlags(entry, RESTING_FLAGS)\n\t\tentry.target = null\n\t\tentry.agent.resetMoveTarget()\n\t}\n\n\tteleport(id: number, position: Vec2): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return\n\t\tconst snapped = this.closestPoint(position, 8) ?? position\n\t\tentry.agent.teleport(this.toVec3(snapped))\n\t\tentry.anchorX = snapped.x\n\t\tentry.anchorZ = snapped.z\n\t\t// a teleport wakes the agent in Detour's eyes: an anchored one goes on sleeping where it was put\n\t\tif (entry.anchored) entry.agent.raw.state = INVALID\n\t}\n\n\tsetAnchored(id: number, anchored: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry || entry.anchored === anchored) return\n\t\tif (!anchored) {\n\t\t\tthis.wake(entry)\n\t\t\treturn\n\t\t}\n\t\tconst { agent } = entry\n\t\tconst { raw } = agent\n\t\tentry.anchored = true\n\t\tentry.anchorX = raw.get_npos(0)\n\t\tentry.anchorZ = raw.get_npos(2)\n\t\tif (entry.target && !entry.ghost && !entry.phasing) this.setFlags(entry, RESTING_FLAGS)\n\t\tentry.target = null\n\t\tagent.resetMoveTarget()\n\t\t// it stops dead: the velocity others steer around, and the one read back, are both nothing\n\t\tfor (let i = 0; i < 3; i++) raw.set_vel(i, 0)\n\t\traw.state = INVALID\n\t}\n\n\t/** Lets an anchored agent go: walking again, from where it stood. Detour checks the ground under it on its next step */\n\tprivate wake(entry: AgentEntry): void {\n\t\tif (!entry.anchored) return\n\t\tentry.anchored = false\n\t\tentry.agent.raw.state = WALKING\n\t}\n\n\tsetGhost(id: number, ghost: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry || entry.ghost === ghost) return\n\t\tentry.ghost = ghost\n\t\t// one that phases has nobody near it either way\n\t\tif (entry.phasing) return\n\t\tentry.flags = ghost ? GHOST_FLAGS : entry.target ? DEFAULT_FLAGS : RESTING_FLAGS\n\t\tentry.agent.updateParameters({\n\t\t\tupdateFlags: entry.flags,\n\t\t\t// with no neighbours in range, a ghost is neither steered nor pushed by anyone\n\t\t\tcollisionQueryRange: ghost ? 0.01 : entry.radius * 8\n\t\t})\n\t}\n\n\tsetSpeed(id: number, speed: number): void {\n\t\tif (this.asked) this.settleGround()\n\t\t// what is held in place has to be able to brake: with nothing to change its pace by, it would glide on as it was\n\t\tthis.agents.get(id)?.agent.updateParameters({ maxSpeed: speed, maxAcceleration: Math.max(speed * 10, BRAKING) })\n\t}\n\n\tsaveAgent(id: number): AgentSave | undefined {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return undefined\n\t\tconst { agent, radius, target, anchored, ghost } = entry\n\t\tconst p = agent.position()\n\t\tconst v = agent.velocity()\n\t\treturn {\n\t\t\tx: p.x,\n\t\t\tz: p.z,\n\t\t\tvx: v.x,\n\t\t\tvz: v.z,\n\t\t\tradius,\n\t\t\tspeed: agent.maxSpeed,\n\t\t\tacceleration: agent.maxAcceleration,\n\t\t\ttarget: target && { x: target.x, z: target.z },\n\t\t\tanchored,\n\t\t\tanchor: anchored ? { x: entry.anchorX, z: entry.anchorZ } : undefined,\n\t\t\tghost,\n\t\t\t...(entry.phasing && { phasing: true })\n\t\t}\n\t}\n\n\treseat(agents: readonly (readonly [id: number, save: AgentSave])[]): void {\n\t\tif (this.asked) this.settleGround()\n\t\t// a crowd as a world just loaded has: the room it starts with, nobody in it, then each agent as the save has it\n\t\tconst old = this.crowd\n\t\tthis.maxAgents = this.firstMaxAgents\n\t\tthis.crowd = crowdOf(this.navMesh, this.maxAgents, this.agentRadius, this.avoidance, !!this.ground)\n\t\tthis.agents.clear()\n\t\t// (the mirrors come back from their own navigations' seats: `SizedNavigation.reseat`)\n\t\tthis.mirrors.clear()\n\t\told.destroy()\n\t\t// and those that phase on a crowd of theirs made anew as the first comes back, as a loaded world's is\n\t\tthis.phasers?.destroy()\n\t\tthis.phasers = undefined\n\t\tfor (const [id, save] of agents) this.restoreAgent(id, save)\n\t}\n\n\trestoreAgent(id: number, save: AgentSave): void {\n\t\tif (this.asked) this.settleGround()\n\t\t// made the way any agent is, then given back what it had: on the crowd of those that phase, where it does\n\t\tthis.place(id, { x: save.x, z: save.z }, { radius: save.radius, speed: save.speed }, !!save.phasing)\n\t\tconst entry = this.agents.get(id)!\n\t\tconst { agent } = entry\n\t\t// it is added on the nearest walkable spot: put it where it was, to the last bit. An anchored one goes where it\n\t\t// holds its ground: that is where it stood, but for a hair in a save from before anchored agents slept\n\t\tconst at = save.anchored ? (save.anchor ?? save) : save\n\t\tagent.teleport({ x: at.x, y: this.heightAt(at.x, at.z), z: at.z })\n\t\tentry.anchorX = at.x\n\t\tentry.anchorZ = at.z\n\t\tif (save.acceleration !== undefined) agent.updateParameters({ maxAcceleration: save.acceleration })\n\t\tthis.setGhost(id, save.ghost)\n\t\tif (save.target) this.setDestination(id, save.target)\n\t\tif (save.anchored) {\n\t\t\tthis.setAnchored(id, true)\n\t\t\treturn\n\t\t}\n\t\t// the crowd keeps velocity as three numbers: x, y and z\n\t\tagent.raw.set_vel(0, save.vx)\n\t\tagent.raw.set_vel(2, save.vz)\n\t}\n\n\tsettle(version: number): void {\n\t\tthis.drain()\n\t\tfor (let i = 0; this.obstaclesDirty; i++) {\n\t\t\tif (i > 100000) throw new Error('Navigation: the obstacles never settled')\n\t\t\tthis.obstaclesDirty = !this.updateTiles()\n\t\t}\n\t\tthis.changes = version\n\t\t// an agent that was given somewhere to go heads straight there until its path has been looked for, which the\n\t\t// crowd does a few at a time: look for all of them now, with no time going by, so nothing moves meanwhile\n\t\tfor (let i = 0; i < 1000 && [...this.agents.values()].some(({ agent }) => PLANNING.has(agent.raw.targetState)); i++) {\n\t\t\tthis.crowd.update(0)\n\t\t\tthis.phasers?.update(0)\n\t\t}\n\t}\n\n\treadAgent(id: number, out: AgentState): boolean {\n\t\tif (this.asked) this.settleGround()\n\t\tconst entry = this.agents.get(id)\n\t\tif (!entry) return false\n\t\t// an anchored agent is asleep where it was anchored, and is answered from here: nothing of it is read from the crowd\n\t\tif (entry.anchored) {\n\t\t\tout.x = entry.anchorX\n\t\t\tout.z = entry.anchorZ\n\t\t\tout.vx = 0\n\t\t\tout.vz = 0\n\t\t\tout.cx = out.nx = entry.anchorX\n\t\t\tout.cz = out.nz = entry.anchorZ\n\t\t\treturn true\n\t\t}\n\t\t// each read is a call into WebAssembly: only what is used, on the ground (x and z, never the height)\n\t\tconst raw = entry.agent.raw\n\t\tout.x = raw.get_npos(0)\n\t\tout.z = raw.get_npos(2)\n\t\tout.vx = raw.get_vel(0)\n\t\tout.vz = raw.get_vel(2)\n\t\t// the corridor has no corners once the agent is nearly there\n\t\tconst corners = raw.ncorners\n\t\tif (corners > 0) {\n\t\t\tout.cx = raw.get_cornerVerts(0)\n\t\t\tout.cz = raw.get_cornerVerts(2)\n\t\t} else {\n\t\t\tout.cx = raw.get_targetPos(0)\n\t\t\tout.cz = raw.get_targetPos(2)\n\t\t}\n\t\tif (corners > 1) {\n\t\t\tout.nx = raw.get_cornerVerts(3)\n\t\t\tout.nz = raw.get_cornerVerts(5)\n\t\t} else {\n\t\t\tout.nx = out.cx\n\t\t\tout.nz = out.cz\n\t\t}\n\t\treturn true\n\t}\n\n\tupdate(dt: number): void {\n\t\tthis.drain()\n\t\tif (this.obstaclesDirty) {\n\t\t\tfor (let i = 0; i < 32; i++) {\n\t\t\t\tif (this.updateTiles()) {\n\t\t\t\t\tthis.obstaclesDirty = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.changes++\n\t\t}\n\n\t\tif (this.walls === 'soft') this.steer()\n\t\t// anchored agents are asleep (INVALID), so Detour, which resolves overlaps symmetrically, does not move them: an\n\t\t// agent that walks into one is pushed off by half the overlap each pass, as ever, and the one that stands its\n\t\t// ground is not moved at all\n\t\tthis.crowd.update(dt)\n\t\t// those that phase, after: on their own, where nobody is in their way and they in nobody's\n\t\tthis.phasers?.update(dt)\n\t}\n\n\t/** The flags an agent steers by, set on the crowd only where they change: one call into WebAssembly */\n\tprivate setFlags(entry: AgentEntry, flags: number): void {\n\t\tif (entry.flags === flags) return\n\t\tentry.flags = flags\n\t\tentry.agent.raw.params.updateFlags = flags\n\t}\n\n\t/**\n\t * `walls: 'soft'`: an agent walking somewhere steers among velocities (obstacle avoidance) only while another agent\n\t * (walking or standing, anchored too, not a ghost) is within its reach, its collision query range (eight of its\n\t * radii); otherwise it follows its path, pushed apart from those near it (separation) but never slowed by a wall it\n\t * touches. Read from where every agent is as the tick starts, in a grid of cells as large as the longest reach, so\n\t * that a game loaded from a save steers as the game it was saved from (Detour's own lists of neighbours are of the\n\t * tick before, and a crowd made anew has none)\n\t */\n\tprivate steer(): void {\n\t\t// written over and cut to length, not emptied and pushed onto: emptied, an array gives up its room\n\t\tconst near = this.near\n\t\tlet count = 0\n\t\tlet walking = 0\n\t\tlet cell = 0\n\t\tfor (const entry of this.agents.values()) {\n\t\t\tif (entry.ghost || entry.phasing) continue\n\t\t\tnear[count++] = entry\n\t\t\tif (entry.target && !entry.anchored) {\n\t\t\t\twalking++\n\t\t\t\tcell = Math.max(cell, entry.radius * 8)\n\t\t\t}\n\t\t}\n\t\t// and those of the other sizes, read as anchored ones are: from where they are kept\n\t\tif (walking > 0) for (const mirror of this.mirrors.values()) if (!mirror.ghost) near[count++] = mirror\n\t\tnear.length = count\n\t\tif (walking === 0) return\n\t\tif (this.nearX.length < count) {\n\t\t\tthis.nearX = new Float64Array(count * 2)\n\t\t\tthis.nearZ = new Float64Array(count * 2)\n\t\t\tthis.nearNext = new Int32Array(count * 2)\n\t\t}\n\t\tconst xs = this.nearX\n\t\tconst zs = this.nearZ\n\t\tconst next = this.nearNext\n\t\tconst heads = this.nearHeads\n\t\theads.clear()\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst entry = near[i]\n\t\t\tif (entry.anchored) {\n\t\t\t\txs[i] = entry.anchorX\n\t\t\t\tzs[i] = entry.anchorZ\n\t\t\t} else {\n\t\t\t\txs[i] = entry.agent.raw.get_npos(0)\n\t\t\t\tzs[i] = entry.agent.raw.get_npos(2)\n\t\t\t}\n\t\t\tconst key = Math.floor(xs[i] / cell) * 65536 + Math.floor(zs[i] / cell)\n\t\t\tnext[i] = heads.get(key) ?? -1\n\t\t\theads.set(key, i)\n\t\t}\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst entry = near[i]\n\t\t\tif (!entry.target || entry.anchored) continue\n\t\t\tconst reach = entry.radius * 8\n\t\t\tconst cx = Math.floor(xs[i] / cell)\n\t\t\tconst cz = Math.floor(zs[i] / cell)\n\t\t\tlet steers = false\n\t\t\tfor (let dx = -1; dx <= 1 && !steers; dx++) {\n\t\t\t\tfor (let dz = -1; dz <= 1 && !steers; dz++) {\n\t\t\t\t\tfor (let j = heads.get((cx + dx) * 65536 + cz + dz) ?? -1; j >= 0; j = next[j]) {\n\t\t\t\t\t\tif (j === i) continue\n\t\t\t\t\t\tconst ox = xs[j] - xs[i]\n\t\t\t\t\t\tconst oz = zs[j] - zs[i]\n\t\t\t\t\t\tif (ox * ox + oz * oz < reach * reach) {\n\t\t\t\t\t\t\tsteers = true\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setFlags(entry, steers ? DEFAULT_FLAGS : RESTING_FLAGS)\n\t\t}\n\t}\n\n\taddObstacle(key: number, rect: Rect): boolean {\n\t\tif (this.asked) this.settleGround()\n\t\tthis.removeObstacle(key)\n\t\tif (this.obstacles.size >= this.maxObstacles) return false\n\t\tconst y = this.terrain.heightAt(rect.x, rect.z)\n\t\t// obstacles carve their exact shape, so grow them by the agent radius like the rest of the navmesh\n\t\tconst half = { x: rect.hw + this.agentRadius, y: 4, z: rect.hd + this.agentRadius }\n\t\tthis.makeRoom(rect.x, rect.z, half.x, half.z)\n\t\tconst result = this.tileCache.addBoxObstacle({ x: rect.x, y, z: rect.z }, half, 0)\n\t\t// out of room, or of requests queued: not in the way, and said by the false, never thrown in the middle of a tick\n\t\tif (!result.success) return false\n\t\tthis.obstacles.set(key, result.obstacle)\n\t\t// the columns made alone it is about are made again from their layers, with it, once the whole's is done\n\t\tif (this.overridden) {\n\t\t\tthis.indexObstacle(key, result.obstacle, true)\n\t\t\tfor (const column of this.columnsOf(rect.x, rect.z, half.x, half.z)) this.requested.add(column)\n\t\t}\n\t\tthis.flushObstacles()\n\t\treturn true\n\t}\n\n\t/**\n\t * Holds obstacles back (true) or lets them go (false): while held, a request to put one down or take one up waits in\n\t * the tile cache, and they are made into tiles together when let go or at the first thing asked of the navigation\n\t * before that, each tile once however many obstacles are on it. The same tiles come of it as of making them one by\n\t * one: a wooded tile is made once, not once a tree (RV42). The version goes up for each obstacle all the same\n\t */\n\tholdObstacles(hold: boolean): void {\n\t\tif (this.asked) this.settleGround()\n\t\tif (this.holding === hold) return\n\t\tthis.holding = hold\n\t\tif (!hold) return this.drain()\n\t\t// a batch starts from a tile cache with nothing queued: what was asked before is made first, and the next update\n\t\t// still says the ground changed, as it would have\n\t\tif (this.obstaclesDirty) {\n\t\t\tthis.held = 1\n\t\t\tthis.drain()\n\t\t\tthis.obstaclesDirty = true\n\t\t}\n\t}\n\n\t/**\n\t * Makes room for one more held request, of an obstacle at (x, z) of these half sizes: the ones held are made into\n\t * tiles first when the tile cache would take no more of them (Detour queues 64), or when their tiles together would\n\t * be more than it makes again from one batch (64, past which it leaves the rest as they were)\n\t */\n\tprivate makeRoom(x: number, z: number, hw: number, hd: number): void {\n\t\tif (!this.holding) return\n\t\tconst columns = this.columnsOf(x, z, hw, hd)\n\t\tlet more = 0\n\t\tfor (const column of columns) if (!this.heldColumns.has(column)) more++\n\t\tif (this.held + 1 > MAX_REQUESTS || this.heldColumns.size + more > MAX_HELD_COLUMNS) this.drain()\n\t\tfor (const column of columns) this.heldColumns.add(column)\n\t}\n\n\t/**\n\t * The columns of the tile grid an obstacle touches, or more: Detour takes a box obstacle's bounds as a square 1.41 times\n\t * its longer half side about its middle, here 1.5 times, so that rounding never leaves one out. More, then, and not\n\t * Detour's own test (which also weighs each layer's walkable cells and heights): what is done with a column here holds\n\t * for one the obstacle does not touch (`buildColumn` makes every layer of it however that falls out)\n\t */\n\tprivate columnsOf(x: number, z: number, hw: number, hd: number): number[] {\n\t\tconst { size, originX, originZ } = this.tiles\n\t\tconst reach = 1.5 * Math.max(hw, hd)\n\t\tconst x0 = Math.floor((x - reach - originX) / size)\n\t\tconst x1 = Math.floor((x + reach - originX) / size)\n\t\tconst z0 = Math.floor((z - reach - originZ) / size)\n\t\tconst z1 = Math.floor((z + reach - originZ) / size)\n\t\tconst columns: number[] = []\n\t\tfor (let tx = x0; tx <= x1; tx++) for (let tz = z0; tz <= z1; tz++) columns.push(tx * 65536 + tz)\n\t\treturn columns\n\t}\n\n\t/** Every held request made into tiles: the tile cache up to date */\n\tprivate drain(): void {\n\t\t// what the ground's changes asked first, as it would have been done before anything after them\n\t\tif (this.asked) this.settleGround()\n\t\tif (!this.held) return\n\t\tthis.held = 0\n\t\tthis.heldColumns.clear()\n\t\tfor (let i = 0; !this.updateTiles(); i++) {\n\t\t\tif (i > 100000) throw new Error('Navigation: the obstacles never settled')\n\t\t}\n\t\tthis.obstaclesDirty = false\n\t}\n\n\tobstacleRoom(): number {\n\t\treturn this.maxObstacles - this.obstacles.size\n\t}\n\n\tremoveObstacle(key: number): void {\n\t\tif (this.asked) this.settleGround()\n\t\tconst obstacle = this.obstacles.get(key)\n\t\tif (!obstacle) return\n\t\tif (this.holding && obstacle.type === 'box') {\n\t\t\tconst { position, halfExtents } = obstacle\n\t\t\tthis.makeRoom(position.x, position.z, halfExtents.x, halfExtents.z)\n\t\t}\n\t\tthis.tileCache.removeObstacle(obstacle)\n\t\tthis.obstacles.delete(key)\n\t\t// the columns made alone it was about are made again from their layers, without it, once the whole's is done\n\t\tif (this.overridden && obstacle.type === 'box') {\n\t\t\tthis.indexObstacle(key, obstacle, false)\n\t\t\tconst { position, halfExtents } = obstacle\n\t\t\tfor (const column of this.columnsOf(position.x, position.z, halfExtents.x, halfExtents.z)) this.requested.add(column)\n\t\t}\n\t\tthis.flushObstacles()\n\t}\n\n\t/**\n\t * The tile cache only queues a limited number of requests, so process them as they come: but while they are held\n\t * (`holdObstacles`), when they wait to be made into tiles together\n\t */\n\tprivate flushObstacles(): void {\n\t\tif (this.holding) this.held++\n\t\telse this.obstaclesDirty = !this.updateTiles()\n\t\tthis.changes++\n\t}\n\n\tclosestPoint(point: Vec2, searchRadius = 4): Vec2 | null {\n\t\tthis.drain()\n\t\tconst query = this.closestQuery\n\t\tquery.halfExtents.x = searchRadius\n\t\tquery.halfExtents.z = searchRadius\n\t\tconst result = this.query.findClosestPoint(this.toVec3(point), query)\n\t\tif (!result.success || result.polyRef === 0) return null\n\t\treturn { x: result.point.x, z: result.point.z }\n\t}\n\n\tfindPath(from: Vec2, to: Vec2): Vec2[] | null {\n\t\tthis.drain()\n\t\tconst result = this.query.computePath(this.toVec3(from), this.toVec3(to, this.scratchEnd))\n\t\tif (!result.success || result.path.length === 0) return null\n\t\treturn result.path.map((p) => ({ x: p.x, z: p.z }))\n\t}\n\n\tdebugGeometry(): NavDebugGeometry {\n\t\tthis.drain()\n\t\tconst drawer = new DebugDrawerUtils()\n\t\tconst primitives = drawer.drawNavMesh(this.navMesh)\n\t\tconst triangles: number[] = []\n\t\tconst lines: number[] = []\n\t\tfor (const primitive of primitives) {\n\t\t\tconst target = primitive.type === 'tris' ? triangles : primitive.type === 'lines' ? lines : null\n\t\t\tif (!target) continue\n\t\t\tfor (const v of primitive.vertices) target.push(v[0], v[1], v[2])\n\t\t}\n\t\tdrawer.dispose()\n\t\treturn { triangles: new Float32Array(triangles), lines: new Float32Array(lines) }\n\t}\n\n\tdispose(): void {\n\t\tthis.asked = undefined\n\t\tthis.dropOverridden()\n\t\tthis.crowd.destroy()\n\t\tthis.phasers?.destroy()\n\t\tthis.query.destroy()\n\t\tthis.tileCache.destroy()\n\t\tthis.navMesh.destroy()\n\t\t// what the tile cache made its tiles with: the module keeps every one of its objects until it is destroyed, and\n\t\t// the process with its slow ground (`speedAt`), the world's registry and through it the world that ended\n\t\tfor (const each of this.owned) {\n\t\t\tconst raw = each instanceof TileCacheMeshProcess ? each.raw : each\n\t\t\tif (raw) Raw.destroy(raw)\n\t\t}\n\t\tthis.owned = []\n\t\tthis.agents.clear()\n\t\tthis.mirrors.clear()\n\t\tthis.obstacles.clear()\n\t}\n}\n"],"mappings":";;;;;;;;;;;AA+IA,IAAa,oBAA+C,OAAO,OAAO;CACzE,SAAS;CACT,cAAc;CACd,cAAc;CACd,YAAY;CACZ,WAAW;CACX,WAAW;CACX,UAAU;CACV,cAAc;CACd,eAAe;CACf,eAAe;AAChB,CAAC;;;;;;;;AASD,IAAa,aAAiD,OAAO,OAAO;CAAE,WAAW;CAAK,WAAW;CAAK,cAAc;AAAE,CAAC;;;;;;;AAe/H,IAAa,mBAAyF,OAAO,OAAO;CACnH,KAAK,OAAO,OAAO;EAAE,cAAc;EAAG,eAAe;EAAG,eAAe;CAAE,CAAC;CAC1E,QAAQ,OAAO,OAAO,CAAC,CAAC;CACxB,MAAM,OAAO,OAAO;EAAE,cAAc;EAAG,eAAe;EAAG,eAAe;CAAE,CAAC;AAC5E,CAAC;AAQD,IAAM,gBAAgB;AACtB,IAAM,cAAc;;;;;AAKpB,IAAM,gBAAgB;;AAEtB,IAAM,2BAAW,IAAI,IAAI;CAAC;CAAG;CAAG;AAAC,CAAC;;AAElC,IAAM,UAAU;;;;;;AAMhB,IAAM,UAAU;AAChB,IAAM,UAAU;;;;;AAwBhB,IAAM,SAAS;;AAUf,SAAS,SAAS,SAAkB,SAAyE;CAC5G,MAAM,EAAE,OAAO,UAAU;CACzB,MAAM,SAAS,IAAI,aAAa,QAAQ,KAAK;CAC7C,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAA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,IAAI,KAAK,IAAI,QAAQ,GAAG;EACzB;EACA,KAAK,QAAQ,CAAC;EACd,KAAK,OAAO,MAAM;EAClB,KAAK,QAAQ,MAAM;EACnB,KAAK,UAAU,MAAM;CACtB;AACD"}
|
|
@@ -4,6 +4,7 @@ import type { System } from '#engine/registry';
|
|
|
4
4
|
import type { Terrain } from '#engine/terrain';
|
|
5
5
|
import type { World } from '#engine/world';
|
|
6
6
|
import { type RecastNavigationOptions } from './recast';
|
|
7
|
+
import type { CellArea } from './navigation';
|
|
7
8
|
/**
|
|
8
9
|
* A building a side learned of by sight, where it saw it: its id and its rectangle
|
|
9
10
|
*
|
|
@@ -36,6 +37,7 @@ export declare class SidePaths {
|
|
|
36
37
|
has(team: number): boolean;
|
|
37
38
|
/** One more each time what a team knows changes */
|
|
38
39
|
version(team: number): number;
|
|
40
|
+
/** Whether the team knows the building by its id */
|
|
39
41
|
knows(team: number, id: number): boolean;
|
|
40
42
|
/** The buildings a team knows, by id */
|
|
41
43
|
known(team: number): ReadonlyMap<number, Rect>;
|
|
@@ -56,13 +58,16 @@ export declare class SidePaths {
|
|
|
56
58
|
/** The buildings a team learned of by sight */
|
|
57
59
|
seen(team: number): ReadonlyMap<number, Rect>;
|
|
58
60
|
/** A slowing layer of cells changed on these cells: each side's navigation weighs them again, as the world's does (EN2) */
|
|
59
|
-
groundChanged(cells: readonly number[]): void;
|
|
61
|
+
groundChanged(cells: readonly number[], walkability?: boolean): void;
|
|
60
62
|
/** The ground was reshaped: each side's navigation cut again of it, as the world's is */
|
|
61
|
-
reshape(): void;
|
|
63
|
+
reshape(area?: CellArea): void;
|
|
64
|
+
/** What the ground's changes asked of each side's navigation done now, as the world's is as each tick ends */
|
|
65
|
+
settleGround(): void;
|
|
66
|
+
/** Frees what the object holds, such as its subscriptions and each side's navigation */
|
|
62
67
|
dispose(): void;
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
|
-
* What each side learns by sight, after the fog is lit (`
|
|
70
|
+
* What each side learns by sight, after the fog is lit (`Rules.paths: 'seen'`): another side's buildings once a
|
|
66
71
|
* cell of one is in sight, and that one gone once its place is. What it knows without seeing is the world's to tell
|
|
67
72
|
* as it happens (`SidePaths.attach`). Kept in the world (`sideKnowledge`) as it changes
|
|
68
73
|
*/
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { defineComponent } from "../components.js";
|
|
2
|
+
import { entityDied, entityRemoved, entitySpawned } from "../engineEvents.js";
|
|
3
|
+
import { allOrFreed } from "./builds.js";
|
|
4
|
+
import { RecastNavigation } from "./recast.js";
|
|
5
|
+
//#region src/navigation/sidePaths.ts
|
|
6
|
+
/**
|
|
7
|
+
* Paths that know only what a side has seen (determinism plan F2, `Rules.paths: 'seen'`). The world's navigation
|
|
8
|
+
* has every building in it, as it must: nobody walks through a wall. But a route planned on it goes around buildings
|
|
9
|
+
* nobody on the side has seen, and the way a unit goes in the dark says they are there. So each side has a navigation
|
|
10
|
+
* of its own, of the ground and the buildings it knows, to plan its routes on; its units walk them a stretch at a time
|
|
11
|
+
* on the world's (`systems/movement.ts`), a stretch no longer than they can see.
|
|
12
|
+
*
|
|
13
|
+
* What a side knows: what is the map's (the neutral's and the creeps', trees and mines among them), its own and its
|
|
14
|
+
* allies', as they are put down and gone; another side's once a cell of it was in sight, and that one gone once its
|
|
15
|
+
* place is in sight again. The first is the world's to say again at any time; the second is the simulation's, kept in
|
|
16
|
+
* the world (`sideKnowledge`), so a save has it and a load makes the navigations again from both
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* What each side learned of other sides' buildings by sight, by team: the simulation's (so a save keeps it), not a
|
|
20
|
+
* screen's (`teamMemory` is the screens')
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
var sideKnowledge = defineComponent({
|
|
25
|
+
id: "core.sideKnowledge",
|
|
26
|
+
default: () => ({})
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* The navigations of the sides, to plan routes on
|
|
30
|
+
*
|
|
31
|
+
* @beta
|
|
32
|
+
*/
|
|
33
|
+
var SidePaths = class SidePaths {
|
|
34
|
+
sides;
|
|
35
|
+
stop;
|
|
36
|
+
constructor(sides) {
|
|
37
|
+
this.sides = sides;
|
|
38
|
+
}
|
|
39
|
+
/** A navigation for each team, of the terrain alone, cut for `options` (the world's smallest unit) */
|
|
40
|
+
static async create(terrain, teams, options = {}) {
|
|
41
|
+
const sides = /* @__PURE__ */ new Map();
|
|
42
|
+
const navigations = await allOrFreed(teams.map(() => () => RecastNavigation.create(terrain, options)));
|
|
43
|
+
teams.forEach((team, i) => {
|
|
44
|
+
const navigation = navigations[i];
|
|
45
|
+
navigation.holdObstacles(true);
|
|
46
|
+
sides.set(team, {
|
|
47
|
+
navigation,
|
|
48
|
+
known: /* @__PURE__ */ new Map(),
|
|
49
|
+
seen: /* @__PURE__ */ new Map(),
|
|
50
|
+
version: 0,
|
|
51
|
+
dirty: false
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return new SidePaths(sides);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Listens to the world for what every side knows as it happens: the map's, and each side's own and its allies'
|
|
58
|
+
* buildings, put down and gone. Given what the world has now, in its order, first: what a load starts from
|
|
59
|
+
*/
|
|
60
|
+
attach(world) {
|
|
61
|
+
this.stop?.();
|
|
62
|
+
for (const entity of world.entities.values()) this.put(world, entity);
|
|
63
|
+
const offs = [
|
|
64
|
+
world.events.on(entitySpawned, (entity) => this.put(world, entity)),
|
|
65
|
+
world.events.on(entityDied, ({ entity }) => this.gone(entity)),
|
|
66
|
+
world.events.on(entityRemoved, (entity) => this.gone(entity))
|
|
67
|
+
];
|
|
68
|
+
this.stop = () => offs.forEach((off) => off());
|
|
69
|
+
}
|
|
70
|
+
/** Whether a team knows a building of `owner`'s without seeing it: the map's, its own, its allies' */
|
|
71
|
+
always(world, team, owner) {
|
|
72
|
+
const player = world.players.get(owner);
|
|
73
|
+
if (!player) return false;
|
|
74
|
+
if (player.neutral || player.creeps || player.team === team) return true;
|
|
75
|
+
for (const other of world.players.values()) if (other.team === team) return world.areAllies(other.id, owner);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
/** A building put down: what every side knows of it at once */
|
|
79
|
+
put(world, entity) {
|
|
80
|
+
if (!entity.isStructure || !entity.alive || !entity.cell) return;
|
|
81
|
+
for (const team of this.sides.keys()) if (this.always(world, team, entity.owner)) this.learn(team, entity.id, entity.rect);
|
|
82
|
+
}
|
|
83
|
+
/** A building gone: forgotten at once where it was known without being seen */
|
|
84
|
+
gone(entity) {
|
|
85
|
+
if (!entity.isStructure) return;
|
|
86
|
+
for (const [team, side] of this.sides) if (side.known.has(entity.id) && !side.seen.has(entity.id)) this.forget(team, entity.id);
|
|
87
|
+
}
|
|
88
|
+
/** Whether a team plans with what it knows */
|
|
89
|
+
has(team) {
|
|
90
|
+
return this.sides.has(team);
|
|
91
|
+
}
|
|
92
|
+
/** One more each time what a team knows changes */
|
|
93
|
+
version(team) {
|
|
94
|
+
return this.sides.get(team)?.version ?? 0;
|
|
95
|
+
}
|
|
96
|
+
/** Whether the team knows the building by its id */
|
|
97
|
+
knows(team, id) {
|
|
98
|
+
return !!this.sides.get(team)?.known.has(id);
|
|
99
|
+
}
|
|
100
|
+
/** The buildings a team knows, by id */
|
|
101
|
+
known(team) {
|
|
102
|
+
return this.sides.get(team)?.known ?? /* @__PURE__ */ new Map();
|
|
103
|
+
}
|
|
104
|
+
/** A team knows a building from now: it is in the way of its routes. `seen` for one it learned of by sight */
|
|
105
|
+
learn(team, id, rect, seen = false) {
|
|
106
|
+
const side = this.sides.get(team);
|
|
107
|
+
if (!side || side.known.has(id)) return;
|
|
108
|
+
const kept = {
|
|
109
|
+
x: rect.x,
|
|
110
|
+
z: rect.z,
|
|
111
|
+
hw: rect.hw,
|
|
112
|
+
hd: rect.hd
|
|
113
|
+
};
|
|
114
|
+
side.known.set(id, kept);
|
|
115
|
+
if (seen) side.seen.set(id, kept);
|
|
116
|
+
side.navigation.addObstacle(id, rect);
|
|
117
|
+
side.version++;
|
|
118
|
+
side.dirty = true;
|
|
119
|
+
}
|
|
120
|
+
/** A team knows a building is gone */
|
|
121
|
+
forget(team, id) {
|
|
122
|
+
const side = this.sides.get(team);
|
|
123
|
+
if (!side?.known.delete(id)) return;
|
|
124
|
+
side.seen.delete(id);
|
|
125
|
+
side.navigation.removeObstacle(id);
|
|
126
|
+
side.version++;
|
|
127
|
+
side.dirty = true;
|
|
128
|
+
}
|
|
129
|
+
/** Brings each navigation up to date with what was learned and forgotten: before a route is planned on it */
|
|
130
|
+
settle() {
|
|
131
|
+
for (const side of this.sides.values()) {
|
|
132
|
+
if (!side.dirty) continue;
|
|
133
|
+
side.navigation.settle(side.navigation.version);
|
|
134
|
+
side.dirty = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** The corners of a route from one point to another, as the team knows the ground. Null where it knows no way */
|
|
138
|
+
route(team, from, to) {
|
|
139
|
+
const side = this.sides.get(team);
|
|
140
|
+
if (!side) return null;
|
|
141
|
+
if (side.dirty) this.settle();
|
|
142
|
+
return side.navigation.findPath(from, to);
|
|
143
|
+
}
|
|
144
|
+
/** What the world keeps of it (`sideKnowledge`): what each side learned by sight */
|
|
145
|
+
save() {
|
|
146
|
+
const saved = {};
|
|
147
|
+
for (const [team, side] of this.sides) saved[team] = [...side.seen].map(([id, rect]) => [
|
|
148
|
+
id,
|
|
149
|
+
rect.x,
|
|
150
|
+
rect.z,
|
|
151
|
+
rect.hw,
|
|
152
|
+
rect.hd
|
|
153
|
+
]);
|
|
154
|
+
return saved;
|
|
155
|
+
}
|
|
156
|
+
/** After a load: what every side knows of the world as it is (`attach`), then what each learned by sight */
|
|
157
|
+
restore(world, saved) {
|
|
158
|
+
this.attach(world);
|
|
159
|
+
for (const [team, buildings] of Object.entries(saved)) for (const [id, x, z, hw, hd] of buildings) this.learn(Number(team), id, {
|
|
160
|
+
x,
|
|
161
|
+
z,
|
|
162
|
+
hw,
|
|
163
|
+
hd
|
|
164
|
+
}, true);
|
|
165
|
+
this.settle();
|
|
166
|
+
}
|
|
167
|
+
/** Every enemy building of `team`'s, in the order they were put there: the ones it can come to know by sight */
|
|
168
|
+
*strangers(world, team) {
|
|
169
|
+
for (const owner of world.players.values()) {
|
|
170
|
+
if (this.always(world, team, owner.id)) continue;
|
|
171
|
+
for (const entity of world.index.ownedBy(owner.id)) if (entity.isStructure && entity.alive && entity.cell) yield entity;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** The buildings a team learned of by sight */
|
|
175
|
+
seen(team) {
|
|
176
|
+
return this.sides.get(team)?.seen ?? /* @__PURE__ */ new Map();
|
|
177
|
+
}
|
|
178
|
+
/** A slowing layer of cells changed on these cells: each side's navigation weighs them again, as the world's does (EN2) */
|
|
179
|
+
groundChanged(cells, walkability) {
|
|
180
|
+
for (const side of this.sides.values()) side.navigation.groundChanged(cells, walkability);
|
|
181
|
+
}
|
|
182
|
+
/** The ground was reshaped: each side's navigation cut again of it, as the world's is */
|
|
183
|
+
reshape(area) {
|
|
184
|
+
for (const side of this.sides.values()) side.navigation.reshape?.(area);
|
|
185
|
+
}
|
|
186
|
+
/** What the ground's changes asked of each side's navigation done now, as the world's is as each tick ends */
|
|
187
|
+
settleGround() {
|
|
188
|
+
for (const side of this.sides.values()) side.navigation.settleGround?.();
|
|
189
|
+
}
|
|
190
|
+
/** Frees what the object holds, such as its subscriptions and each side's navigation */
|
|
191
|
+
dispose() {
|
|
192
|
+
this.stop?.();
|
|
193
|
+
for (const side of this.sides.values()) side.navigation.dispose();
|
|
194
|
+
this.sides.clear();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
/** Whether any cell of a rectangle is in a team's sight */
|
|
198
|
+
function inSight(world, team, rect) {
|
|
199
|
+
const x0 = Math.floor(rect.x - rect.hw);
|
|
200
|
+
const x1 = Math.ceil(rect.x + rect.hw) - 1;
|
|
201
|
+
const z0 = Math.floor(rect.z - rect.hd);
|
|
202
|
+
const z1 = Math.ceil(rect.z + rect.hd) - 1;
|
|
203
|
+
for (let z = z0; z <= z1; z++) for (let x = x0; x <= x1; x++) if (world.fog.isVisible(team, x + .5, z + .5)) return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* What each side learns by sight, after the fog is lit (`Rules.paths: 'seen'`): another side's buildings once a
|
|
208
|
+
* cell of one is in sight, and that one gone once its place is. What it knows without seeing is the world's to tell
|
|
209
|
+
* as it happens (`SidePaths.attach`). Kept in the world (`sideKnowledge`) as it changes
|
|
210
|
+
*/
|
|
211
|
+
var sideKnowledgeSystem = {
|
|
212
|
+
name: "sideKnowledge",
|
|
213
|
+
phase: "cleanup",
|
|
214
|
+
every: 3,
|
|
215
|
+
update(world) {
|
|
216
|
+
const paths = world.sidePaths;
|
|
217
|
+
if (!paths) return;
|
|
218
|
+
let changed = false;
|
|
219
|
+
const teams = [...new Set([...world.players.values()].map((player) => player.team))].filter((team) => paths.has(team));
|
|
220
|
+
for (const team of teams) {
|
|
221
|
+
for (const entity of paths.strangers(world, team)) {
|
|
222
|
+
if (paths.knows(team, entity.id) || !inSight(world, team, entity.rect)) continue;
|
|
223
|
+
paths.learn(team, entity.id, entity.rect, true);
|
|
224
|
+
changed = true;
|
|
225
|
+
}
|
|
226
|
+
for (const [id, rect] of [...paths.seen(team)]) {
|
|
227
|
+
const entity = world.entities.get(id);
|
|
228
|
+
if (entity?.alive && entity.cell || !inSight(world, team, rect)) continue;
|
|
229
|
+
paths.forget(team, id);
|
|
230
|
+
changed = true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!changed) return;
|
|
234
|
+
paths.settle();
|
|
235
|
+
world.setState(sideKnowledge, paths.save());
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
export { SidePaths, sideKnowledge, sideKnowledgeSystem };
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=sidePaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidePaths.js","names":[],"sources":["../../src/navigation/sidePaths.ts"],"sourcesContent":["/**\n * Paths that know only what a side has seen (determinism plan F2, `Rules.paths: 'seen'`). The world's navigation\n * has every building in it, as it must: nobody walks through a wall. But a route planned on it goes around buildings\n * nobody on the side has seen, and the way a unit goes in the dark says they are there. So each side has a navigation\n * of its own, of the ground and the buildings it knows, to plan its routes on; its units walk them a stretch at a time\n * on the world's (`systems/movement.ts`), a stretch no longer than they can see.\n *\n * What a side knows: what is the map's (the neutral's and the creeps', trees and mines among them), its own and its\n * allies', as they are put down and gone; another side's once a cell of it was in sight, and that one gone once its\n * place is in sight again. The first is the world's to say again at any time; the second is the simulation's, kept in\n * the world (`sideKnowledge`), so a save has it and a load makes the navigations again from both\n */\nimport { entityDied, entityRemoved, entitySpawned } from '#engine/engineEvents'\nimport { defineComponent } from '#engine/components'\nimport type { Entity, PlayerId } from '#engine/entity'\nimport type { Rect, Vec2 } from '#engine/math'\nimport type { System } from '#engine/registry'\nimport type { Terrain } from '#engine/terrain'\nimport type { World } from '#engine/world'\nimport { allOrFreed } from './builds'\nimport { RecastNavigation, type RecastNavigationOptions } from './recast'\nimport type { CellArea } from './navigation'\n\n/**\n * A building a side learned of by sight, where it saw it: its id and its rectangle\n *\n * @beta\n */\nexport type KnownBuilding = [id: number, x: number, z: number, hw: number, hd: number]\n\n/**\n * What each side learned of other sides' buildings by sight, by team: the simulation's (so a save keeps it), not a\n * screen's (`teamMemory` is the screens')\n *\n * @internal\n */\nexport const sideKnowledge = defineComponent<Record<number, KnownBuilding[]>>({ id: 'core.sideKnowledge', default: () => ({}) })\n\n/** One side's navigation, and what is in it */\ninterface Side {\n\tnavigation: RecastNavigation\n\t/** Every building in its navigation */\n\tknown: Map<number, Rect>\n\t/** Those of them it learned of by sight: another side's, which it forgets only once it sees they are gone */\n\tseen: Map<number, Rect>\n\t/** One more each time what the side knows changes: routes planned before are planned again */\n\tversion: number\n\t/** Learned or forgotten since its navigation was last brought up to date */\n\tdirty: boolean\n}\n\n/**\n * The navigations of the sides, to plan routes on\n *\n * @beta\n */\nexport class SidePaths {\n\tprivate stop?: () => void\n\n\tprivate constructor(private readonly sides: Map<number, Side>) {}\n\n\t/** A navigation for each team, of the terrain alone, cut for `options` (the world's smallest unit) */\n\tstatic async create(terrain: Terrain, teams: readonly number[], options: RecastNavigationOptions = {}): Promise<SidePaths> {\n\t\tconst sides = new Map<number, Side>()\n\t\t// asked side by side: the same ground, built once (`navigationData`) and read for each\n\t\tconst navigations = await allOrFreed(teams.map(() => () => RecastNavigation.create(terrain, options)))\n\t\tteams.forEach((team, i) => {\n\t\t\tconst navigation = navigations[i]\n\t\t\t// asked of only once settled (`route`): what is learned and forgotten meanwhile is made into tiles together,\n\t\t\t// a wooded tile once, not once a tree (RV42)\n\t\t\tnavigation.holdObstacles(true)\n\t\t\tsides.set(team, { navigation, known: new Map(), seen: new Map(), version: 0, dirty: false })\n\t\t})\n\t\treturn new SidePaths(sides)\n\t}\n\n\t/**\n\t * Listens to the world for what every side knows as it happens: the map's, and each side's own and its allies'\n\t * buildings, put down and gone. Given what the world has now, in its order, first: what a load starts from\n\t */\n\tattach(world: World): void {\n\t\tthis.stop?.()\n\t\tfor (const entity of world.entities.values()) this.put(world, entity)\n\t\tconst offs = [\n\t\t\tworld.events.on(entitySpawned, (entity) => this.put(world, entity)),\n\t\t\tworld.events.on(entityDied, ({ entity }) => this.gone(entity)),\n\t\t\tworld.events.on(entityRemoved, (entity) => this.gone(entity))\n\t\t]\n\t\tthis.stop = () => offs.forEach((off) => off())\n\t}\n\n\t/** Whether a team knows a building of `owner`'s without seeing it: the map's, its own, its allies' */\n\tprivate always(world: World, team: number, owner: PlayerId): boolean {\n\t\tconst player = world.players.get(owner)\n\t\tif (!player) return false\n\t\tif (player.neutral || player.creeps || player.team === team) return true\n\t\tfor (const other of world.players.values()) if (other.team === team) return world.areAllies(other.id, owner)\n\t\treturn false\n\t}\n\n\t/** A building put down: what every side knows of it at once */\n\tprivate put(world: World, entity: Entity): void {\n\t\tif (!entity.isStructure || !entity.alive || !entity.cell) return\n\t\tfor (const team of this.sides.keys()) if (this.always(world, team, entity.owner)) this.learn(team, entity.id, entity.rect)\n\t}\n\n\t/** A building gone: forgotten at once where it was known without being seen */\n\tprivate gone(entity: Entity): void {\n\t\tif (!entity.isStructure) return\n\t\tfor (const [team, side] of this.sides) if (side.known.has(entity.id) && !side.seen.has(entity.id)) this.forget(team, entity.id)\n\t}\n\n\t/** Whether a team plans with what it knows */\n\thas(team: number): boolean {\n\t\treturn this.sides.has(team)\n\t}\n\n\t/** One more each time what a team knows changes */\n\tversion(team: number): number {\n\t\treturn this.sides.get(team)?.version ?? 0\n\t}\n\n\t/** Whether the team knows the building by its id */\n\tknows(team: number, id: number): boolean {\n\t\treturn !!this.sides.get(team)?.known.has(id)\n\t}\n\n\t/** The buildings a team knows, by id */\n\tknown(team: number): ReadonlyMap<number, Rect> {\n\t\treturn this.sides.get(team)?.known ?? new Map()\n\t}\n\n\t/** A team knows a building from now: it is in the way of its routes. `seen` for one it learned of by sight */\n\tlearn(team: number, id: number, rect: Rect, seen = false): void {\n\t\tconst side = this.sides.get(team)\n\t\tif (!side || side.known.has(id)) return\n\t\tconst kept = { x: rect.x, z: rect.z, hw: rect.hw, hd: rect.hd }\n\t\tside.known.set(id, kept)\n\t\tif (seen) side.seen.set(id, kept)\n\t\tside.navigation.addObstacle(id, rect)\n\t\tside.version++\n\t\tside.dirty = true\n\t}\n\n\t/** A team knows a building is gone */\n\tforget(team: number, id: number): void {\n\t\tconst side = this.sides.get(team)\n\t\tif (!side?.known.delete(id)) return\n\t\tside.seen.delete(id)\n\t\tside.navigation.removeObstacle(id)\n\t\tside.version++\n\t\tside.dirty = true\n\t}\n\n\t/** Brings each navigation up to date with what was learned and forgotten: before a route is planned on it */\n\tsettle(): void {\n\t\tfor (const side of this.sides.values()) {\n\t\t\tif (!side.dirty) continue\n\t\t\tside.navigation.settle(side.navigation.version)\n\t\t\tside.dirty = false\n\t\t}\n\t}\n\n\t/** The corners of a route from one point to another, as the team knows the ground. Null where it knows no way */\n\troute(team: number, from: Vec2, to: Vec2): Vec2[] | null {\n\t\tconst side = this.sides.get(team)\n\t\tif (!side) return null\n\t\tif (side.dirty) this.settle()\n\t\treturn side.navigation.findPath(from, to)\n\t}\n\n\t/** What the world keeps of it (`sideKnowledge`): what each side learned by sight */\n\tsave(): Record<number, KnownBuilding[]> {\n\t\tconst saved: Record<number, KnownBuilding[]> = {}\n\t\tfor (const [team, side] of this.sides) saved[team] = [...side.seen].map(([id, rect]) => [id, rect.x, rect.z, rect.hw, rect.hd])\n\t\treturn saved\n\t}\n\n\t/** After a load: what every side knows of the world as it is (`attach`), then what each learned by sight */\n\trestore(world: World, saved: Record<number, KnownBuilding[]>): void {\n\t\tthis.attach(world)\n\t\tfor (const [team, buildings] of Object.entries(saved)) {\n\t\t\tfor (const [id, x, z, hw, hd] of buildings) this.learn(Number(team), id, { x, z, hw, hd }, true)\n\t\t}\n\t\tthis.settle()\n\t}\n\n\t/** Every enemy building of `team`'s, in the order they were put there: the ones it can come to know by sight */\n\t*strangers(world: World, team: number): Generator<Entity> {\n\t\tfor (const owner of world.players.values()) {\n\t\t\tif (this.always(world, team, owner.id)) continue\n\t\t\tfor (const entity of world.index.ownedBy(owner.id)) if (entity.isStructure && entity.alive && entity.cell) yield entity\n\t\t}\n\t}\n\n\t/** The buildings a team learned of by sight */\n\tseen(team: number): ReadonlyMap<number, Rect> {\n\t\treturn this.sides.get(team)?.seen ?? new Map()\n\t}\n\n\t/** A slowing layer of cells changed on these cells: each side's navigation weighs them again, as the world's does (EN2) */\n\tgroundChanged(cells: readonly number[], walkability?: boolean): void {\n\t\tfor (const side of this.sides.values()) side.navigation.groundChanged(cells, walkability)\n\t}\n\n\t/** The ground was reshaped: each side's navigation cut again of it, as the world's is */\n\treshape(area?: CellArea): void {\n\t\tfor (const side of this.sides.values()) side.navigation.reshape?.(area)\n\t}\n\n\t/** What the ground's changes asked of each side's navigation done now, as the world's is as each tick ends */\n\tsettleGround(): void {\n\t\tfor (const side of this.sides.values()) side.navigation.settleGround?.()\n\t}\n\n\t/** Frees what the object holds, such as its subscriptions and each side's navigation */\n\tdispose(): void {\n\t\tthis.stop?.()\n\t\tfor (const side of this.sides.values()) side.navigation.dispose()\n\t\tthis.sides.clear()\n\t}\n}\n\n/** Whether any cell of a rectangle is in a team's sight */\nfunction inSight(world: World, team: number, rect: Rect): boolean {\n\tconst x0 = Math.floor(rect.x - rect.hw)\n\tconst x1 = Math.ceil(rect.x + rect.hw) - 1\n\tconst z0 = Math.floor(rect.z - rect.hd)\n\tconst z1 = Math.ceil(rect.z + rect.hd) - 1\n\tfor (let z = z0; z <= z1; z++) for (let x = x0; x <= x1; x++) if (world.fog.isVisible(team, x + 0.5, z + 0.5)) return true\n\treturn false\n}\n\n/**\n * What each side learns by sight, after the fog is lit (`Rules.paths: 'seen'`): another side's buildings once a\n * cell of one is in sight, and that one gone once its place is. What it knows without seeing is the world's to tell\n * as it happens (`SidePaths.attach`). Kept in the world (`sideKnowledge`) as it changes\n */\nexport const sideKnowledgeSystem: System = {\n\tname: 'sideKnowledge',\n\tphase: 'cleanup',\n\tevery: 3,\n\tupdate(world) {\n\t\tconst paths = world.sidePaths\n\t\tif (!paths) return\n\t\tlet changed = false\n\t\tconst teams = [...new Set([...world.players.values()].map((player) => player.team))].filter((team) => paths.has(team))\n\t\tfor (const team of teams) {\n\t\t\tfor (const entity of paths.strangers(world, team)) {\n\t\t\t\tif (paths.knows(team, entity.id) || !inSight(world, team, entity.rect)) continue\n\t\t\t\tpaths.learn(team, entity.id, entity.rect, true)\n\t\t\t\tchanged = true\n\t\t\t}\n\t\t\tfor (const [id, rect] of [...paths.seen(team)]) {\n\t\t\t\tconst entity = world.entities.get(id)\n\t\t\t\tif ((entity?.alive && entity.cell) || !inSight(world, team, rect)) continue\n\t\t\t\tpaths.forget(team, id)\n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