@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":"look.js","names":[],"sources":["../../src/map/look.ts"],"sourcesContent":["/*\n * What a map looks like beyond its ground, as data the engine carries and never reads: light, fog, sky, water, weather, tiles' looks (design review E8a: `map.ts` in parts)\n */\nimport { environmentChanged } from '#engine/engineEvents'\nimport { replicateEvent } from '../replication'\nimport { MAX_TILES } from '../tiles'\n\n/**\n * What a map looks like beyond its ground (design review E8c): the engine carries it (in the map, its file, a save,\n * what players are told as it changes: `world.setEnvironment`) and reads none of it but the map's own tiles, which are\n * paint like the game's. An open interface: the client adds what it draws by (its water, light, sky, fog, weather,\n * lights and the rest), as a game adds its commands (`Commands`)\n *\n * @public\n */\nexport interface MapEnvironment {\n\t/** Ground of the map's own to paint with, past the game's tiles (see `MapTile`): the rules' paint, by id */\n\ttiles?: MapTile[]\n}\n\n/**\n * A ground of a map's own, to paint with as a game's tiles are (`MapEnvironment.tiles`): to the rules, paint by its id.\n * An open interface: the client adds its look (its picture, colour, pattern)\n *\n * @beta\n */\nexport interface MapTile {\n\t/** Its id in the map's paint (`GameMap.tileset`): none of the game's tiles' */\n\tid: string\n\t/** What the editor's palette calls it */\n\tname: string\n}\n\n/**\n * The ids of a map's own tiles (`MapEnvironment.tiles`)\n *\n * @beta\n */\nexport const mapTileIds = (environment: MapEnvironment | undefined): string[] => (environment?.tiles ?? []).map((tile) => tile.id)\n\n/**\n * The tiles a world from a map is painted with: the game's, then the map's own that are none of them, as many as a map\n * can hold. The order a played ground's paint is in, and its looks\n *\n * @beta\n */\nexport function playTileset(gameTiles: readonly string[], environment: MapEnvironment | undefined): string[] {\n\tconst own = mapTileIds(environment).filter((id) => !gameTiles.includes(id))\n\treturn [...gameTiles, ...own].slice(0, MAX_TILES)\n}\n\n/** The map's light, fog and sky changed (`world.setEnvironment`): to everyone */\nexport const toldEnvironment = replicateEvent(environmentChanged, 'environment', ({ environment, over }) => ({\n\ttype: 'environment',\n\tenvironment: structuredClone(environment),\n\t...(over && { over })\n}))\n\n/**\n * The light a doodad carries (`MapDoodad.light`), over the one its kind of doodad gives: an open interface the client\n * fills in with what a light of the map is (`MapLightSource`, less where it stands and its name)\n *\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface MapDoodadLight {}\n"],"mappings":";;;;;;;;;AAsCA,IAAa,cAAc,iBAAuD,aAAa,SAAS,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,EAAE;;;;;;;AAQjI,SAAgB,YAAY,WAA8B,aAAmD;CAC5G,MAAM,MAAM,WAAW,WAAW,CAAC,CAAC,QAAQ,OAAO,CAAC,UAAU,SAAS,EAAE,CAAC;CAC1E,OAAO,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,CAAC,MAAM,GAAA,GAAY;AACjD;;AAGA,IAAa,kBAAkB,eAAe,oBAAoB,gBAAgB,EAAE,aAAa,YAAY;CAC5G,MAAM;CACN,aAAa,gBAAgB,WAAW;CACxC,GAAI,QAAQ,EAAE,KAAK;AACpB,EAAE"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { hypot } from "../exactMath.js";
|
|
2
|
+
import { clamp, smoothstep } from "../math.js";
|
|
3
|
+
import "../terrain.js";
|
|
4
|
+
//#region src/map/pathProfile.ts
|
|
5
|
+
/**
|
|
6
|
+
* How deep the ground is under water, by its kind (none, shallow, deep)
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
var WATER_DEPTH = [
|
|
11
|
+
0,
|
|
12
|
+
.45,
|
|
13
|
+
1.6
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* How far along a path its land is averaged each way, in cells: what makes a road as smooth along it as a road is
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
var PROFILE_SMOOTH = 4;
|
|
21
|
+
/**
|
|
22
|
+
* How far a path's profile reaches from its line, in cells: half its bed and its banks
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
function profileReach(path) {
|
|
27
|
+
const profile = path.profile ?? {};
|
|
28
|
+
return Math.max(profile.width ?? path.width, 1) / 2 + Math.max(profile.banks ?? 2, 0);
|
|
29
|
+
}
|
|
30
|
+
/** How deep the water in a profile's bed is */
|
|
31
|
+
var waterOf = (profile) => !profile.water ? 0 : (profile.depth ?? 0) >= 1 ? 2 : 1;
|
|
32
|
+
/** How far the land along a path is read, in cells: every half a cell from each point */
|
|
33
|
+
var STEP = .5;
|
|
34
|
+
/** The map's own land at a point, between its corners: the heights a carve starts from */
|
|
35
|
+
function landAt(map, x, z) {
|
|
36
|
+
const vx = map.width + 1;
|
|
37
|
+
const fx = clamp(x, 0, map.width);
|
|
38
|
+
const fz = clamp(z, 0, map.depth);
|
|
39
|
+
const ix = Math.min(Math.floor(fx), map.width - 1);
|
|
40
|
+
const iz = Math.min(Math.floor(fz), map.depth - 1);
|
|
41
|
+
const tx = fx - ix;
|
|
42
|
+
const tz = fz - iz;
|
|
43
|
+
const g = map.ground;
|
|
44
|
+
const a = g[iz * vx + ix] + (g[iz * vx + ix + 1] - g[iz * vx + ix]) * tx;
|
|
45
|
+
return a + (g[(iz + 1) * vx + ix] + (g[(iz + 1) * vx + ix + 1] - g[(iz + 1) * vx + ix]) * tx - a) * tz;
|
|
46
|
+
}
|
|
47
|
+
function lineOf(map, path) {
|
|
48
|
+
const { points } = path;
|
|
49
|
+
const starts = [0];
|
|
50
|
+
const along = [];
|
|
51
|
+
const raw = [];
|
|
52
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
53
|
+
const a = points[i];
|
|
54
|
+
const b = points[i + 1];
|
|
55
|
+
const length = hypot(b.x - a.x, b.z - a.z);
|
|
56
|
+
starts.push(starts[i] + length);
|
|
57
|
+
for (let d = 0; d < length; d += STEP) {
|
|
58
|
+
const t = d / length;
|
|
59
|
+
along.push(starts[i] + d);
|
|
60
|
+
raw.push(landAt(map, a.x + (b.x - a.x) * t, a.z + (b.z - a.z) * t));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const last = points[points.length - 1];
|
|
64
|
+
along.push(starts[starts.length - 1]);
|
|
65
|
+
raw.push(landAt(map, last.x, last.z));
|
|
66
|
+
const height = new Array(raw.length);
|
|
67
|
+
let from = 0;
|
|
68
|
+
let to = 0;
|
|
69
|
+
let sum = 0;
|
|
70
|
+
for (let k = 0; k < raw.length; k++) {
|
|
71
|
+
while (to < raw.length && along[to] <= along[k] + 4) sum += raw[to++];
|
|
72
|
+
while (along[from] < along[k] - 4) sum -= raw[from++];
|
|
73
|
+
height[k] = sum / (to - from);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
points,
|
|
77
|
+
starts,
|
|
78
|
+
along,
|
|
79
|
+
height
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** The smoothed land at a distance along a line */
|
|
83
|
+
function heightAlong(line, at) {
|
|
84
|
+
const { along, height } = line;
|
|
85
|
+
if (at <= along[0]) return height[0];
|
|
86
|
+
if (at >= along[along.length - 1]) return height[height.length - 1];
|
|
87
|
+
let lo = 0;
|
|
88
|
+
let hi = along.length - 1;
|
|
89
|
+
while (hi - lo > 1) {
|
|
90
|
+
const mid = lo + hi >> 1;
|
|
91
|
+
if (along[mid] <= at) lo = mid;
|
|
92
|
+
else hi = mid;
|
|
93
|
+
}
|
|
94
|
+
const span = along[hi] - along[lo] || 1;
|
|
95
|
+
return height[lo] + (height[hi] - height[lo]) * ((at - along[lo]) / span);
|
|
96
|
+
}
|
|
97
|
+
/** The nearest point of a line to a point within `reach`: how far, and how far along; nothing beyond `reach` */
|
|
98
|
+
function nearest(line, x, z, reach) {
|
|
99
|
+
let best = reach;
|
|
100
|
+
let along = -1;
|
|
101
|
+
const { points, starts } = line;
|
|
102
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
103
|
+
const a = points[i];
|
|
104
|
+
const b = points[i + 1];
|
|
105
|
+
if (x < Math.min(a.x, b.x) - best || x > Math.max(a.x, b.x) + best || z < Math.min(a.z, b.z) - best || z > Math.max(a.z, b.z) + best) continue;
|
|
106
|
+
const dx = b.x - a.x;
|
|
107
|
+
const dz = b.z - a.z;
|
|
108
|
+
const span = dx * dx + dz * dz;
|
|
109
|
+
const t = span ? clamp(((x - a.x) * dx + (z - a.z) * dz) / span, 0, 1) : 0;
|
|
110
|
+
const d = hypot(x - (a.x + dx * t), z - (a.z + dz * t));
|
|
111
|
+
if (d <= best) {
|
|
112
|
+
best = d;
|
|
113
|
+
along = starts[i] + t * (starts[i + 1] - starts[i]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return along < 0 ? void 0 : {
|
|
117
|
+
distance: best,
|
|
118
|
+
along
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The ground the paths with a profile carve, for the corners `x0..x1` × `z0..z1` (row by row), and the water they put
|
|
123
|
+
* in the cells `x0 - 1..x1` × `z0 - 1..z1` (row by row; 0 where they put none): nothing where no profile reaches
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
function profiledGround(map, x0, z0, x1, z1) {
|
|
128
|
+
const profiled = map.paths.filter((path) => path.profile && path.points.length > 1);
|
|
129
|
+
if (!profiled.length) return void 0;
|
|
130
|
+
const vx = map.width + 1;
|
|
131
|
+
const row = x1 - x0 + 1;
|
|
132
|
+
let ground;
|
|
133
|
+
let water;
|
|
134
|
+
const cellRow = x1 - x0 + 2;
|
|
135
|
+
/** The corners as the map has them, the first time a profile reaches one */
|
|
136
|
+
const corners = () => {
|
|
137
|
+
if (ground) return ground;
|
|
138
|
+
ground = new Float64Array(row * (z1 - z0 + 1));
|
|
139
|
+
for (let z = z0; z <= z1; z++) for (let x = x0; x <= x1; x++) ground[(z - z0) * row + (x - x0)] = map.ground[z * vx + x];
|
|
140
|
+
return ground;
|
|
141
|
+
};
|
|
142
|
+
for (const path of profiled) {
|
|
143
|
+
const profile = path.profile;
|
|
144
|
+
const reach = profileReach(path);
|
|
145
|
+
const xs = path.points.map((p) => p.x);
|
|
146
|
+
const zs = path.points.map((p) => p.z);
|
|
147
|
+
if (Math.max(...xs) + reach < x0 - 1 || Math.min(...xs) - reach > x1 || Math.max(...zs) + reach < z0 - 1 || Math.min(...zs) - reach > z1) continue;
|
|
148
|
+
const line = lineOf(map, path);
|
|
149
|
+
const half = Math.max(profile.width ?? path.width, 1) / 2;
|
|
150
|
+
const banks = Math.max(profile.banks ?? 2, 0);
|
|
151
|
+
const kind = waterOf(profile);
|
|
152
|
+
const lowered = Math.max((profile.depth ?? 0) - WATER_DEPTH[kind], 0);
|
|
153
|
+
const vx0 = Math.max(Math.floor(Math.min(...xs) - reach), x0);
|
|
154
|
+
const vz0 = Math.max(Math.floor(Math.min(...zs) - reach), z0);
|
|
155
|
+
const vx1 = Math.min(Math.ceil(Math.max(...xs) + reach), x1);
|
|
156
|
+
const vz1 = Math.min(Math.ceil(Math.max(...zs) + reach), z1);
|
|
157
|
+
for (let iz = vz0; iz <= vz1; iz++) for (let ix = vx0; ix <= vx1; ix++) {
|
|
158
|
+
const near = nearest(line, ix, iz, reach);
|
|
159
|
+
if (!near) continue;
|
|
160
|
+
const carved = corners();
|
|
161
|
+
const weight = near.distance <= half ? 1 : 1 - smoothstep(0, 1, (near.distance - half) / (banks || 1));
|
|
162
|
+
const at = (iz - z0) * row + (ix - x0);
|
|
163
|
+
const bed = heightAlong(line, near.along) - lowered;
|
|
164
|
+
carved[at] += (bed - carved[at]) * weight;
|
|
165
|
+
}
|
|
166
|
+
if (!kind) continue;
|
|
167
|
+
for (let cz = Math.max(vz0 - 1, z0 - 1, 0); cz <= Math.min(vz1, z1, map.depth - 1); cz++) for (let cx = Math.max(vx0 - 1, x0 - 1, 0); cx <= Math.min(vx1, x1, map.width - 1); cx++) {
|
|
168
|
+
if (!nearest(line, cx + .5, cz + .5, half)) continue;
|
|
169
|
+
corners();
|
|
170
|
+
water ??= new Uint8Array(cellRow * (z1 - z0 + 2));
|
|
171
|
+
const at = (cz - z0 + 1) * cellRow + (cx - x0 + 1);
|
|
172
|
+
water[at] = Math.max(water[at], kind);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return ground && {
|
|
176
|
+
ground,
|
|
177
|
+
water
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { PROFILE_SMOOTH, WATER_DEPTH, profileReach, profiledGround };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=pathProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathProfile.js","names":[],"sources":["../../src/map/pathProfile.ts"],"sourcesContent":["import { hypot } from '../exactMath'\nimport { clamp, smoothstep } from '../math'\nimport { WATER_DEEP, WATER_SHALLOW } from '../terrain'\nimport type { GameMap, MapPath, PathProfile } from './types'\n\n/*\n * Roads and rivers carved as the terrain is worked out (EQ19): a path with a profile (`MapPath.profile`) lowers and\n * levels the ground under it from the map's own land, which stays as it is painted, so the bed follows the path's\n * points wherever they go, and an edit of a few cells works out a few cells again (`updateMapTerrain`'s area). The same\n * in every engine: square roots, sums and smoothsteps, no sines.\n */\n\n/**\n * How deep the ground is under water, by its kind (none, shallow, deep)\n *\n * @internal\n */\nexport const WATER_DEPTH = [0, 0.45, 1.6]\n\n/**\n * How far along a path its land is averaged each way, in cells: what makes a road as smooth along it as a road is\n *\n * @beta\n */\nexport const PROFILE_SMOOTH = 4\n\n/**\n * How far a path's profile reaches from its line, in cells: half its bed and its banks\n *\n * @beta\n */\nexport function profileReach(path: Pick<MapPath, 'width' | 'profile'>): number {\n\tconst profile = path.profile ?? {}\n\treturn Math.max(profile.width ?? path.width, 1) / 2 + Math.max(profile.banks ?? 2, 0)\n}\n\n/** How deep the water in a profile's bed is */\nconst waterOf = (profile: PathProfile) => (!profile.water ? 0 : (profile.depth ?? 0) >= 1 ? WATER_DEEP : WATER_SHALLOW)\n\n/** How far the land along a path is read, in cells: every half a cell from each point */\nconst STEP = 0.5\n\n/**\n * A path's line as the carve reads it: its segments, how far along each begins, and its land along it smoothed (from\n * each point every half a cell, so a moved point changes the samples of its own two segments alone)\n */\ninterface Line {\n\tpoints: { x: number; z: number }[]\n\tstarts: number[]\n\talong: number[]\n\theight: number[]\n}\n\n/** The map's own land at a point, between its corners: the heights a carve starts from */\nfunction landAt(map: GameMap, x: number, z: number): number {\n\tconst vx = map.width + 1\n\tconst fx = clamp(x, 0, map.width)\n\tconst fz = clamp(z, 0, map.depth)\n\tconst ix = Math.min(Math.floor(fx), map.width - 1)\n\tconst iz = Math.min(Math.floor(fz), map.depth - 1)\n\tconst tx = fx - ix\n\tconst tz = fz - iz\n\tconst g = map.ground\n\tconst a = g[iz * vx + ix] + (g[iz * vx + ix + 1] - g[iz * vx + ix]) * tx\n\tconst b = g[(iz + 1) * vx + ix] + (g[(iz + 1) * vx + ix + 1] - g[(iz + 1) * vx + ix]) * tx\n\treturn a + (b - a) * tz\n}\n\nfunction lineOf(map: GameMap, path: MapPath): Line {\n\tconst { points } = path\n\tconst starts = [0]\n\tconst along: number[] = []\n\tconst raw: number[] = []\n\tfor (let i = 0; i < points.length - 1; i++) {\n\t\tconst a = points[i]\n\t\tconst b = points[i + 1]\n\t\tconst length = hypot(b.x - a.x, b.z - a.z)\n\t\tstarts.push(starts[i] + length)\n\t\tfor (let d = 0; d < length; d += STEP) {\n\t\t\tconst t = d / length\n\t\t\talong.push(starts[i] + d)\n\t\t\traw.push(landAt(map, a.x + (b.x - a.x) * t, a.z + (b.z - a.z) * t))\n\t\t}\n\t}\n\tconst last = points[points.length - 1]\n\talong.push(starts[starts.length - 1])\n\traw.push(landAt(map, last.x, last.z))\n\t// each sample the mean of those within PROFILE_SMOOTH of it along the path\n\tconst height = new Array<number>(raw.length)\n\tlet from = 0\n\tlet to = 0\n\tlet sum = 0\n\tfor (let k = 0; k < raw.length; k++) {\n\t\twhile (to < raw.length && along[to] <= along[k] + PROFILE_SMOOTH) sum += raw[to++]\n\t\twhile (along[from] < along[k] - PROFILE_SMOOTH) sum -= raw[from++]\n\t\theight[k] = sum / (to - from)\n\t}\n\treturn { points, starts, along, height }\n}\n\n/** The smoothed land at a distance along a line */\nfunction heightAlong(line: Line, at: number): number {\n\tconst { along, height } = line\n\tif (at <= along[0]) return height[0]\n\tif (at >= along[along.length - 1]) return height[height.length - 1]\n\tlet lo = 0\n\tlet hi = along.length - 1\n\twhile (hi - lo > 1) {\n\t\tconst mid = (lo + hi) >> 1\n\t\tif (along[mid] <= at) lo = mid\n\t\telse hi = mid\n\t}\n\tconst span = along[hi] - along[lo] || 1\n\treturn height[lo] + (height[hi] - height[lo]) * ((at - along[lo]) / span)\n}\n\n/** The nearest point of a line to a point within `reach`: how far, and how far along; nothing beyond `reach` */\nfunction nearest(line: Line, x: number, z: number, reach: number): { distance: number; along: number } | undefined {\n\tlet best = reach\n\tlet along = -1\n\tconst { points, starts } = line\n\tfor (let i = 0; i < points.length - 1; i++) {\n\t\tconst a = points[i]\n\t\tconst b = points[i + 1]\n\t\t// (a segment whose box is out of reach is not looked at)\n\t\tif (x < Math.min(a.x, b.x) - best || x > Math.max(a.x, b.x) + best || z < Math.min(a.z, b.z) - best || z > Math.max(a.z, b.z) + best) continue\n\t\tconst dx = b.x - a.x\n\t\tconst dz = b.z - a.z\n\t\tconst span = dx * dx + dz * dz\n\t\tconst t = span ? clamp(((x - a.x) * dx + (z - a.z) * dz) / span, 0, 1) : 0\n\t\tconst d = hypot(x - (a.x + dx * t), z - (a.z + dz * t))\n\t\tif (d <= best) {\n\t\t\tbest = d\n\t\t\talong = starts[i] + t * (starts[i + 1] - starts[i])\n\t\t}\n\t}\n\treturn along < 0 ? undefined : { distance: best, along }\n}\n\n/**\n * The ground the paths with a profile carve, for the corners `x0..x1` × `z0..z1` (row by row), and the water they put\n * in the cells `x0 - 1..x1` × `z0 - 1..z1` (row by row; 0 where they put none): nothing where no profile reaches\n *\n * @internal\n */\nexport function profiledGround(\n\tmap: GameMap,\n\tx0: number,\n\tz0: number,\n\tx1: number,\n\tz1: number\n): { ground: Float64Array; water: Uint8Array | undefined } | undefined {\n\tconst profiled = map.paths.filter((path) => path.profile && path.points.length > 1)\n\tif (!profiled.length) return undefined\n\tconst vx = map.width + 1\n\tconst row = x1 - x0 + 1\n\tlet ground: Float64Array | undefined\n\tlet water: Uint8Array | undefined\n\tconst cellRow = x1 - x0 + 2\n\t/** The corners as the map has them, the first time a profile reaches one */\n\tconst corners = (): Float64Array => {\n\t\tif (ground) return ground\n\t\tground = new Float64Array(row * (z1 - z0 + 1))\n\t\tfor (let z = z0; z <= z1; z++) for (let x = x0; x <= x1; x++) ground[(z - z0) * row + (x - x0)] = map.ground[z * vx + x]\n\t\treturn ground\n\t}\n\tfor (const path of profiled) {\n\t\tconst profile = path.profile!\n\t\tconst reach = profileReach(path)\n\t\tconst xs = path.points.map((p) => p.x)\n\t\tconst zs = path.points.map((p) => p.z)\n\t\tif (Math.max(...xs) + reach < x0 - 1 || Math.min(...xs) - reach > x1 || Math.max(...zs) + reach < z0 - 1 || Math.min(...zs) - reach > z1) continue\n\t\tconst line = lineOf(map, path)\n\t\tconst half = Math.max(profile.width ?? path.width, 1) / 2\n\t\tconst banks = Math.max(profile.banks ?? 2, 0)\n\t\tconst kind = waterOf(profile)\n\t\t// with water in it, the water is part of the depth: the bed is lowered by the rest\n\t\tconst lowered = Math.max((profile.depth ?? 0) - WATER_DEPTH[kind], 0)\n\t\tconst vx0 = Math.max(Math.floor(Math.min(...xs) - reach), x0)\n\t\tconst vz0 = Math.max(Math.floor(Math.min(...zs) - reach), z0)\n\t\tconst vx1 = Math.min(Math.ceil(Math.max(...xs) + reach), x1)\n\t\tconst vz1 = Math.min(Math.ceil(Math.max(...zs) + reach), z1)\n\t\tfor (let iz = vz0; iz <= vz1; iz++) {\n\t\t\tfor (let ix = vx0; ix <= vx1; ix++) {\n\t\t\t\tconst near = nearest(line, ix, iz, reach)\n\t\t\t\tif (!near) continue\n\t\t\t\tconst carved = corners()\n\t\t\t\t// on the bed all of it; over the banks less and less, eased\n\t\t\t\tconst weight = near.distance <= half ? 1 : 1 - smoothstep(0, 1, (near.distance - half) / (banks || 1))\n\t\t\t\tconst at = (iz - z0) * row + (ix - x0)\n\t\t\t\tconst bed = heightAlong(line, near.along) - lowered\n\t\t\t\tcarved[at] += (bed - carved[at]) * weight\n\t\t\t}\n\t\t}\n\t\tif (!kind) continue\n\t\tfor (let cz = Math.max(vz0 - 1, z0 - 1, 0); cz <= Math.min(vz1, z1, map.depth - 1); cz++) {\n\t\t\tfor (let cx = Math.max(vx0 - 1, x0 - 1, 0); cx <= Math.min(vx1, x1, map.width - 1); cx++) {\n\t\t\t\tconst near = nearest(line, cx + 0.5, cz + 0.5, half)\n\t\t\t\tif (!near) continue\n\t\t\t\tcorners()\n\t\t\t\twater ??= new Uint8Array(cellRow * (z1 - z0 + 2))\n\t\t\t\tconst at = (cz - z0 + 1) * cellRow + (cx - x0 + 1)\n\t\t\t\twater[at] = Math.max(water[at], kind)\n\t\t\t}\n\t\t}\n\t}\n\treturn ground && { ground, water }\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAa,cAAc;CAAC;CAAG;CAAM;AAAG;;;;;;AAOxC,IAAa,iBAAiB;;;;;;AAO9B,SAAgB,aAAa,MAAkD;CAC9E,MAAM,UAAU,KAAK,WAAW,CAAC;CACjC,OAAO,KAAK,IAAI,QAAQ,SAAS,KAAK,OAAO,CAAC,IAAI,IAAI,KAAK,IAAI,QAAQ,SAAS,GAAG,CAAC;AACrF;;AAGA,IAAM,WAAW,YAA0B,CAAC,Q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QAAQ;GAEvB,MAAM,SAAS,KAAK,YAAY,OAAO,IAAI,IAAI,WAAW,GAAG,IAAI,KAAK,WAAW,SAAS,SAAS,EAAE;GACrG,MAAM,MAAM,KAAK,MAAM,OAAO,KAAK;GACnC,MAAM,MAAM,YAAY,MAAM,KAAK,KAAK,IAAI;GAC5C,OAAO,QAAQ,MAAM,OAAO,OAAO;EACpC;EAED,IAAI,CAAC,MAAM;EACX,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,MACnF,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,MAAM;GAEzF,IAAI,CADS,QAAQ,MAAM,KAAK,IAAK,KAAK,IAAK,IAC1C,GAAM;GACX,QAAQ;GACR,UAAU,IAAI,WAAW,WAAW,KAAK,KAAK,EAAE;GAChD,MAAM,MAAM,KAAK,KAAK,KAAK,WAAW,KAAK,KAAK;GAChD,MAAM,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI;EACrC;CAEF;CACA,OAAO,UAAU;EAAE;EAAQ;CAAM;AAClC"}
|
package/dist/map/resize.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ import { type GameMap } from './types';
|
|
|
9
9
|
export interface MapSides {
|
|
10
10
|
/** Towards x 0, and towards x of the width */
|
|
11
11
|
left: number;
|
|
12
|
+
/** Cells gained on the right, towards x of the width; less than 0 cuts them */
|
|
12
13
|
right: number;
|
|
13
14
|
/** Towards z 0, and towards z of the depth */
|
|
14
15
|
top: number;
|
|
16
|
+
/** Cells gained on the bottom, towards z of the depth; less than 0 cuts them */
|
|
15
17
|
bottom: number;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
@@ -21,9 +23,11 @@ export interface MapSides {
|
|
|
21
23
|
* @beta
|
|
22
24
|
*/
|
|
23
25
|
export interface MapResize {
|
|
26
|
+
/** The sides the map is grown or cut on */
|
|
24
27
|
readonly sides: MapSides;
|
|
25
28
|
/** The new size, in cells */
|
|
26
29
|
readonly width: number;
|
|
30
|
+
/** The new depth of the map in cells */
|
|
27
31
|
readonly depth: number;
|
|
28
32
|
/** A place where it is on the grown map (the old place, moved by the cells gained on the left and the top) */
|
|
29
33
|
moved<P extends Vec2>(place: P): P;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { clamp } from "../math.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
import { fieldsOf } from "./schema.js";
|
|
4
|
+
import { cloneMap } from "./file.js";
|
|
5
|
+
//#region src/map/resize.ts
|
|
6
|
+
/**
|
|
7
|
+
* A map grown or cut on any side: the ground, cliffs, water and paint go on as they were at the old edge where it
|
|
8
|
+
* grows; everything on it moves along, and what is no longer on the map is gone. The map itself is left as it was.
|
|
9
|
+
* What the engine keeps moves (objects, camps, regions, points, paths, doodads, cameras, the players' starts, the bounds,
|
|
10
|
+
* the game's own kinds' things in `data`); what others keep moves with the `resizers` given (the client's looks:
|
|
11
|
+
* `mapLooksResizer`)
|
|
12
|
+
*
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
function resizeMap(map, sides, resizers = []) {
|
|
16
|
+
const { left, right, top, bottom } = sides;
|
|
17
|
+
const width = map.width + left + right;
|
|
18
|
+
const depth = map.depth + top + bottom;
|
|
19
|
+
if (width < 8 || depth < 8 || width > 512 || depth > 512) throw new Error(`A map is between 8 and 512 cells each way, not ${width} × ${depth}`);
|
|
20
|
+
const copy = cloneMap(map);
|
|
21
|
+
const layer = (old, oldRow, oldColumn, row, column) => {
|
|
22
|
+
const out = new old.constructor(row * column);
|
|
23
|
+
for (let z = 0; z < column; z++) {
|
|
24
|
+
const from = clamp(z - top, 0, oldColumn - 1) * oldRow;
|
|
25
|
+
for (let x = 0; x < row; x++) out[z * row + x] = old[from + clamp(x - left, 0, oldRow - 1)];
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
};
|
|
29
|
+
copy.width = width;
|
|
30
|
+
copy.depth = depth;
|
|
31
|
+
const grown = (old, perVertex = false) => perVertex ? layer(old, map.width + 1, map.depth + 1, width + 1, depth + 1) : layer(old, map.width, map.depth, width, depth);
|
|
32
|
+
const into = copy;
|
|
33
|
+
for (const field of fieldsOf("layer", "mask", "layers")) {
|
|
34
|
+
const value = map[field.key];
|
|
35
|
+
if (!value) continue;
|
|
36
|
+
into[field.key] = field.kind === "layers" ? Object.fromEntries(Object.entries(value).map(([id, cells]) => [id, grown(cells)])) : grown(value, field.perVertex);
|
|
37
|
+
}
|
|
38
|
+
const on = (p) => p.x >= 0 && p.z >= 0 && p.x <= width && p.z <= depth;
|
|
39
|
+
const moved = (p) => ({
|
|
40
|
+
...p,
|
|
41
|
+
x: p.x + left,
|
|
42
|
+
z: p.z + top
|
|
43
|
+
});
|
|
44
|
+
const inside = (p) => ({
|
|
45
|
+
...p,
|
|
46
|
+
x: clamp(p.x, 0, width),
|
|
47
|
+
z: clamp(p.z, 0, depth)
|
|
48
|
+
});
|
|
49
|
+
const shape = (shape) => {
|
|
50
|
+
if (shape.kind !== "rect") {
|
|
51
|
+
const center = moved(shape);
|
|
52
|
+
return on(center) ? center : void 0;
|
|
53
|
+
}
|
|
54
|
+
const x0 = Math.max(shape.x - shape.width / 2 + left, 0);
|
|
55
|
+
const z0 = Math.max(shape.z - shape.depth / 2 + top, 0);
|
|
56
|
+
const x1 = Math.min(shape.x + shape.width / 2 + left, width);
|
|
57
|
+
const z1 = Math.min(shape.z + shape.depth / 2 + top, depth);
|
|
58
|
+
return x1 > x0 && z1 > z0 ? {
|
|
59
|
+
...shape,
|
|
60
|
+
x: (x0 + x1) / 2,
|
|
61
|
+
z: (z0 + z1) / 2,
|
|
62
|
+
width: x1 - x0,
|
|
63
|
+
depth: z1 - z0
|
|
64
|
+
} : void 0;
|
|
65
|
+
};
|
|
66
|
+
copy.objects = copy.objects.map((object) => ({
|
|
67
|
+
...object,
|
|
68
|
+
...moved(object)
|
|
69
|
+
})).filter(on);
|
|
70
|
+
copy.camps = copy.camps.map((camp) => ({
|
|
71
|
+
...camp,
|
|
72
|
+
...moved(camp)
|
|
73
|
+
})).filter(on);
|
|
74
|
+
copy.points = copy.points.map((point) => ({
|
|
75
|
+
...point,
|
|
76
|
+
...moved(point)
|
|
77
|
+
})).filter(on);
|
|
78
|
+
copy.doodads = copy.doodads.map((doodad) => ({
|
|
79
|
+
...doodad,
|
|
80
|
+
...moved(doodad)
|
|
81
|
+
})).filter(on);
|
|
82
|
+
copy.cameras = copy.cameras.map((camera) => ({
|
|
83
|
+
...camera,
|
|
84
|
+
...inside(moved(camera))
|
|
85
|
+
}));
|
|
86
|
+
copy.paths = copy.paths.map((path) => ({
|
|
87
|
+
...path,
|
|
88
|
+
points: path.points.map((p) => inside(moved(p)))
|
|
89
|
+
}));
|
|
90
|
+
copy.players = copy.players.map((player) => {
|
|
91
|
+
if (!player.start) return player;
|
|
92
|
+
const start = moved(player.start);
|
|
93
|
+
const { start: _, ...rest } = player;
|
|
94
|
+
return on(start) ? {
|
|
95
|
+
...player,
|
|
96
|
+
start
|
|
97
|
+
} : rest;
|
|
98
|
+
});
|
|
99
|
+
copy.regions = copy.regions.flatMap((region) => {
|
|
100
|
+
const moved = shape(region.shape);
|
|
101
|
+
return moved ? [{
|
|
102
|
+
...region,
|
|
103
|
+
shape: moved
|
|
104
|
+
}] : [];
|
|
105
|
+
});
|
|
106
|
+
for (const [kind, kept] of Object.entries(copy.data)) if (Array.isArray(kept) && kept.length && kept.every(isThing)) copy.data[kind] = kept.map((thing) => moved(thing)).filter(on);
|
|
107
|
+
if (map.bounds) {
|
|
108
|
+
const x = Math.max(map.bounds.x + left, 0);
|
|
109
|
+
const z = Math.max(map.bounds.z + top, 0);
|
|
110
|
+
const bounds = {
|
|
111
|
+
x,
|
|
112
|
+
z,
|
|
113
|
+
width: Math.min(map.bounds.x + left + map.bounds.width, width) - x,
|
|
114
|
+
depth: Math.min(map.bounds.z + top + map.bounds.depth, depth) - z
|
|
115
|
+
};
|
|
116
|
+
if (bounds.width > 0 && bounds.depth > 0) copy.bounds = bounds;
|
|
117
|
+
else delete copy.bounds;
|
|
118
|
+
}
|
|
119
|
+
const resize = {
|
|
120
|
+
sides,
|
|
121
|
+
width,
|
|
122
|
+
depth,
|
|
123
|
+
moved,
|
|
124
|
+
on,
|
|
125
|
+
inside,
|
|
126
|
+
shape
|
|
127
|
+
};
|
|
128
|
+
for (const resizer of resizers) resizer(copy, resize);
|
|
129
|
+
return copy;
|
|
130
|
+
}
|
|
131
|
+
/** A thing of a game's own kind, as `mapThings` reads one: an id, and a place */
|
|
132
|
+
var isThing = (thing) => typeof thing === "object" && thing !== null && Number.isInteger(thing.id) && Number.isFinite(thing.x) && Number.isFinite(thing.z);
|
|
133
|
+
//#endregion
|
|
134
|
+
export { resizeMap };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=resize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize.js","names":[],"sources":["../../src/map/resize.ts"],"sourcesContent":["/*\n * A map grown or cut on its sides (design review E8a: `map.ts` in parts)\n */\nimport type { AreaShape } from '../areas'\nimport { clamp, type Vec2 } from '../math'\nimport { cloneMap } from './file'\nimport { fieldsOf } from './schema'\nimport type { MapThing } from '../mapFields'\nimport { type GameMap, type MapRegion, MAX_MAP_SIZE, MIN_MAP_SIZE } from './types'\n\n/**\n * How many cells a map gains on each side, or loses where it is less than 0 (see `resizeMap`)\n *\n * @beta\n */\nexport interface MapSides {\n\t/** Towards x 0, and towards x of the width */\n\tleft: number\n\t/** Cells gained on the right, towards x of the width; less than 0 cuts them */\n\tright: number\n\t/** Towards z 0, and towards z of the depth */\n\ttop: number\n\t/** Cells gained on the bottom, towards z of the depth; less than 0 cuts them */\n\tbottom: number\n}\n\n/**\n * How a map is being grown or cut (`resizeMap`), for what moves along with it: where a place goes, whether it is\n * still on the map, and a shape moved and cut to the map\n *\n * @beta\n */\nexport interface MapResize {\n\t/** The sides the map is grown or cut on */\n\treadonly sides: MapSides\n\t/** The new size, in cells */\n\treadonly width: number\n\t/** The new depth of the map in cells */\n\treadonly depth: number\n\t/** A place where it is on the grown map (the old place, moved by the cells gained on the left and the top) */\n\tmoved<P extends Vec2>(place: P): P\n\t/** Whether a place is on the grown map */\n\ton(place: Vec2): boolean\n\t/** A place kept on the grown map: at its edge where it is past it */\n\tinside<P extends Vec2>(place: P): P\n\t/** A shape moved: a circle while its middle is on the map, what is left of a rectangle on it; none when it is gone */\n\tshape<S extends AreaShape>(shape: S): S | undefined\n}\n\n/**\n * What moves along with a map grown or cut, of what others than the engine keep with it (`resizeMap`): the client's\n * looks under `map.environment` (`mapLooksResizer` of `@v12-engine/client`), the editor's own. Changes the copy it is\n * given, as `resizeMap` hands it on\n *\n * @beta\n */\nexport type MapResizer = (map: GameMap, resize: MapResize) => void\n\n/**\n * A map grown or cut on any side: the ground, cliffs, water and paint go on as they were at the old edge where it\n * grows; everything on it moves along, and what is no longer on the map is gone. The map itself is left as it was.\n * What the engine keeps moves (objects, camps, regions, points, paths, doodads, cameras, the players' starts, the bounds,\n * the game's own kinds' things in `data`); what others keep moves with the `resizers` given (the client's looks:\n * `mapLooksResizer`)\n *\n * @beta\n */\nexport function resizeMap(map: GameMap, sides: MapSides, resizers: readonly MapResizer[] = []): GameMap {\n\tconst { left, right, top, bottom } = sides\n\tconst width = map.width + left + right\n\tconst depth = map.depth + top + bottom\n\tif (width < MIN_MAP_SIZE || depth < MIN_MAP_SIZE || width > MAX_MAP_SIZE || depth > MAX_MAP_SIZE)\n\t\tthrow new Error(`A map is between ${MIN_MAP_SIZE} and ${MAX_MAP_SIZE} cells each way, not ${width} × ${depth}`)\n\tconst copy = cloneMap(map)\n\t// each new cell, or corner of the ground, takes what is nearest to it on the old map\n\tconst layer = <T extends Float32Array | Uint8Array>(old: T, oldRow: number, oldColumn: number, row: number, column: number): T => {\n\t\tconst out = new (old.constructor as new (length: number) => T)(row * column)\n\t\tfor (let z = 0; z < column; z++) {\n\t\t\tconst from = clamp(z - top, 0, oldColumn - 1) * oldRow\n\t\t\tfor (let x = 0; x < row; x++) out[z * row + x] = old[from + clamp(x - left, 0, oldRow - 1)]\n\t\t}\n\t\treturn out\n\t}\n\tcopy.width = width\n\tcopy.depth = depth\n\t// every layer the map's table has (`MAP_FIELDS`): by corner for the heights, by cell for the rest\n\tconst grown = <T extends Float32Array | Uint8Array>(old: T, perVertex = false): T =>\n\t\tperVertex ? layer(old, map.width + 1, map.depth + 1, width + 1, depth + 1) : layer(old, map.width, map.depth, width, depth)\n\tconst into = copy as unknown as Record<string, unknown>\n\tfor (const field of fieldsOf('layer', 'mask', 'layers')) {\n\t\tconst value = map[field.key] as Float32Array | Uint8Array | Record<string, Uint8Array> | undefined\n\t\tif (!value) continue\n\t\tinto[field.key] =\n\t\t\tfield.kind === 'layers'\n\t\t\t\t? Object.fromEntries(Object.entries(value as Record<string, Uint8Array>).map(([id, cells]) => [id, grown(cells)]))\n\t\t\t\t: grown(value as Float32Array | Uint8Array, field.perVertex)\n\t}\n\tconst on = (p: Vec2) => p.x >= 0 && p.z >= 0 && p.x <= width && p.z <= depth\n\tconst moved = <P extends Vec2>(p: P): P => ({ ...p, x: p.x + left, z: p.z + top })\n\tconst inside = <P extends Vec2>(p: P): P => ({ ...p, x: clamp(p.x, 0, width), z: clamp(p.z, 0, depth) })\n\tconst shape = <S extends AreaShape>(shape: S): S | undefined => {\n\t\t// a circle, and a polygon (by its corners round its middle): where its middle is\n\t\tif (shape.kind !== 'rect') {\n\t\t\tconst center = moved(shape)\n\t\t\treturn on(center) ? center : undefined\n\t\t}\n\t\t// a rectangle is by its middle: what is left of it on the map, and its middle again\n\t\tconst x0 = Math.max(shape.x - shape.width / 2 + left, 0)\n\t\tconst z0 = Math.max(shape.z - shape.depth / 2 + top, 0)\n\t\tconst x1 = Math.min(shape.x + shape.width / 2 + left, width)\n\t\tconst z1 = Math.min(shape.z + shape.depth / 2 + top, depth)\n\t\treturn x1 > x0 && z1 > z0 ? { ...shape, x: (x0 + x1) / 2, z: (z0 + z1) / 2, width: x1 - x0, depth: z1 - z0 } : undefined\n\t}\n\tcopy.objects = copy.objects.map((object) => ({ ...object, ...moved(object) })).filter(on)\n\tcopy.camps = copy.camps.map((camp) => ({ ...camp, ...moved(camp) })).filter(on)\n\tcopy.points = copy.points.map((point) => ({ ...point, ...moved(point) })).filter(on)\n\tcopy.doodads = copy.doodads.map((doodad) => ({ ...doodad, ...moved(doodad) })).filter(on)\n\tcopy.cameras = copy.cameras.map((camera) => ({ ...camera, ...inside(moved(camera)) }))\n\tcopy.paths = copy.paths.map((path) => ({ ...path, points: path.points.map((p) => inside(moved(p))) }))\n\tcopy.players = copy.players.map((player) => {\n\t\tif (!player.start) return player\n\t\tconst start = moved(player.start)\n\t\tconst { start: _, ...rest } = player\n\t\treturn on(start) ? { ...player, start } : rest\n\t})\n\tcopy.regions = copy.regions.flatMap((region): MapRegion[] => {\n\t\tconst moved = shape(region.shape)\n\t\treturn moved ? [{ ...region, shape: moved }] : []\n\t})\n\t// the game's own kinds' things (`MapThing`, kept in `data` under each kind): a list of them moves as the engine's do\n\tfor (const [kind, kept] of Object.entries(copy.data)) {\n\t\tif (Array.isArray(kept) && kept.length && kept.every(isThing)) copy.data[kind] = kept.map((thing) => moved(thing)).filter(on)\n\t}\n\tif (map.bounds) {\n\t\tconst x = Math.max(map.bounds.x + left, 0)\n\t\tconst z = Math.max(map.bounds.z + top, 0)\n\t\tconst bounds = {\n\t\t\tx,\n\t\t\tz,\n\t\t\twidth: Math.min(map.bounds.x + left + map.bounds.width, width) - x,\n\t\t\tdepth: Math.min(map.bounds.z + top + map.bounds.depth, depth) - z\n\t\t}\n\t\tif (bounds.width > 0 && bounds.depth > 0) copy.bounds = bounds\n\t\telse delete copy.bounds\n\t}\n\tconst resize: MapResize = { sides, width, depth, moved, on, inside, shape }\n\tfor (const resizer of resizers) resizer(copy, resize)\n\treturn copy\n}\n\n/** A thing of a game's own kind, as `mapThings` reads one: an id, and a place */\nconst isThing = (thing: unknown): thing is MapThing =>\n\ttypeof thing === 'object' &&\n\tthing !== null &&\n\tNumber.isInteger((thing as MapThing).id) &&\n\tNumber.isFinite((thing as MapThing).x) &&\n\tNumber.isFinite((thing as MapThing).z)\n"],"mappings":";;;;;;;;;;;;;;AAmEA,SAAgB,UAAU,KAAc,OAAiB,WAAkC,CAAC,GAAY;CACvG,MAAM,EAAE,MAAM,OAAO,KAAK,WAAW;CACrC,MAAM,QAAQ,IAAI,QAAQ,OAAO;CACjC,MAAM,QAAQ,IAAI,QAAQ,MAAM;CAChC,IAAI,QAAA,KAAwB,QAAA,KAAwB,QAAA,OAAwB,QAAA,KAC3E,MAAM,IAAI,MAAM,kDAA4E,MAAM,KAAK,OAAO;CAC/G,MAAM,OAAO,SAAS,GAAG;CAEzB,MAAM,SAA8C,KAAQ,QAAgB,WAAmB,KAAa,WAAsB;EACjI,MAAM,MAAM,IAAK,IAAI,YAA0C,MAAM,MAAM;EAC3E,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;GAChC,MAAM,OAAO,MAAM,IAAI,KAAK,GAAG,YAAY,CAAC,IAAI;GAChD,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,OAAO,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC;EAC1F;EACA,OAAO;CACR;CACA,KAAK,QAAQ;CACb,KAAK,QAAQ;CAEb,MAAM,SAA8C,KAAQ,YAAY,UACvE,YAAY,MAAM,KAAK,IAAI,QAAQ,GAAG,IAAI,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,IAAI,MAAM,KAAK,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK;CAC3H,MAAM,OAAO;CACb,KAAK,MAAM,SAAS,SAAS,SAAS,QAAQ,QAAQ,GAAG;EACxD,MAAM,Q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AAI,IAAI,QAAQ;EACf,MAAM,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,MAAM,CAAC;EACzC,MAAM,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC;EACxC,MAAM,SAAS;GACd;GACA;GACA,OAAO,KAAK,IAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,IAAI;GACjE,OAAO,KAAK,IAAI,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO,OAAO,KAAK,IAAI;EACjE;EACA,IAAI,OAAO,QAAQ,KAAK,OAAO,QAAQ,GAAG,KAAK,SAAS;OACnD,OAAO,KAAK;CAClB;CACA,MAAM,SAAoB;EAAE;EAAO;EAAO;EAAO;EAAO;EAAI;EAAQ;CAAM;CAC1E,KAAK,MAAM,WAAW,UAAU,QAAQ,MAAM,MAAM;CACpD,OAAO;AACR;;AAGA,IAAM,WAAW,UAChB,OAAO,UAAU,YACjB,UAAU,QACV,OAAO,UAAW,MAAmB,EAAE,KACvC,OAAO,SAAU,MAAmB,CAAC,KACrC,OAAO,SAAU,MAAmB,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
//#region src/map/schema.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every field of a map, in the order its file has them (`format` before them, what the reader does not know of the
|
|
4
|
+
* file before that). `satisfies` checks that none of `GameMap` is left out
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
var MAP_FIELDS = [
|
|
9
|
+
{
|
|
10
|
+
key: "name",
|
|
11
|
+
kind: "text",
|
|
12
|
+
written: "always",
|
|
13
|
+
empty: () => "Untitled"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: "description",
|
|
17
|
+
kind: "text",
|
|
18
|
+
written: "always",
|
|
19
|
+
empty: () => ""
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: "game",
|
|
23
|
+
kind: "text",
|
|
24
|
+
written: "defined"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "width",
|
|
28
|
+
kind: "number",
|
|
29
|
+
written: "always",
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: "depth",
|
|
34
|
+
kind: "number",
|
|
35
|
+
written: "always",
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "cliffHeight",
|
|
40
|
+
kind: "number",
|
|
41
|
+
written: "always",
|
|
42
|
+
empty: () => 3
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "ground",
|
|
46
|
+
kind: "layer",
|
|
47
|
+
written: "always",
|
|
48
|
+
required: true,
|
|
49
|
+
perVertex: true,
|
|
50
|
+
what: "the ground"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "levels",
|
|
54
|
+
kind: "layer",
|
|
55
|
+
written: "always",
|
|
56
|
+
required: true,
|
|
57
|
+
what: "the levels"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: "ramps",
|
|
61
|
+
kind: "layer",
|
|
62
|
+
written: "always",
|
|
63
|
+
required: true,
|
|
64
|
+
what: "the ramps"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "water",
|
|
68
|
+
kind: "layer",
|
|
69
|
+
written: "always",
|
|
70
|
+
required: true,
|
|
71
|
+
what: "the water"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "tiles",
|
|
75
|
+
kind: "layer",
|
|
76
|
+
written: "always",
|
|
77
|
+
required: true,
|
|
78
|
+
what: "the paint"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: "cells",
|
|
82
|
+
kind: "layers",
|
|
83
|
+
written: "filled"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "pathing",
|
|
87
|
+
kind: "mask",
|
|
88
|
+
written: "filled",
|
|
89
|
+
what: "what is kept off cells"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "tileset",
|
|
93
|
+
kind: "names",
|
|
94
|
+
written: "always",
|
|
95
|
+
required: true,
|
|
96
|
+
what: "the tileset"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: "players",
|
|
100
|
+
kind: "list",
|
|
101
|
+
written: "always",
|
|
102
|
+
required: true,
|
|
103
|
+
byId: true
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
key: "objects",
|
|
107
|
+
kind: "list",
|
|
108
|
+
written: "always",
|
|
109
|
+
required: true,
|
|
110
|
+
byId: true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "camps",
|
|
114
|
+
kind: "list",
|
|
115
|
+
written: "always",
|
|
116
|
+
required: true,
|
|
117
|
+
byId: true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: "regions",
|
|
121
|
+
kind: "list",
|
|
122
|
+
written: "filled",
|
|
123
|
+
byId: true,
|
|
124
|
+
empty: () => []
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
key: "points",
|
|
128
|
+
kind: "list",
|
|
129
|
+
written: "filled",
|
|
130
|
+
byId: true,
|
|
131
|
+
empty: () => []
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "paths",
|
|
135
|
+
kind: "list",
|
|
136
|
+
written: "filled",
|
|
137
|
+
byId: true,
|
|
138
|
+
empty: () => []
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
key: "doodads",
|
|
142
|
+
kind: "list",
|
|
143
|
+
written: "filled",
|
|
144
|
+
byId: true,
|
|
145
|
+
empty: () => []
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
key: "cameras",
|
|
149
|
+
kind: "list",
|
|
150
|
+
written: "filled",
|
|
151
|
+
byId: true,
|
|
152
|
+
empty: () => []
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: "randomGroups",
|
|
156
|
+
kind: "list",
|
|
157
|
+
written: "filled"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
key: "itemTables",
|
|
161
|
+
kind: "list",
|
|
162
|
+
written: "filled"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
key: "forces",
|
|
166
|
+
kind: "list",
|
|
167
|
+
written: "filled"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "races",
|
|
171
|
+
kind: "names",
|
|
172
|
+
written: "filled"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
key: "author",
|
|
176
|
+
kind: "text",
|
|
177
|
+
written: "filled"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
key: "silence",
|
|
181
|
+
kind: "names",
|
|
182
|
+
written: "filled"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: "meantFor",
|
|
186
|
+
kind: "text",
|
|
187
|
+
written: "filled"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: "explored",
|
|
191
|
+
kind: "boolean",
|
|
192
|
+
written: "defined"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "loading",
|
|
196
|
+
kind: "text",
|
|
197
|
+
written: "filled"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
key: "preview",
|
|
201
|
+
kind: "text",
|
|
202
|
+
written: "filled"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: "environment",
|
|
206
|
+
kind: "object",
|
|
207
|
+
written: "filled"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
key: "definitions",
|
|
211
|
+
kind: "object",
|
|
212
|
+
written: "filled",
|
|
213
|
+
plain: true
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: "generated",
|
|
217
|
+
kind: "object",
|
|
218
|
+
written: "defined"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "day",
|
|
222
|
+
kind: "object",
|
|
223
|
+
written: "filled"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
key: "bounds",
|
|
227
|
+
kind: "object",
|
|
228
|
+
written: "defined"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
key: "data",
|
|
232
|
+
kind: "object",
|
|
233
|
+
written: "filled",
|
|
234
|
+
empty: () => ({}),
|
|
235
|
+
plain: true
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
key: "editor",
|
|
239
|
+
kind: "object",
|
|
240
|
+
written: "filled",
|
|
241
|
+
plain: true
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
/** The fields as specs, for what walks them */
|
|
245
|
+
var MAP_FIELD_SPECS = MAP_FIELDS;
|
|
246
|
+
/** What a reader of this format knows in a file: `format` and every field. The rest is carried along (`GameMap.extra`) */
|
|
247
|
+
var KNOWN = /* @__PURE__ */ new Set(["format", ...MAP_FIELDS.map((field) => field.key)]);
|
|
248
|
+
/** The fields of a kind */
|
|
249
|
+
var fieldsOf = (...kinds) => MAP_FIELD_SPECS.filter((field) => kinds.includes(field.kind));
|
|
250
|
+
/** The lists of things with ids: merged thing by thing (`mergeMaps`), an entry to a line (`mapText`) */
|
|
251
|
+
var BY_ID = MAP_FIELD_SPECS.filter((field) => field.byId).map((field) => field.key);
|
|
252
|
+
/** The layers of the ground every map has: merged cell by cell (`mergeMaps`), a row to a line (`mapText`) */
|
|
253
|
+
var LAYERS = fieldsOf("layer").map((field) => field.key);
|
|
254
|
+
//#endregion
|
|
255
|
+
export { BY_ID, KNOWN, LAYERS, MAP_FIELDS, MAP_FIELD_SPECS, fieldsOf };
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=schema.js.map
|