@v12-engine/engine 0.1.0 → 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,275 @@
|
|
|
1
|
+
import { cellsChanged, cellsSeen } from "./engineEvents.js";
|
|
2
|
+
import { CellMemory, teamMemory } from "./session/memory.js";
|
|
3
|
+
import { replicateEvent } from "./replication.js";
|
|
4
|
+
import { inShape, shapeBounds } from "./areas.js";
|
|
5
|
+
import { foliageStyleProblem } from "./foliage.js";
|
|
6
|
+
//#region src/cellLayers.ts
|
|
7
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
/**
|
|
9
|
+
* Why what a `data.json` says of the game's layers of cells (`GameData.cellLayers`) is not right, where it first is
|
|
10
|
+
* not: nothing when it is
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
function dataCellLayersProblem(said) {
|
|
15
|
+
if (!isRecord(said)) return "cellLayers is no object by layer";
|
|
16
|
+
for (const [layer, entry] of Object.entries(said)) {
|
|
17
|
+
if (!isRecord(entry)) return `cellLayers.${layer} is no object`;
|
|
18
|
+
const other = Object.keys(entry).find((key) => key !== "values");
|
|
19
|
+
if (other) return `cellLayers.${layer}.${other} is nothing a layer says as data (values)`;
|
|
20
|
+
if (entry.values === void 0) continue;
|
|
21
|
+
if (!isRecord(entry.values)) return `cellLayers.${layer}.values is no object by value`;
|
|
22
|
+
for (const [key, value] of Object.entries(entry.values)) {
|
|
23
|
+
const what = `cellLayers.${layer}.values.${key}`;
|
|
24
|
+
if (!/^[1-9]\d{0,2}$/.test(key) || Number(key) > 255) return `${what}: a value is a number from 1 to 255`;
|
|
25
|
+
if (value === false) continue;
|
|
26
|
+
if (!isRecord(value)) return `${what} is no object, or false for none`;
|
|
27
|
+
for (const [field, held] of Object.entries(value)) if (field === "name") {
|
|
28
|
+
if (typeof held !== "string" || !held) return `${what}.name is no word`;
|
|
29
|
+
} else if (field === "color") {
|
|
30
|
+
if (!Array.isArray(held) || held.length !== 3 || !held.every((part) => typeof part === "number" && part >= 0 && part <= 1)) return `${what}.color is no colour, [r, g, b] from 0 to 1`;
|
|
31
|
+
} else if (field === "foliage") {
|
|
32
|
+
const wrong = foliageStyleProblem(held, `${what}.foliage`);
|
|
33
|
+
if (wrong) return wrong;
|
|
34
|
+
} else return `${what}.${field} is nothing a value says (name, color, foliage)`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A game's layers of cells with what its data says of them laid over (`DataCellLayer`): each value over the layer's of
|
|
40
|
+
* the same number, field by field (its `foliage` style too), one the layer has not added (named `Style <n>` where it
|
|
41
|
+
* says no name), one said `false` taken out; in the order of their numbers. A layer that lists no values has its one
|
|
42
|
+
* value, 1, first. A layer the game has not is left out. The layers given are not changed
|
|
43
|
+
*
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
function layCellLayerData(layers, said) {
|
|
47
|
+
return layers.map((def) => {
|
|
48
|
+
const over = said[def.id]?.values;
|
|
49
|
+
if (!over) return def;
|
|
50
|
+
const values = new Map(cellLayerValues(def).map((each) => [each.value, each]));
|
|
51
|
+
for (const [key, entry] of Object.entries(over)) {
|
|
52
|
+
const value = Number(key);
|
|
53
|
+
if (entry === false) {
|
|
54
|
+
values.delete(value);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const under = values.get(value) ?? {
|
|
58
|
+
value,
|
|
59
|
+
name: `Style ${value}`
|
|
60
|
+
};
|
|
61
|
+
const foliage = under.foliage || entry.foliage ? {
|
|
62
|
+
...under.foliage,
|
|
63
|
+
...entry.foliage
|
|
64
|
+
} : void 0;
|
|
65
|
+
values.set(value, {
|
|
66
|
+
...under,
|
|
67
|
+
...entry,
|
|
68
|
+
value,
|
|
69
|
+
...foliage && { foliage }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...def,
|
|
74
|
+
values: [...values.values()].sort((a, b) => a.value - b.value)
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Typed help for writing a layer of cells
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
var defineCellLayer = (def) => def;
|
|
84
|
+
/**
|
|
85
|
+
* The values a layer is painted with, as the editor offers them: its own, or 1, named after the layer
|
|
86
|
+
*
|
|
87
|
+
* @beta
|
|
88
|
+
*/
|
|
89
|
+
var cellLayerValues = (def) => def.values ?? [{
|
|
90
|
+
value: 1,
|
|
91
|
+
name: def.name
|
|
92
|
+
}];
|
|
93
|
+
/**
|
|
94
|
+
* The cells of a terrain in a shape, as indices into its layers: the cells whose middle is in it
|
|
95
|
+
*
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
function cellsIn(terrain, shape) {
|
|
99
|
+
const { width, depth } = terrain;
|
|
100
|
+
const { x0, z0, x1, z1 } = shapeBounds(shape);
|
|
101
|
+
const cells = [];
|
|
102
|
+
for (let cz = Math.max(Math.floor(z0), 0); cz < Math.min(Math.ceil(z1), depth); cz++) for (let cx = Math.max(Math.floor(x0), 0); cx < Math.min(Math.ceil(x1), width); cx++) if (inShape(shape, {
|
|
103
|
+
x: cx + .5,
|
|
104
|
+
z: cz + .5
|
|
105
|
+
})) cells.push(cz * width + cx);
|
|
106
|
+
return cells;
|
|
107
|
+
}
|
|
108
|
+
/** Whether a team sees a cell of the ground: its middle */
|
|
109
|
+
var seesCell = (world, team, cell) => world.fog.isVisible(team, cell % world.terrain.width + .5, Math.floor(cell / world.terrain.width) + .5);
|
|
110
|
+
/** What a team sees of the ground now, a byte a cell: none where it sees all of it (or the fog has nothing of it, which `seesCell` says) */
|
|
111
|
+
var sightOf = (world, team) => world.fog.isRevealed(team) ? void 0 : world.fog.cells(team)?.visible;
|
|
112
|
+
/**
|
|
113
|
+
* Cells of a layer the rules set (`world.setCells`), each with what it was: what each team that does not see a cell
|
|
114
|
+
* keeps of it as it last knew it (`TeamMemory.cells`, a `CellMemory` a layer), to be told when it comes into sight. A
|
|
115
|
+
* cell set back to what the team knows is nothing to tell; one the team sees is told now. A fire changes cells every
|
|
116
|
+
* tick: each team's sight is read as its grid, and nothing is made but a layer's memory the first time
|
|
117
|
+
*/
|
|
118
|
+
function rememberUnseenCells(world, layer, cells, was, value) {
|
|
119
|
+
const memories = world.state(teamMemory);
|
|
120
|
+
const size = world.terrain.width * world.terrain.depth;
|
|
121
|
+
for (const team of world.fog.teams) {
|
|
122
|
+
let known = memories[team]?.cells?.[layer]?.ready(size);
|
|
123
|
+
const sight = sightOf(world, team);
|
|
124
|
+
const all = !sight && world.fog.isRevealed(team);
|
|
125
|
+
for (let i = 0; i < cells.length; i++) {
|
|
126
|
+
const cell = cells[i];
|
|
127
|
+
if (all || (sight ? sight[cell] !== 0 : seesCell(world, team, cell))) {
|
|
128
|
+
known?.forget(cell);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const knew = known?.has(cell) ? known.known[cell] : was[i];
|
|
132
|
+
if (knew === value) {
|
|
133
|
+
known?.forget(cell);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!known) {
|
|
137
|
+
const memory = memories[team] ??= {
|
|
138
|
+
structures: {},
|
|
139
|
+
cleared: []
|
|
140
|
+
};
|
|
141
|
+
known = ((memory.cells ??= {})[layer] ??= new CellMemory()).ready(size);
|
|
142
|
+
}
|
|
143
|
+
known.remember(cell, knew);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Of what a team sees as bits (`FogOfWar.sightBits`, rows of `words` words), the 32 cells from `first` on, in order of
|
|
149
|
+
* the cells as a layer's memory holds them (`CellMemory.held`): the rows they are in, each piece taken from a word or two
|
|
150
|
+
*/
|
|
151
|
+
function sightWord(sight, words, width, depth, first) {
|
|
152
|
+
let z = Math.floor(first / width);
|
|
153
|
+
let x = first - z * width;
|
|
154
|
+
let word = 0;
|
|
155
|
+
for (let filled = 0; filled < 32 && z < depth; z++, x = 0) {
|
|
156
|
+
const count = Math.min(32 - filled, width - x);
|
|
157
|
+
const at = z * words + (x >>> 5);
|
|
158
|
+
const shift = x & 31;
|
|
159
|
+
let piece = sight[at] >>> shift;
|
|
160
|
+
if (shift !== 0 && shift + count > 32) piece |= sight[at + 1] << 32 - shift;
|
|
161
|
+
if (count < 32) piece &= (1 << count) - 1;
|
|
162
|
+
word |= piece << filled;
|
|
163
|
+
filled += count;
|
|
164
|
+
}
|
|
165
|
+
return word;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The cells changed out of a team's sight that are in it now (`TeamMemory.cells`), told to the team as they are now
|
|
169
|
+
* (`cellsSeen`, in order of the cells) and forgotten: after the fog is worked out again (`fogSystem`). A layer's
|
|
170
|
+
* memory is gone through a word of 32 cells at a time, those it remembers none of passed over, each held against what
|
|
171
|
+
* the team sees of those 32 as bits (`FogOfWar.sightBits`) where the fog has them, else cell by cell
|
|
172
|
+
*/
|
|
173
|
+
function tellCellsInSight(world) {
|
|
174
|
+
if (!world.states.has(teamMemory)) return;
|
|
175
|
+
const memories = world.state(teamMemory);
|
|
176
|
+
const { width, depth } = world.terrain;
|
|
177
|
+
const words = Math.ceil(width / 32);
|
|
178
|
+
for (const [key, memory] of Object.entries(memories)) {
|
|
179
|
+
if (!memory.cells) continue;
|
|
180
|
+
const team = Number(key);
|
|
181
|
+
const all = world.fog.isRevealed(team);
|
|
182
|
+
const bits = all ? void 0 : world.fog.sightBits(team);
|
|
183
|
+
const sight = all || bits ? void 0 : sightOf(world, team);
|
|
184
|
+
for (const [layer, known] of Object.entries(memory.cells)) {
|
|
185
|
+
if (known.count === 0) continue;
|
|
186
|
+
const { held } = known.ready(width * depth);
|
|
187
|
+
let seen;
|
|
188
|
+
for (let word = 0; word < held.length; word++) {
|
|
189
|
+
let found = held[word];
|
|
190
|
+
if (found === 0) continue;
|
|
191
|
+
if (!all && bits) found &= sightWord(bits, words, width, depth, word << 5);
|
|
192
|
+
while (found !== 0) {
|
|
193
|
+
const low = found & -found;
|
|
194
|
+
const cell = (word << 5) + 31 - Math.clz32(low);
|
|
195
|
+
found ^= low;
|
|
196
|
+
if (all || bits || (sight ? sight[cell] !== 0 : seesCell(world, team, cell))) (seen ??= []).push(cell);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!seen) continue;
|
|
200
|
+
const byValue = /* @__PURE__ */ new Map();
|
|
201
|
+
for (const cell of seen) {
|
|
202
|
+
known.forget(cell);
|
|
203
|
+
const value = world.terrain.cellAt(layer, cell % width + .5, Math.floor(cell / width) + .5);
|
|
204
|
+
let cells = byValue.get(value);
|
|
205
|
+
if (!cells) byValue.set(value, cells = []);
|
|
206
|
+
cells.push(cell);
|
|
207
|
+
}
|
|
208
|
+
for (const [value, cells] of byValue) world.events.emit(cellsSeen, {
|
|
209
|
+
team,
|
|
210
|
+
layer,
|
|
211
|
+
cells,
|
|
212
|
+
value
|
|
213
|
+
});
|
|
214
|
+
if (known.count === 0) delete memory.cells[layer];
|
|
215
|
+
}
|
|
216
|
+
if (Object.keys(memory.cells).length === 0) delete memory.cells;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* What a team remembers of cells the rules changed out of its sight (`TeamMemory.cells`), as a save keeps it: by
|
|
221
|
+
* layer, the value it last knew by cell, a copy. `undefined` where it remembers none; a layer it remembered and has
|
|
222
|
+
* forgotten all of may stay, empty, until the team's next look
|
|
223
|
+
*
|
|
224
|
+
* @beta
|
|
225
|
+
*/
|
|
226
|
+
function rememberedCells(world, team) {
|
|
227
|
+
const cells = world.states.has(teamMemory) ? world.state(teamMemory)[team]?.cells : void 0;
|
|
228
|
+
if (!cells) return void 0;
|
|
229
|
+
const size = world.terrain.width * world.terrain.depth;
|
|
230
|
+
return Object.fromEntries(Object.entries(cells).map(([layer, known]) => [layer, known.ready(size).toRecord()]));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The world's ground as a team knows it: its layers' cells as the team last saw those changed out of its sight
|
|
234
|
+
* (`TeamMemory.cells`). The ground itself where the team knows all of it, or for an observer (no team)
|
|
235
|
+
*/
|
|
236
|
+
function groundKnownTo(world, team) {
|
|
237
|
+
const { terrain } = world;
|
|
238
|
+
const known = team === void 0 || !world.states.has(teamMemory) ? void 0 : world.state(teamMemory)[team]?.cells;
|
|
239
|
+
if (!known) return terrain;
|
|
240
|
+
const size = terrain.width * terrain.depth;
|
|
241
|
+
const cells = { ...terrain.cells };
|
|
242
|
+
for (const [layer, memory] of Object.entries(known)) {
|
|
243
|
+
const values = cells[layer] = new Uint8Array(cells[layer] ?? size);
|
|
244
|
+
memory.ready(size).forEach((cell, was) => values[cell] = was);
|
|
245
|
+
}
|
|
246
|
+
return Object.create(terrain, { cells: { value: cells } });
|
|
247
|
+
}
|
|
248
|
+
/** Whether the seat's player is told of cells their team sees changed, rather than as they come into sight: an observer is told of all */
|
|
249
|
+
var toldNow = (view, cell) => view.observer || seesCell(view.world, view.team, cell);
|
|
250
|
+
/** A layer's cells changed (`world.setCells`): to those who see them. The others are told as they come into sight (`toldCellsSeen`) */
|
|
251
|
+
var toldCells = replicateEvent(cellsChanged, "cells", ({ layer, cells, value, over }, view) => {
|
|
252
|
+
const at = cells.filter((cell) => toldNow(view, cell));
|
|
253
|
+
return at.length ? {
|
|
254
|
+
type: "cells",
|
|
255
|
+
layer,
|
|
256
|
+
at,
|
|
257
|
+
value,
|
|
258
|
+
...over !== void 0 && { over: Math.round(over * 100) / 100 }
|
|
259
|
+
} : void 0;
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* Cells changed out of a team's sight came into it (`tellCellsInSight`): to the team, as they are now, said to be seen
|
|
263
|
+
* so (`seen`: a screen does not show them changing now). An observer was told already
|
|
264
|
+
*/
|
|
265
|
+
var toldCellsSeen = replicateEvent(cellsSeen, "cells", ({ team, layer, cells, value }, view) => !view.observer && view.team === team ? {
|
|
266
|
+
type: "cells",
|
|
267
|
+
layer,
|
|
268
|
+
at: [...cells],
|
|
269
|
+
value,
|
|
270
|
+
seen: true
|
|
271
|
+
} : void 0);
|
|
272
|
+
//#endregion
|
|
273
|
+
export { cellLayerValues, cellsIn, dataCellLayersProblem, defineCellLayer, groundKnownTo, layCellLayerData, rememberUnseenCells, rememberedCells, tellCellsInSight, toldCells, toldCellsSeen };
|
|
274
|
+
|
|
275
|
+
//# sourceMappingURL=cellLayers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellLayers.js","names":[],"sources":["../src/cellLayers.ts"],"sourcesContent":["import { cellsChanged, cellsSeen } from '#engine/engineEvents'\nimport { type AreaShape, inShape, shapeBounds } from './areas'\nimport type { Terrain } from './terrain'\nimport type { World } from './world'\nimport { type FoliageStyleDef, foliageStyleProblem } from './foliage'\nimport { replicateEvent, type SessionView } from './replication'\nimport { CellMemory, teamMemory } from './session/memory'\n\n/**\n * A layer of cells a game paints its maps with, for its rules to read: where the bushes are, what burns, where a\n * lane runs. A value per cell (0 to 255, 0 being none), kept with the map (`GameMap.cells`), in the world's ground\n * (`Terrain.cells`, read with `terrain.cellAt`), its saves and what each player is sent. The rules change it while\n * the game runs with `world.setCells`: the players who see a cell are told at once, the others as it comes into their\n * sight (`TeamMemory.cells`), so a change in the dark is not given away. The editor paints the layers a game lists\n * (`Rules.cellLayers`), with the values it names\n *\n * @beta\n */\nexport interface CellLayerDef {\n\t/** Its key in `Terrain.cells` and in the map's file */\n\tid: string\n\t/** What the editor calls it */\n\tname: string\n\t/** What it is for, for the editor's tooltip */\n\tdescription?: string\n\t/** The colour the editor shows it in, 0 to 1 each */\n\tcolor?: [number, number, number]\n\t/**\n\t * The values the editor paints with, named: `[{ value: 1, name: 'Bush' }]`. One value, 1, named after the layer when\n\t * left out: a layer of cells that are or are not. Of a layer of grass or bushes, its styles (`CellLayerValue.foliage`)\n\t */\n\tvalues?: CellLayerValue[]\n\t/**\n\t * How fast one on foot goes over a cell of the layer that is not 0, as a multiplier of its speed: a swamp at 0.5. 1\n\t * when left out; a cell of several such layers is slowed by each (`groundSpeedOfCell`)\n\t */\n\tspeed?: number\n}\n\n/**\n * A value a layer of cells is painted with (`CellLayerDef.values`): its number in the cells, what the editor calls it,\n * and, of a layer of grass or bushes, the style it is to the rules\n *\n * @beta\n */\nexport interface CellLayerValue {\n\t/** The value in the cells, 1 to 255 */\n\tvalue: number\n\t/** What the editor calls it */\n\tname: string\n\t/** The colour the editor shows it in, 0 to 1 each: the layer's when left out */\n\tcolor?: [number, number, number]\n\t/**\n\t * Of a layer of grass or bushes (`foliagePack`): what this style is to the rules (`FoliageStyleDef`), whether it\n\t * hides, burns, slows. Over the layer's own (`FoliageLayerOptions.style`)\n\t */\n\tfoliage?: FoliageStyleDef\n}\n\n/**\n * What a `data.json`, or a map's definitions, says of a value of a layer of cells (`DataCellLayer.values`): its name,\n * colour and style, any of them, over the game's value of the same number; one the game has not is a value of its own\n *\n * @beta\n */\nexport type DataCellLayerValue = Partial<Omit<CellLayerValue, 'value'>>\n\n/**\n * What a `data.json` (`GameData.cellLayers`, every map) or a map's definitions (`GameMap.definitions`, that map alone)\n * says of one of the game's layers of cells: its values, by their number, each over the code's (`DataCellLayerValue`),\n * or `false` to take one of the game's out. What the editor writes of a style made or changed there:\n * `{ \"grass\": { \"values\": { \"3\": { \"name\": \"Dry field\", \"foliage\": { \"flammable\": 1 } } } } }`\n *\n * @beta\n */\nexport interface DataCellLayer {\n\t/** The layer's values, by number (1 to 255): each over the game's of that number, a new one, or `false` for none */\n\tvalues?: Record<number, DataCellLayerValue | false>\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Why what a `data.json` says of the game's layers of cells (`GameData.cellLayers`) is not right, where it first is\n * not: nothing when it is\n *\n * @beta\n */\nexport function dataCellLayersProblem(said: unknown): string | undefined {\n\tif (!isRecord(said)) return 'cellLayers is no object by layer'\n\tfor (const [layer, entry] of Object.entries(said)) {\n\t\tif (!isRecord(entry)) return `cellLayers.${layer} is no object`\n\t\tconst other = Object.keys(entry).find((key) => key !== 'values')\n\t\tif (other) return `cellLayers.${layer}.${other} is nothing a layer says as data (values)`\n\t\tif (entry.values === undefined) continue\n\t\tif (!isRecord(entry.values)) return `cellLayers.${layer}.values is no object by value`\n\t\tfor (const [key, value] of Object.entries(entry.values)) {\n\t\t\tconst what = `cellLayers.${layer}.values.${key}`\n\t\t\tif (!/^[1-9]\\d{0,2}$/.test(key) || Number(key) > 255) return `${what}: a value is a number from 1 to 255`\n\t\t\tif (value === false) continue\n\t\t\tif (!isRecord(value)) return `${what} is no object, or false for none`\n\t\t\tfor (const [field, held] of Object.entries(value)) {\n\t\t\t\tif (field === 'name') {\n\t\t\t\t\tif (typeof held !== 'string' || !held) return `${what}.name is no word`\n\t\t\t\t} else if (field === 'color') {\n\t\t\t\t\tif (!Array.isArray(held) || held.length !== 3 || !held.every((part) => typeof part === 'number' && part >= 0 && part <= 1))\n\t\t\t\t\t\treturn `${what}.color is no colour, [r, g, b] from 0 to 1`\n\t\t\t\t} else if (field === 'foliage') {\n\t\t\t\t\tconst wrong = foliageStyleProblem(held, `${what}.foliage`)\n\t\t\t\t\tif (wrong) return wrong\n\t\t\t\t} else return `${what}.${field} is nothing a value says (name, color, foliage)`\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined\n}\n\n/**\n * A game's layers of cells with what its data says of them laid over (`DataCellLayer`): each value over the layer's of\n * the same number, field by field (its `foliage` style too), one the layer has not added (named `Style <n>` where it\n * says no name), one said `false` taken out; in the order of their numbers. A layer that lists no values has its one\n * value, 1, first. A layer the game has not is left out. The layers given are not changed\n *\n * @beta\n */\nexport function layCellLayerData(layers: readonly CellLayerDef[], said: Readonly<Record<string, DataCellLayer>>): CellLayerDef[] {\n\treturn layers.map((def) => {\n\t\tconst over = said[def.id]?.values\n\t\tif (!over) return def\n\t\tconst values = new Map(cellLayerValues(def).map((each) => [each.value, each]))\n\t\tfor (const [key, entry] of Object.entries(over)) {\n\t\t\tconst value = Number(key)\n\t\t\tif (entry === false) {\n\t\t\t\tvalues.delete(value)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst under = values.get(value) ?? { value, name: `Style ${value}` }\n\t\t\tconst foliage = under.foliage || entry.foliage ? { ...under.foliage, ...entry.foliage } : undefined\n\t\t\tvalues.set(value, { ...under, ...entry, value, ...(foliage && { foliage }) })\n\t\t}\n\t\treturn { ...def, values: [...values.values()].sort((a, b) => a.value - b.value) }\n\t})\n}\n\n/**\n * Typed help for writing a layer of cells\n *\n * @public\n */\nexport const defineCellLayer = (def: CellLayerDef): CellLayerDef => def\n\n/**\n * The values a layer is painted with, as the editor offers them: its own, or 1, named after the layer\n *\n * @beta\n */\nexport const cellLayerValues = (def: CellLayerDef): CellLayerValue[] => def.values ?? [{ value: 1, name: def.name }]\n\n/**\n * The cells of a terrain in a shape, as indices into its layers: the cells whose middle is in it\n *\n * @beta\n */\nexport function cellsIn(terrain: Pick<Terrain, 'width' | 'depth'>, shape: AreaShape): number[] {\n\tconst { width, depth } = terrain\n\tconst { x0, z0, x1, z1 } = shapeBounds(shape)\n\tconst cells: number[] = []\n\tfor (let cz = Math.max(Math.floor(z0), 0); cz < Math.min(Math.ceil(z1), depth); cz++) {\n\t\tfor (let cx = Math.max(Math.floor(x0), 0); cx < Math.min(Math.ceil(x1), width); cx++) {\n\t\t\tif (inShape(shape, { x: cx + 0.5, z: cz + 0.5 })) cells.push(cz * width + cx)\n\t\t}\n\t}\n\treturn cells\n}\n\n/** Whether a team sees a cell of the ground: its middle */\nconst seesCell = (world: World, team: number, cell: number): boolean =>\n\tworld.fog.isVisible(team, (cell % world.terrain.width) + 0.5, Math.floor(cell / world.terrain.width) + 0.5)\n\n/** What a team sees of the ground now, a byte a cell: none where it sees all of it (or the fog has nothing of it, which `seesCell` says) */\nconst sightOf = (world: World, team: number): Uint8Array | undefined => (world.fog.isRevealed(team) ? undefined : world.fog.cells(team)?.visible)\n\n/**\n * Cells of a layer the rules set (`world.setCells`), each with what it was: what each team that does not see a cell\n * keeps of it as it last knew it (`TeamMemory.cells`, a `CellMemory` a layer), to be told when it comes into sight. A\n * cell set back to what the team knows is nothing to tell; one the team sees is told now. A fire changes cells every\n * tick: each team's sight is read as its grid, and nothing is made but a layer's memory the first time\n */\nexport function rememberUnseenCells(world: World, layer: string, cells: readonly number[], was: readonly number[], value: number): void {\n\tconst memories = world.state(teamMemory)\n\tconst size = world.terrain.width * world.terrain.depth\n\tfor (const team of world.fog.teams) {\n\t\tlet known = memories[team]?.cells?.[layer]?.ready(size)\n\t\tconst sight = sightOf(world, team)\n\t\tconst all = !sight && world.fog.isRevealed(team)\n\t\tfor (let i = 0; i < cells.length; i++) {\n\t\t\tconst cell = cells[i]\n\t\t\tif (all || (sight ? sight[cell] !== 0 : seesCell(world, team, cell))) {\n\t\t\t\tknown?.forget(cell)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst knew = known?.has(cell) ? known.known[cell] : was[i]\n\t\t\tif (knew === value) {\n\t\t\t\tknown?.forget(cell)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!known) {\n\t\t\t\tconst memory = (memories[team] ??= { structures: {}, cleared: [] })\n\t\t\t\tknown = ((memory.cells ??= {})[layer] ??= new CellMemory()).ready(size)\n\t\t\t}\n\t\t\tknown.remember(cell, knew)\n\t\t}\n\t}\n}\n\n/**\n * Of what a team sees as bits (`FogOfWar.sightBits`, rows of `words` words), the 32 cells from `first` on, in order of\n * the cells as a layer's memory holds them (`CellMemory.held`): the rows they are in, each piece taken from a word or two\n */\nfunction sightWord(sight: Uint32Array, words: number, width: number, depth: number, first: number): number {\n\tlet z = Math.floor(first / width)\n\tlet x = first - z * width\n\tlet word = 0\n\tfor (let filled = 0; filled < 32 && z < depth; z++, x = 0) {\n\t\tconst count = Math.min(32 - filled, width - x)\n\t\tconst at = z * words + (x >>> 5)\n\t\tconst shift = x & 31\n\t\tlet piece = sight[at] >>> shift\n\t\tif (shift !== 0 && shift + count > 32) piece |= sight[at + 1] << (32 - shift)\n\t\tif (count < 32) piece &= (1 << count) - 1\n\t\tword |= piece << filled\n\t\tfilled += count\n\t}\n\treturn word\n}\n\n/**\n * The cells changed out of a team's sight that are in it now (`TeamMemory.cells`), told to the team as they are now\n * (`cellsSeen`, in order of the cells) and forgotten: after the fog is worked out again (`fogSystem`). A layer's\n * memory is gone through a word of 32 cells at a time, those it remembers none of passed over, each held against what\n * the team sees of those 32 as bits (`FogOfWar.sightBits`) where the fog has them, else cell by cell\n */\nexport function tellCellsInSight(world: World): void {\n\tif (!world.states.has(teamMemory)) return\n\tconst memories = world.state(teamMemory)\n\tconst { width, depth } = world.terrain\n\tconst words = Math.ceil(width / 32)\n\tfor (const [key, memory] of Object.entries(memories)) {\n\t\tif (!memory.cells) continue\n\t\tconst team = Number(key)\n\t\tconst all = world.fog.isRevealed(team)\n\t\tconst bits = all ? undefined : world.fog.sightBits(team)\n\t\tconst sight = all || bits ? undefined : sightOf(world, team)\n\t\tfor (const [layer, known] of Object.entries(memory.cells)) {\n\t\t\tif (known.count === 0) continue\n\t\t\tconst { held } = known.ready(width * depth)\n\t\t\tlet seen: number[] | undefined\n\t\t\tfor (let word = 0; word < held.length; word++) {\n\t\t\t\tlet found = held[word]\n\t\t\t\tif (found === 0) continue\n\t\t\t\t// the cells of the word in sight, at once where the fog has them as bits\n\t\t\t\tif (!all && bits) found &= sightWord(bits, words, width, depth, word << 5)\n\t\t\t\twhile (found !== 0) {\n\t\t\t\t\tconst low = found & -found\n\t\t\t\t\tconst cell = (word << 5) + 31 - Math.clz32(low)\n\t\t\t\t\tfound ^= low\n\t\t\t\t\tif (all || bits || (sight ? sight[cell] !== 0 : seesCell(world, team, cell))) (seen ??= []).push(cell)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!seen) continue\n\t\t\tconst byValue = new Map<number, number[]>()\n\t\t\tfor (const cell of seen) {\n\t\t\t\tknown.forget(cell)\n\t\t\t\tconst value = world.terrain.cellAt(layer, (cell % width) + 0.5, Math.floor(cell / width) + 0.5)\n\t\t\t\tlet cells = byValue.get(value)\n\t\t\t\tif (!cells) byValue.set(value, (cells = []))\n\t\t\t\tcells.push(cell)\n\t\t\t}\n\t\t\tfor (const [value, cells] of byValue) world.events.emit(cellsSeen, { team, layer, cells, value })\n\t\t\tif (known.count === 0) delete memory.cells[layer]\n\t\t}\n\t\tif (Object.keys(memory.cells).length === 0) delete memory.cells\n\t}\n}\n\n/**\n * What a team remembers of cells the rules changed out of its sight (`TeamMemory.cells`), as a save keeps it: by\n * layer, the value it last knew by cell, a copy. `undefined` where it remembers none; a layer it remembered and has\n * forgotten all of may stay, empty, until the team's next look\n *\n * @beta\n */\nexport function rememberedCells(world: World, team: number): Record<string, Record<number, number>> | undefined {\n\tconst cells = world.states.has(teamMemory) ? world.state(teamMemory)[team]?.cells : undefined\n\tif (!cells) return undefined\n\tconst size = world.terrain.width * world.terrain.depth\n\treturn Object.fromEntries(Object.entries(cells).map(([layer, known]) => [layer, known.ready(size).toRecord()]))\n}\n\n/**\n * The world's ground as a team knows it: its layers' cells as the team last saw those changed out of its sight\n * (`TeamMemory.cells`). The ground itself where the team knows all of it, or for an observer (no team)\n */\nexport function groundKnownTo(world: World, team: number | undefined): Terrain {\n\tconst { terrain } = world\n\tconst known = team === undefined || !world.states.has(teamMemory) ? undefined : world.state(teamMemory)[team]?.cells\n\tif (!known) return terrain\n\tconst size = terrain.width * terrain.depth\n\tconst cells: Record<string, Uint8Array> = { ...terrain.cells }\n\tfor (const [layer, memory] of Object.entries(known)) {\n\t\tconst values = (cells[layer] = new Uint8Array(cells[layer] ?? size))\n\t\tmemory.ready(size).forEach((cell, was) => (values[cell] = was))\n\t}\n\treturn Object.create(terrain, { cells: { value: cells } }) as Terrain\n}\n\n/** Whether the seat's player is told of cells their team sees changed, rather than as they come into sight: an observer is told of all */\nconst toldNow = (view: SessionView, cell: number): boolean => view.observer || seesCell(view.world, view.team, cell)\n\n/** A layer's cells changed (`world.setCells`): to those who see them. The others are told as they come into sight (`toldCellsSeen`) */\nexport const toldCells = replicateEvent(cellsChanged, 'cells', ({ layer, cells, value, over }, view) => {\n\tconst at = cells.filter((cell) => toldNow(view, cell))\n\treturn at.length ? { type: 'cells', layer, at, value, ...(over !== undefined && { over: Math.round(over * 100) / 100 }) } : undefined\n})\n\n/**\n * Cells changed out of a team's sight came into it (`tellCellsInSight`): to the team, as they are now, said to be seen\n * so (`seen`: a screen does not show them changing now). An observer was told already\n */\nexport const toldCellsSeen = replicateEvent(cellsSeen, 'cells', ({ team, layer, cells, value }, view) =>\n\t!view.observer && view.team === team ? { type: 'cells', layer, at: [...cells], value, seen: true } : undefined\n)\n"],"mappings":";;;;;;AAgFA,IAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;;;;;;AAQ1I,SAAgB,sBAAsB,MAAmC;CACxE,IAAI,CAAC,SAAS,IAAI,GAAG,OAAO;CAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,cAAc,MAAM;EACjD,MAAM,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,QAAQ,QAAQ,QAAQ;EAC/D,IAAI,OAAO,OAAO,cAAc,MAAM,GAAG,MAAM;EAC/C,IAAI,MAAM,WAAW,KAAA,GAAW;EAChC,IAAI,CAAC,SAAS,MAAM,MAAM,GAAG,OAAO,cAAc,MAAM;EACxD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,MAAM,GAAG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AAC,OAAO,OAAO;CACnB,MAAM,OAAO,QAAQ,QAAQ,QAAQ;CACrC,MAAM,QAAoC,EAAE,GAAG,QAAQ,MAAM;CAC7D,KAAK,MAAM,CAAC,OAAO,WAAW,OAAO,QAAQ,KAAK,GAAG;EACpD,MAAM,SAAU,MAAM,SAAS,IAAI,WAAW,MAAM,UAAU,IAAI;EAClE,OAAO,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,QAAS,OAAO,QAAQ,GAAI;CAC/D;CACA,OAAO,OAAO,OAAO,SAAS,EAAE,OAAO,EAAE,OAAO,MAAM,EAAE,CAAC;AAC1D;;AAGA,IAAM,WAAW,MAAmB,SAA0B,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,MAAM,IAAI;;AAGnH,IAAa,YAAY,eAAe,cAAc,UAAU,EAAE,OAAO,OAAO,OAAO,QAAQ,SAAS;CACvG,MAAM,KAAK,MAAM,QAAQ,SAAS,QAAQ,MAAM,IAAI,CAAC;CACrD,OAAO,GAAG,SAAS;EAAE,MAAM;EAAS;EAAO;EAAI;EAAO,GAAI,SAAS,KAAA,KAAa,EAAE,MAAM,KAAK,MAAM,OAAO,GAAG,IAAI,IAAI;CAAG,IAAI,KAAA;AAC7H,CAAC;;;;;AAMD,IAAa,gBAAgB,eAAe,WAAW,UAAU,EAAE,MAAM,OAAO,OAAO,SAAS,SAC/F,CAAC,KAAK,YAAY,KAAK,SAAS,OAAO;CAAE,MAAM;CAAS;CAAO,IAAI,CAAC,GAAG,KAAK;CAAG;CAAO,MAAM;AAAK,IAAI,KAAA,CACtG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Terrain } from './terrain';
|
|
2
|
+
/**
|
|
3
|
+
* How `patchCells` finds a patch
|
|
4
|
+
*
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface PatchCellsOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Only the cells of the same value as the first (the same style of grass): the patch of that style. Any cell that is
|
|
10
|
+
* not 0 when left out: all the grass that touches, whatever its style
|
|
11
|
+
*/
|
|
12
|
+
sameValue?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The patch of a layer of cells one cell is in: the cells of the layer that touch it and each other, through sides and
|
|
16
|
+
* corners, as indices (`z * width + x`) in order. The patches of a hiding layer are these (`concealmentPack`); the
|
|
17
|
+
* editor's wand picks one. None where the cell is off the ground or 0
|
|
18
|
+
*
|
|
19
|
+
* const field = patchCells(world.terrain, 'grass', cell, { sameValue: true })
|
|
20
|
+
* world.setCells('grass', field, 3)
|
|
21
|
+
*
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare function patchCells(terrain: Pick<Terrain, 'width' | 'depth' | 'cells'>, layer: string, cell: number, options?: PatchCellsOptions): number[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/cellPatches.ts
|
|
2
|
+
/** The eight steps to the cells about one */
|
|
3
|
+
var AROUND_X = [
|
|
4
|
+
-1,
|
|
5
|
+
0,
|
|
6
|
+
1,
|
|
7
|
+
-1,
|
|
8
|
+
1,
|
|
9
|
+
-1,
|
|
10
|
+
0,
|
|
11
|
+
1
|
|
12
|
+
];
|
|
13
|
+
var AROUND_Z = [
|
|
14
|
+
-1,
|
|
15
|
+
-1,
|
|
16
|
+
-1,
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
1,
|
|
20
|
+
1,
|
|
21
|
+
1
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Marks the patch a cell is in with `mark` (`of[cell] = mark`): the cells reached from it, one to the next through
|
|
25
|
+
* sides and corners, that are `value` (or, with a `value` of -1, any but 0) and not marked yet in `of`. Each cell
|
|
26
|
+
* reached is pushed to `out` where one is given. `stack` is scratch, left empty
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
function floodCells(width, depth, cells, value, start, of, mark, stack, out) {
|
|
31
|
+
of[start] = mark;
|
|
32
|
+
out?.push(start);
|
|
33
|
+
stack.push(start);
|
|
34
|
+
while (stack.length) {
|
|
35
|
+
const c = stack.pop();
|
|
36
|
+
const x = c % width;
|
|
37
|
+
const z = (c - x) / width;
|
|
38
|
+
for (let i = 0; i < 8; i++) {
|
|
39
|
+
const nx = x + AROUND_X[i];
|
|
40
|
+
const nz = z + AROUND_Z[i];
|
|
41
|
+
if (nx < 0 || nz < 0 || nx >= width || nz >= depth) continue;
|
|
42
|
+
const n = nz * width + nx;
|
|
43
|
+
if (of[n] !== 0) continue;
|
|
44
|
+
const held = cells[n];
|
|
45
|
+
if (value < 0 ? held === 0 : held !== value) continue;
|
|
46
|
+
of[n] = mark;
|
|
47
|
+
out?.push(n);
|
|
48
|
+
stack.push(n);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The patch of a layer of cells one cell is in: the cells of the layer that touch it and each other, through sides and
|
|
54
|
+
* corners, as indices (`z * width + x`) in order. The patches of a hiding layer are these (`concealmentPack`); the
|
|
55
|
+
* editor's wand picks one. None where the cell is off the ground or 0
|
|
56
|
+
*
|
|
57
|
+
* const field = patchCells(world.terrain, 'grass', cell, { sameValue: true })
|
|
58
|
+
* world.setCells('grass', field, 3)
|
|
59
|
+
*
|
|
60
|
+
* @beta
|
|
61
|
+
*/
|
|
62
|
+
function patchCells(terrain, layer, cell, options = {}) {
|
|
63
|
+
const { width, depth } = terrain;
|
|
64
|
+
const cells = terrain.cells[layer];
|
|
65
|
+
if (!cells || !Number.isInteger(cell) || cell < 0 || cell >= width * depth || cells[cell] === 0) return [];
|
|
66
|
+
const out = [];
|
|
67
|
+
floodCells(width, depth, cells, options.sameValue ? cells[cell] : -1, cell, new Int32Array(width * depth), 1, [], out);
|
|
68
|
+
return out.sort((a, b) => a - b);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { floodCells, patchCells };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=cellPatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellPatches.js","names":[],"sources":["../src/cellPatches.ts"],"sourcesContent":["import type { Terrain } from './terrain'\n\n/*\n * Patches of a layer of cells: the cells of it that touch, sides or corners. One flood fill for all who need one: the\n * hiding places (`concealment.ts`, which labels every patch of a layer), the editor's wand and a game's own code\n * (`patchCells`, the patch of one cell).\n */\n\n/** The eight steps to the cells about one */\nconst AROUND_X = [-1, 0, 1, -1, 1, -1, 0, 1] as const\nconst AROUND_Z = [-1, -1, -1, 0, 0, 1, 1, 1] as const\n\n/**\n * Marks the patch a cell is in with `mark` (`of[cell] = mark`): the cells reached from it, one to the next through\n * sides and corners, that are `value` (or, with a `value` of -1, any but 0) and not marked yet in `of`. Each cell\n * reached is pushed to `out` where one is given. `stack` is scratch, left empty\n *\n * @internal\n */\nexport function floodCells(\n\twidth: number,\n\tdepth: number,\n\tcells: ArrayLike<number>,\n\tvalue: number,\n\tstart: number,\n\tof: Int32Array,\n\tmark: number,\n\tstack: number[],\n\tout?: number[]\n): void {\n\tof[start] = mark\n\tout?.push(start)\n\tstack.push(start)\n\twhile (stack.length) {\n\t\tconst c = stack.pop()!\n\t\tconst x = c % width\n\t\tconst z = (c - x) / width\n\t\tfor (let i = 0; i < 8; i++) {\n\t\t\tconst nx = x + AROUND_X[i]\n\t\t\tconst nz = z + AROUND_Z[i]\n\t\t\tif (nx < 0 || nz < 0 || nx >= width || nz >= depth) continue\n\t\t\tconst n = nz * width + nx\n\t\t\tif (of[n] !== 0) continue\n\t\t\tconst held = cells[n]\n\t\t\tif (value < 0 ? held === 0 : held !== value) continue\n\t\t\tof[n] = mark\n\t\t\tout?.push(n)\n\t\t\tstack.push(n)\n\t\t}\n\t}\n}\n\n/**\n * How `patchCells` finds a patch\n *\n * @beta\n */\nexport interface PatchCellsOptions {\n\t/**\n\t * Only the cells of the same value as the first (the same style of grass): the patch of that style. Any cell that is\n\t * not 0 when left out: all the grass that touches, whatever its style\n\t */\n\tsameValue?: boolean\n}\n\n/**\n * The patch of a layer of cells one cell is in: the cells of the layer that touch it and each other, through sides and\n * corners, as indices (`z * width + x`) in order. The patches of a hiding layer are these (`concealmentPack`); the\n * editor's wand picks one. None where the cell is off the ground or 0\n *\n * const field = patchCells(world.terrain, 'grass', cell, { sameValue: true })\n * world.setCells('grass', field, 3)\n *\n * @beta\n */\nexport function patchCells(terrain: Pick<Terrain, 'width' | 'depth' | 'cells'>, layer: string, cell: number, options: PatchCellsOptions = {}): number[] {\n\tconst { width, depth } = terrain\n\tconst cells = terrain.cells[layer]\n\tif (!cells || !Number.isInteger(cell) || cell < 0 || cell >= width * depth || cells[cell] === 0) return []\n\tconst out: number[] = []\n\tfloodCells(width, depth, cells, options.sameValue ? cells[cell] : -1, cell, new Int32Array(width * depth), 1, [], out)\n\treturn out.sort((a, b) => a - b)\n}\n"],"mappings":";;AASA,IAAM,WAAW;CAAC;CAAI;CAAG;CAAG;CAAI;CAAG;CAAI;CAAG;AAAC;AAC3C,IAAM,WAAW;CAAC;CAAI;CAAI;CAAI;CAAG;CAAG;CAAG;CAAG;AAAC;;;;;;;;AAS3C,SAAgB,WACf,OACA,OACA,OACA,OACA,OACA,IACA,MACA,OACA,KACO;CACP,GAAG,SAAS;CACZ,KAAK,KAAK,KAAK;CACf,MAAM,KAAK,KAAK;CAChB,OAAO,MAAM,QAAQ;EACpB,MAAM,IAAI,MAAM,IAAI;EACpB,MAAM,IAAI,IAAI;EACd,MAAM,KAAK,IAAI,KAAK;EACpB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;GAC3B,MAAM,KAAK,IAAI,SAAS;GACxB,MAAM,KAAK,IAAI,SAAS;GACxB,IAAI,KAAK,KAAK,KAAK,KAAK,MAAM,SAAS,MAAM,OAAO;GACpD,MAAM,IAAI,KAAK,QAAQ;GACvB,IAAI,GAAG,OAAO,GAAG;GACjB,MAAM,OAAO,MAAM;GACnB,IAAI,QAAQ,IAAI,SAAS,IAAI,SAAS,OAAO;GAC7C,GAAG,KAAK;GACR,KAAK,KAAK,CAAC;GACX,MAAM,KAAK,CAAC;EACb;CACD;AACD;;;;;;;;;;;AAyBA,SAAgB,WAAW,SAAqD,OAAe,MAAc,UAA6B,CAAC,GAAa;CACvJ,MAAM,EAAE,OAAO,UAAU;CACzB,MAAM,QAAQ,QAAQ,MAAM;CAC5B,IAAI,CAAC,SAAS,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,QAAQ,QAAQ,SAAS,MAAM,UAAU,GAAG,OAAO,CAAC;CACzG,MAAM,MAAgB,CAAC;CACvB,WAAW,OAAO,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI,MAAM,IAAI,WAAW,QAAQ,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG;CACrH,OAAO,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC;AAChC"}
|
package/dist/cinematics.d.ts
CHANGED
|
@@ -72,7 +72,11 @@ export interface CinematicEnded {
|
|
|
72
72
|
/** How it ended there */
|
|
73
73
|
outcome: CinematicOutcome;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* How a cinematic is played when a rule calls for it: who sees it, whether the game waits and whether it can be skipped
|
|
77
|
+
*
|
|
78
|
+
* @beta
|
|
79
|
+
*/
|
|
76
80
|
export interface CinematicOptions {
|
|
77
81
|
/** Who sees it: a player, some, or everyone. Everyone when left out */
|
|
78
82
|
to?: Audience;
|
|
@@ -154,6 +158,7 @@ export interface CinematicChoice {
|
|
|
154
158
|
cinematic: string;
|
|
155
159
|
/** The choice's name in the cinematic (`choice` when it gave none), and the answer's id */
|
|
156
160
|
question: string;
|
|
161
|
+
/** The id of the answer picked */
|
|
157
162
|
choice: string;
|
|
158
163
|
/** Whether nobody picked and the time ran out on its default */
|
|
159
164
|
timedOut: boolean;
|
|
@@ -161,14 +166,14 @@ export interface CinematicChoice {
|
|
|
161
166
|
/** A player's pick of a choice of a cinematic, as their screen said: heard by the rules as `cinematicChoice` */
|
|
162
167
|
export declare function cinematicChose(world: World, choice: CinematicChoice): void;
|
|
163
168
|
/**
|
|
164
|
-
* A step of a sequence that plays one of the view's cinematics: `defineSequence('td.start', [cinematic('td.intro', {
|
|
165
|
-
* hold: true }), ...talk(...)])`. It does not wait for it (with `hold`, the game, and the sequence with it, waits),
|
|
169
|
+
* A step of a sequence that plays one of the view's cinematics: `defineSequence({ id: 'td.start', steps: [cinematic('td.intro', {
|
|
170
|
+
* hold: true }), ...talk(...)] })`. It does not wait for it (with `hold`, the game, and the sequence with it, waits),
|
|
166
171
|
* unless told to: `wait: 'ended'` goes on once the player it was for has seen it end (or skipped it), `any` once one
|
|
167
172
|
* of the players it went to has, `all` once every one of them has. Only players with a screen are waited for (not the
|
|
168
173
|
* computer's); one who left a game of several never says, so a sequence for many waits for `any` where that matters.
|
|
169
174
|
* With a wait it is two steps, which `defineSequence` takes as they are
|
|
170
175
|
*
|
|
171
|
-
* @
|
|
176
|
+
* @public
|
|
172
177
|
*/
|
|
173
178
|
export declare function cinematic<D = undefined>(id: string, options?: CinematicOptions & {
|
|
174
179
|
wait?: undefined;
|
|
@@ -176,7 +181,7 @@ export declare function cinematic<D = undefined>(id: string, options?: Cinematic
|
|
|
176
181
|
/**
|
|
177
182
|
* With `wait`: the cinematic played, then a wait for its end (see the other form), as two steps
|
|
178
183
|
*
|
|
179
|
-
* @
|
|
184
|
+
* @public
|
|
180
185
|
*/
|
|
181
186
|
export declare function cinematic<D = undefined>(id: string, options: CinematicOptions & {
|
|
182
187
|
wait: CinematicWait;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { defineComponent } from "./components.js";
|
|
2
|
+
import { defineListener } from "./events.js";
|
|
3
|
+
import { cinematicChoice, cinematicCue as cinematicCue$1, cinematicCued, cinematicEnded as cinematicEnded$1, enteredArea } from "./engineEvents.js";
|
|
4
|
+
import { replicateEvent } from "./replication.js";
|
|
5
|
+
import { plain } from "./plain.js";
|
|
6
|
+
import { waitUntil } from "./sequences.js";
|
|
7
|
+
//#region src/cinematics.ts
|
|
8
|
+
/** The outcomes a screen may report, for the command's check */
|
|
9
|
+
var CINEMATIC_OUTCOMES = [
|
|
10
|
+
"ended",
|
|
11
|
+
"skipped",
|
|
12
|
+
"stopped",
|
|
13
|
+
"replaced",
|
|
14
|
+
"ignored"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Plays one of the view's cinematics on the screens of the players it is for, now
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
function playCinematic(world, id, options = {}) {
|
|
22
|
+
const { to = "everyone", hold = false, skippable = true, params } = options;
|
|
23
|
+
world.events.emit(cinematicCue$1, {
|
|
24
|
+
id,
|
|
25
|
+
to: audience(to),
|
|
26
|
+
hold,
|
|
27
|
+
skippable,
|
|
28
|
+
...params && { params: plain(params, `params of the cinematic "${id}"`, "Cinematic") }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Who a cue or a cinematic goes to, as a list: everyone's is left out */
|
|
32
|
+
var audience = (to) => to === "everyone" ? void 0 : Array.isArray(to) ? to : [to];
|
|
33
|
+
/**
|
|
34
|
+
* Cues the cinematic playing on the screens of the players it is for (everyone when left out): one waiting for it
|
|
35
|
+
* (`cut.untilCue(name)`) goes on, and the view's hooks of it (`cue:<name>`) run. Nothing happens where none plays, or
|
|
36
|
+
* the one playing does not listen for it. `params` is plain data the cue carries
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
function cueCinematic(world, cue, options = {}) {
|
|
41
|
+
const { to = "everyone", params } = options;
|
|
42
|
+
world.events.emit(cinematicCued, {
|
|
43
|
+
cue,
|
|
44
|
+
to: audience(to),
|
|
45
|
+
...params && { params: plain(params, `params of the cue "${cue}"`, "Cinematic") }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A step of a sequence that cues the cinematic playing (see `cueCinematic`): `[wait(4), cinematicCue('gateOpen')]`
|
|
50
|
+
*
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
var cinematicCue = (cue, options) => (world) => cueCinematic(world, cue, options);
|
|
54
|
+
/** The sequences waiting for a cinematic to end on players' screens: in the world, so that a save keeps the count */
|
|
55
|
+
var waits = defineComponent({
|
|
56
|
+
id: "core.cinematicWaits",
|
|
57
|
+
default: () => ({ list: [] })
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* A player's screen says a cinematic the rules played is over (the `cinematic` command): the engine says so to the rules
|
|
61
|
+
* (`cinematicEnded`), and a sequence that waits for it counts it
|
|
62
|
+
*/
|
|
63
|
+
function cinematicEnded(world, player, cinematic, outcome) {
|
|
64
|
+
if (world.states.has(waits)) for (const entry of world.state(waits).list) {
|
|
65
|
+
if (entry.cinematic !== cinematic || !entry.waiting.includes(player)) continue;
|
|
66
|
+
entry.waiting = entry.any ? [] : entry.waiting.filter((other) => other !== player);
|
|
67
|
+
}
|
|
68
|
+
world.events.emit(cinematicEnded$1, {
|
|
69
|
+
player,
|
|
70
|
+
cinematic,
|
|
71
|
+
outcome
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** A player's pick of a choice of a cinematic, as their screen said: heard by the rules as `cinematicChoice` */
|
|
75
|
+
function cinematicChose(world, choice) {
|
|
76
|
+
world.events.emit(cinematicChoice, choice);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The players a cinematic goes to that have a screen to say it ended: the ones of `to` (everyone's when left out) the
|
|
80
|
+
* computer does not play, and not the neutral ones
|
|
81
|
+
*/
|
|
82
|
+
function screensOf(world, to) {
|
|
83
|
+
const computers = new Set(world.computers.list());
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const player of world.players.values()) {
|
|
86
|
+
if (player.neutral || computers.has(player.id) || to && !to.includes(player.id)) continue;
|
|
87
|
+
out.push(player.id);
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
function cinematic(id, options = {}) {
|
|
92
|
+
const { wait, ...rest } = options;
|
|
93
|
+
const play = (world) => playCinematic(world, id, rest);
|
|
94
|
+
if (!wait) return play;
|
|
95
|
+
const begin = (world, _data, run) => {
|
|
96
|
+
const state = world.state(waits);
|
|
97
|
+
state.list = state.list.filter((entry) => entry.run !== run && world.sequences.running(entry.run));
|
|
98
|
+
state.list.push({
|
|
99
|
+
run,
|
|
100
|
+
cinematic: id,
|
|
101
|
+
waiting: screensOf(world, audience(rest.to ?? "everyone")),
|
|
102
|
+
any: wait === "any"
|
|
103
|
+
});
|
|
104
|
+
playCinematic(world, id, rest);
|
|
105
|
+
};
|
|
106
|
+
return [begin, waitUntil((world, _data, run) => {
|
|
107
|
+
const state = world.state(waits);
|
|
108
|
+
const entry = state.list.find((candidate) => candidate.run === run);
|
|
109
|
+
if (entry && entry.waiting.length > 0) return false;
|
|
110
|
+
state.list = state.list.filter((candidate) => candidate !== entry);
|
|
111
|
+
return true;
|
|
112
|
+
})];
|
|
113
|
+
}
|
|
114
|
+
/** A cinematic played, to whom it is for: everyone when it names nobody */
|
|
115
|
+
var toldCinematic = replicateEvent(cinematicCue$1, "cinematic", ({ id, to, hold, skippable, params }, view) => !to || to.includes(view.player) ? {
|
|
116
|
+
type: "cinematic",
|
|
117
|
+
cinematic: id,
|
|
118
|
+
hold,
|
|
119
|
+
skippable,
|
|
120
|
+
...params && { params }
|
|
121
|
+
} : void 0);
|
|
122
|
+
/** A cue of the rules to a cinematic playing, to whom it is for */
|
|
123
|
+
var toldCinematicCue = replicateEvent(cinematicCued, "cinematicCue", ({ cue, to, params }, view) => !to || to.includes(view.player) ? {
|
|
124
|
+
type: "cinematicCue",
|
|
125
|
+
cue,
|
|
126
|
+
...params && { params }
|
|
127
|
+
} : void 0);
|
|
128
|
+
/**
|
|
129
|
+
* The regions whose cinematic has played (`MapRegion.cinematic`), by name: kept in the world, so that a save knows
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
var regionCinematicsPlayed = defineComponent({
|
|
134
|
+
id: "core.regionCinematics",
|
|
135
|
+
default: () => ({})
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* A region of the map with a cinematic (`MapRegion.cinematic`, ED4) plays it for everyone, once, the first time a unit
|
|
139
|
+
* of a player (not the neutral, nor a building) walks in, unless the game plays it its own way (`play: 'code'`)
|
|
140
|
+
*
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
143
|
+
var regionCinematic = defineListener({
|
|
144
|
+
id: "core.regionCinematic",
|
|
145
|
+
event: enteredArea,
|
|
146
|
+
run(world, { area, entity }) {
|
|
147
|
+
const cinematic = world.map.regions.find((each) => each.name === area)?.cinematic;
|
|
148
|
+
if (!cinematic || cinematic.play === "code" || world.player(entity.owner).neutral) return;
|
|
149
|
+
const played = world.state(regionCinematicsPlayed);
|
|
150
|
+
if (played[area]) return;
|
|
151
|
+
world.setState(regionCinematicsPlayed, {
|
|
152
|
+
...played,
|
|
153
|
+
[area]: true
|
|
154
|
+
});
|
|
155
|
+
playCinematic(world, cinematic.id);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
//#endregion
|
|
159
|
+
export { CINEMATIC_OUTCOMES, cinematic, cinematicChose, cinematicCue, cinematicEnded, cueCinematic, playCinematic, regionCinematic, regionCinematicsPlayed, toldCinematic, toldCinematicCue, waits };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=cinematics.js.map
|