@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
package/dist/registry.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { CORE_STAT_KEYS, noStats } from "./defs.js";
|
|
2
|
+
import { engineEventById, isGameEvent } from "./events.js";
|
|
3
|
+
import { defaultSettings } from "./rules.js";
|
|
4
|
+
import { gameHash } from "./mods.js";
|
|
5
|
+
import { DATA_KINDS } from "./gameData.js";
|
|
6
|
+
import { Definitions } from "./definitions.js";
|
|
7
|
+
//#region src/registry.ts
|
|
8
|
+
/**
|
|
9
|
+
* What is thrown for a component or an event of its own that a game uses without listing it (`Rules.components`,
|
|
10
|
+
* `Rules.events`): no world finds it by its id, so a save, a snapshot or the index would lose it
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
var UnlistedError = class extends Error {
|
|
15
|
+
kind;
|
|
16
|
+
id;
|
|
17
|
+
game;
|
|
18
|
+
constructor(kind, id, game) {
|
|
19
|
+
super(`The ${kind} "${id}" is used by the game "${game}" without being listed in it: add it to Rules.${kind}s, as its timers and listeners are`);
|
|
20
|
+
this.kind = kind;
|
|
21
|
+
this.id = id;
|
|
22
|
+
this.game = game;
|
|
23
|
+
this.name = "UnlistedError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** A list's entries by id, with their place: worked out once a list (`tile`, `resource`, `tunable` are asked every tick) */
|
|
27
|
+
var indexes = /* @__PURE__ */ new WeakMap();
|
|
28
|
+
function indexOf(list) {
|
|
29
|
+
let index = indexes.get(list);
|
|
30
|
+
if (!index) indexes.set(list, index = new Map(list.map((def, at) => [def.id, {
|
|
31
|
+
def,
|
|
32
|
+
at
|
|
33
|
+
}])));
|
|
34
|
+
return index;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The registry of a game's definitions and behaviours: unit types, abilities, orders, systems, buffs and the rest, by id
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
var Registry = class {
|
|
42
|
+
/** The game's unit types, buildings and resources (`Rules.units`) */
|
|
43
|
+
units = new Definitions("unit type", void 0, (def) => {
|
|
44
|
+
if (def.kind !== "unit" && !def.footprint) throw new Error(`Unit type "${def.id}" needs a footprint`);
|
|
45
|
+
});
|
|
46
|
+
/** The orders units can be given, the engine's and the game's, by type */
|
|
47
|
+
orders = new Definitions("order type", (behavior) => behavior.type);
|
|
48
|
+
/** How groups line up (`Rules.formations`) */
|
|
49
|
+
formations = new Definitions("formation");
|
|
50
|
+
/** The game's research (`Rules.upgrades`) */
|
|
51
|
+
upgrades = new Definitions("upgrade");
|
|
52
|
+
/** Every ability there is, of units, heroes and items alike (`Rules.abilities`) */
|
|
53
|
+
abilities = new Definitions("ability");
|
|
54
|
+
/** The game's buffs (`Rules.buffs`) */
|
|
55
|
+
buffs = new Definitions("buff");
|
|
56
|
+
/** The game's items (`Rules.items`) */
|
|
57
|
+
items = new Definitions("item");
|
|
58
|
+
/** The tags of the game's items named and given a look (`Rules.tags`): a tag none names is its own word */
|
|
59
|
+
tags = new Definitions("tag");
|
|
60
|
+
/** The game's races, in its order (`Rules.races`): none in a game without */
|
|
61
|
+
races = new Definitions("race");
|
|
62
|
+
/** The game's prefabs (`Rules.prefabs`) */
|
|
63
|
+
prefabs = new Definitions("prefab");
|
|
64
|
+
/** The commands a world takes, the engine's and the game's, by type */
|
|
65
|
+
commands = new Definitions("command", (def) => def.type);
|
|
66
|
+
/** What each type of an ability's effect does, by type */
|
|
67
|
+
effects = new Definitions("effect type", (effect) => effect.type);
|
|
68
|
+
/** A game's own ways of aiming an ability (`Rules.targetings`), by name */
|
|
69
|
+
targetings = new Definitions("way of aiming");
|
|
70
|
+
/**
|
|
71
|
+
* The kinds of definition a game's data is kept for (`DataKind`), each its collection: what the Data panel, mods,
|
|
72
|
+
* saves and a game's reload walk, one loop each
|
|
73
|
+
*/
|
|
74
|
+
kinds = {
|
|
75
|
+
units: this.units,
|
|
76
|
+
abilities: this.abilities,
|
|
77
|
+
buffs: this.buffs,
|
|
78
|
+
items: this.items,
|
|
79
|
+
upgrades: this.upgrades,
|
|
80
|
+
races: this.races
|
|
81
|
+
};
|
|
82
|
+
/** The components the game lists (`Rules.components`), and those its app keeps in its worlds, by id */
|
|
83
|
+
components = /* @__PURE__ */ new Map();
|
|
84
|
+
/** The engine's own components (`coreComponents`) and the listed, by id: what `component` finds, in one look */
|
|
85
|
+
known = /* @__PURE__ */ new Map();
|
|
86
|
+
/** The events of its own the game lists (`Rules.events`), by id */
|
|
87
|
+
events = /* @__PURE__ */ new Map();
|
|
88
|
+
/**
|
|
89
|
+
* Takes in the engine's own components, which every game has (`coreComponents`)
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
defineCore(components) {
|
|
94
|
+
for (const component of components) if (!this.components.has(component.id)) this.known.set(component.id, component);
|
|
95
|
+
}
|
|
96
|
+
/** Takes in the components and events a game lists. Throws for an id that is there twice, another way */
|
|
97
|
+
defineParts(components, events) {
|
|
98
|
+
for (const component of components) {
|
|
99
|
+
const before = this.components.get(component.id);
|
|
100
|
+
if (before && before !== component) throw new Error(`The component "${component.id}" is there twice`);
|
|
101
|
+
this.components.set(component.id, component);
|
|
102
|
+
this.known.set(component.id, component);
|
|
103
|
+
}
|
|
104
|
+
for (const event of events) {
|
|
105
|
+
const before = this.events.get(event.id);
|
|
106
|
+
if (before && before !== event) throw new Error(`The event "${event.id}" is there twice`);
|
|
107
|
+
this.events.set(event.id, event);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** A component of this game by its id: one the game lists, or one of the engine's own (`coreComponents`). None for any other */
|
|
111
|
+
component(id) {
|
|
112
|
+
return this.known.get(id);
|
|
113
|
+
}
|
|
114
|
+
/** A component of this game by its id, as something of the world uses it: throws for one the game does not list (`UnlistedError`) */
|
|
115
|
+
used(id) {
|
|
116
|
+
const found = this.component(id);
|
|
117
|
+
if (!found) throw new UnlistedError("component", id, this.game);
|
|
118
|
+
return found;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* An event of the game's own by its id: listed, or the engine's (`core.`), as the engine defined it. One of a game's
|
|
122
|
+
* that it does not list throws (`UnlistedError`). Never another game's: a process may hold more than one, each
|
|
123
|
+
* defining an id its own way (E7)
|
|
124
|
+
*/
|
|
125
|
+
event(id) {
|
|
126
|
+
const listed = this.events.get(id) ?? engineEventById(id);
|
|
127
|
+
if (listed) return listed;
|
|
128
|
+
if (isGameEvent(id)) throw new UnlistedError("event", id, this.game);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The components the game lists, for what goes through them all: the map's fields they have
|
|
132
|
+
*
|
|
133
|
+
* @beta
|
|
134
|
+
*/
|
|
135
|
+
listedComponents() {
|
|
136
|
+
return this.components.values();
|
|
137
|
+
}
|
|
138
|
+
/** Whether the game lists a component or an event, or it is one of the engine's own */
|
|
139
|
+
lists(kind, id) {
|
|
140
|
+
return kind === "component" ? this.known.has(id) : this.events.has(id) || engineEventById(id) !== void 0;
|
|
141
|
+
}
|
|
142
|
+
/** The log of the world this is the registry of, once there is one (`World.log`) */
|
|
143
|
+
log;
|
|
144
|
+
/**
|
|
145
|
+
* Takes the definitions of another registry of the same game over its own (`world.reload`): its unit types,
|
|
146
|
+
* abilities, buffs, items, upgrades and races, the code of its effects and orders, its rules, and its module. Those
|
|
147
|
+
* it has that the other has not are kept (a world may have units of them). What the game is made of otherwise (its
|
|
148
|
+
* resources, stats, components, events) stays as it is: a world was made of it
|
|
149
|
+
*/
|
|
150
|
+
takeFrom(other) {
|
|
151
|
+
for (const kind of DATA_KINDS) this.kinds[kind].takeFrom(other.kinds[kind]);
|
|
152
|
+
this.effects.takeFrom(other.effects);
|
|
153
|
+
this.targetings.takeFrom(other.targetings);
|
|
154
|
+
this.orders.takeFrom(other.orders);
|
|
155
|
+
this.formations.takeFrom(other.formations);
|
|
156
|
+
this.tags.takeFrom(other.tags);
|
|
157
|
+
this.settings = other.settings;
|
|
158
|
+
this.score = other.score;
|
|
159
|
+
this.day = other.day;
|
|
160
|
+
this.report = other.report;
|
|
161
|
+
this.tunables = other.tunables;
|
|
162
|
+
this.files = new Map(other.files);
|
|
163
|
+
this.fileDefs = new Map(other.fileDefs);
|
|
164
|
+
this.upkeep = other.upkeep;
|
|
165
|
+
this.module = other.module;
|
|
166
|
+
this.hashed = this.dataHashed = void 0;
|
|
167
|
+
}
|
|
168
|
+
/** Lowest threshold first. Empty for a game without upkeep */
|
|
169
|
+
upkeep = [];
|
|
170
|
+
/** Id of the game module it was made from */
|
|
171
|
+
game = "";
|
|
172
|
+
/** The game module it was made from */
|
|
173
|
+
module = null;
|
|
174
|
+
hashed;
|
|
175
|
+
/** What identifies the game exactly, mods and code included (see `gameHash`). Worked out the first time it is asked for */
|
|
176
|
+
get hash() {
|
|
177
|
+
return this.hashed ??= this.module ? gameHash(this.module) : "";
|
|
178
|
+
}
|
|
179
|
+
dataHashed;
|
|
180
|
+
/**
|
|
181
|
+
* What identifies the game's data: everything but how its code reads (see `gameHash`). What a server and a player
|
|
182
|
+
* check they share: the two run builds of the same code that print it differently
|
|
183
|
+
*/
|
|
184
|
+
get dataHash() {
|
|
185
|
+
return this.dataHashed ??= this.module ? gameHash(this.module, { code: false }) : "";
|
|
186
|
+
}
|
|
187
|
+
/** The version of what the game keeps in a save (`Rules.saves.version`): 1 for a game that says none */
|
|
188
|
+
get saveVersion() {
|
|
189
|
+
return this.module?.saves?.version ?? 1;
|
|
190
|
+
}
|
|
191
|
+
/** The game's own stats, next to the engine's (`Rules.stats`) */
|
|
192
|
+
stats = [];
|
|
193
|
+
/** The game put together with its packs (`assembleGame`): set as the registry is made of it */
|
|
194
|
+
assembly = null;
|
|
195
|
+
/** The engine's parts and the game's that give an entity something as it is made (`Component.onSpawn`), in order */
|
|
196
|
+
spawning = [];
|
|
197
|
+
/** The engine's parts and the game's that call something off as an entity leaves its owner (`Component.onLeave`) */
|
|
198
|
+
leaving = [];
|
|
199
|
+
/** The engine's parts and the game's that may have a structure stand open, in nobody's way (`Component.passable`) */
|
|
200
|
+
passing = [];
|
|
201
|
+
/** Whether a structure stands open now, in nobody's way, by its parts (`Component.passable`): a gate opened */
|
|
202
|
+
standsOpen(entity) {
|
|
203
|
+
for (const part of this.passing) if (entity.has(part) && part.passable(entity.get(part), entity)) return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
/** What the game's packs add to a unit's stats (`GamePack.stats`): a hero's growth */
|
|
207
|
+
statFields = [];
|
|
208
|
+
/** How each event of the world is told to a player, the engine's then the packs' (`replicateEvent`), in order */
|
|
209
|
+
replications = [];
|
|
210
|
+
/** The parts of a player's snapshot, the engine's then the packs' (`SnapshotField`), in order */
|
|
211
|
+
snapshotFields = [];
|
|
212
|
+
/** What the game counts of its players (`RuleSettings.score`), its stats made: null for a game that counts nothing */
|
|
213
|
+
score = null;
|
|
214
|
+
/** What each of the game's own files was read as (`Rules.files`), by id */
|
|
215
|
+
files = /* @__PURE__ */ new Map();
|
|
216
|
+
/** The game's own files (`Rules.files`), by id */
|
|
217
|
+
fileDefs = /* @__PURE__ */ new Map();
|
|
218
|
+
/** What the rules read of a file of the game's own data (`Rules.files`): throws for one the game does not list */
|
|
219
|
+
file(def) {
|
|
220
|
+
if (!this.files.has(def.id)) throw new Error(`The file "${def.id}" is not the game's: list it in Rules.files`);
|
|
221
|
+
return this.files.get(def.id);
|
|
222
|
+
}
|
|
223
|
+
/** Puts what a file of the game's is read as, for this registry's world alone: the editor's panel, as it is edited */
|
|
224
|
+
setFile(def, value) {
|
|
225
|
+
this.files.set(def.id, value);
|
|
226
|
+
this.fileDefs.set(def.id, def);
|
|
227
|
+
}
|
|
228
|
+
/** A file of the game's own data by its id (`waves.json`): what reads it, for an editor that writes it. None for one the game does not list */
|
|
229
|
+
fileDef(id) {
|
|
230
|
+
return this.fileDefs.get(id);
|
|
231
|
+
}
|
|
232
|
+
/** A prefab of the game's by id, for `world.spawnPrefab`; throws for one there is not */
|
|
233
|
+
prefab(id) {
|
|
234
|
+
const def = this.prefabs.find(id);
|
|
235
|
+
if (!def) throw new Error(`No prefab is called "${id}": list it in Rules.prefabs, or give the prefab itself`);
|
|
236
|
+
return def;
|
|
237
|
+
}
|
|
238
|
+
/** What the ground can be painted with, in the order of their indices: the first is 1 (`Rules.tiles`) */
|
|
239
|
+
tiles = [];
|
|
240
|
+
/** The game's layers of cells (`Rules.cellLayers`): what `Terrain.cells` is keyed by, with what each means */
|
|
241
|
+
cellLayers = [];
|
|
242
|
+
/** The numbers of the rules to be tuned while the game plays (`Rules.tunables`) */
|
|
243
|
+
tunables = [];
|
|
244
|
+
/** A tunable by id, or nothing for one the game does not have */
|
|
245
|
+
tunable(id) {
|
|
246
|
+
return indexOf(this.tunables).get(id)?.def;
|
|
247
|
+
}
|
|
248
|
+
/** The index of a tile of the game, for painting the ground in code: `terrain.tiles[cell] = registry.tile('road')` */
|
|
249
|
+
tile(id) {
|
|
250
|
+
const found = indexOf(this.tiles).get(id);
|
|
251
|
+
if (!found) throw new Error(`Unknown tile "${id}"`);
|
|
252
|
+
return found.at + 1;
|
|
253
|
+
}
|
|
254
|
+
/** The ids of the game's tiles, in the order of their indices */
|
|
255
|
+
get tileIds() {
|
|
256
|
+
return this.tiles.map((tile) => tile.id);
|
|
257
|
+
}
|
|
258
|
+
/** Every stat there is in the game, the engine's first */
|
|
259
|
+
statKeys = [...CORE_STAT_KEYS];
|
|
260
|
+
/** Every stat of the game at 0, its own at their default: what base stats start from */
|
|
261
|
+
statDefaults = noStats();
|
|
262
|
+
/** The game's numbers that are not about any one unit (`Rules.settings`) */
|
|
263
|
+
settings = defaultSettings;
|
|
264
|
+
/** Null for a game where it is always day */
|
|
265
|
+
day = null;
|
|
266
|
+
/** What the game tells each player about itself, see `Rules.report`. Asked by the session that runs the world */
|
|
267
|
+
report = null;
|
|
268
|
+
/** The resources of the game, in the order players are shown them */
|
|
269
|
+
resources = [];
|
|
270
|
+
/**
|
|
271
|
+
* The resource prices, bounties, revives and sales are in: the game's money. Null for a game without one,
|
|
272
|
+
* where there is nothing of that kind to pay with
|
|
273
|
+
*/
|
|
274
|
+
currency = null;
|
|
275
|
+
/** The command type, or undefined for one the game does not have: commands come from outside, and may name anything */
|
|
276
|
+
command(type) {
|
|
277
|
+
return this.commands.find(type);
|
|
278
|
+
}
|
|
279
|
+
/** The definition of a resource, or undefined for one the game does not have */
|
|
280
|
+
resource(id) {
|
|
281
|
+
return indexOf(this.resources).get(id)?.def;
|
|
282
|
+
}
|
|
283
|
+
/** A unit type by id: throws for one the game does not have (`units`) */
|
|
284
|
+
unit(id) {
|
|
285
|
+
return this.units.get(id);
|
|
286
|
+
}
|
|
287
|
+
/** An upgrade by id: throws for one the game does not have (`upgrades`) */
|
|
288
|
+
upgrade(id) {
|
|
289
|
+
return this.upgrades.get(id);
|
|
290
|
+
}
|
|
291
|
+
/** A race by id: throws for one the game does not have (`races`) */
|
|
292
|
+
race(id) {
|
|
293
|
+
return this.races.get(id);
|
|
294
|
+
}
|
|
295
|
+
/** An ability by id: throws for one the game does not have (`abilities`) */
|
|
296
|
+
ability(id) {
|
|
297
|
+
return this.abilities.get(id);
|
|
298
|
+
}
|
|
299
|
+
/** A buff by id: throws for one the game does not have (`buffs`) */
|
|
300
|
+
buff(id) {
|
|
301
|
+
return this.buffs.get(id);
|
|
302
|
+
}
|
|
303
|
+
/** An item by id: throws for one the game does not have (`items`) */
|
|
304
|
+
item(id) {
|
|
305
|
+
return this.items.get(id);
|
|
306
|
+
}
|
|
307
|
+
/** What an effect type does: throws for one there is not (`effects`) */
|
|
308
|
+
effect(type) {
|
|
309
|
+
return this.effects.get(type).run;
|
|
310
|
+
}
|
|
311
|
+
/** An order type's behaviour, typed by what its orders keep (`OrderStates`): throws for one there is not (`orders`) */
|
|
312
|
+
order(type) {
|
|
313
|
+
return this.orders.get(type);
|
|
314
|
+
}
|
|
315
|
+
/** A formation by id: throws for one there is not (`formations`) */
|
|
316
|
+
formation(id) {
|
|
317
|
+
return this.formations.get(id);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
//#endregion
|
|
321
|
+
export { Registry, UnlistedError };
|
|
322
|
+
|
|
323
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../src/registry.ts"],"sourcesContent":["import type { AdvanceState, AlongPath, AttackGroundState, AttackState, FollowState, HoldState, PatrolState } from './orders/basic'\nimport type { GameFileDef } from './gameFiles'\nimport type { ReplicatedEvent, SnapshotField } from './replication'\nimport { DATA_KINDS, type DataDefs, type DataKind } from './gameData'\nimport { Definitions } from './definitions'\nimport type { BuildState, RepairState, WorkState } from './orders/build'\nimport type { CastState } from './orders/cast'\nimport type { HarvestState } from './orders/harvest'\nimport type { ItemOrderState } from './orders/items'\nimport type { BoardState, LoadState, UnloadState } from './transport'\nimport type { RaceDef } from './races'\nimport type { Logger } from './log'\nimport type { Component } from './components'\nimport { engineEventById, type EventKey, isGameEvent } from './events'\nimport type { EffectHandler, EffectType } from './abilities/effects'\nimport type { Targeting } from './targeting'\nimport type { CommandDef } from './commands'\nimport {\n\ttype AbilityDef,\n\ttype BuffDef,\n\tCORE_STAT_KEYS,\n\ttype DayCycle,\n\ttype ItemDef,\n\tnoStats,\n\ttype ResourceDef,\n\ttype ResourceId,\n\ttype StatDef,\n\ttype Stats,\n\ttype TagDef,\n\ttype UnitTypeDef,\n\ttype UpgradeDef,\n\ttype UpkeepTier\n} from './defs'\nimport type { Entity, EntityId, Order, PlayerId } from './entity'\nimport type { Vec2 } from './math'\nimport type { StatField } from './stats'\nimport type { FormationDef } from './formation'\nimport type { AssembledGame, Rules } from './game'\nimport { gameHash } from './mods'\nimport { defaultSettings, type RuleSettings } from './rules'\nimport type { TileDef } from './tiles'\nimport type { PrefabDef } from './prefabs'\nimport type { TunableDef } from './tunables'\nimport type { World } from './world'\nimport type { CellLayerDef } from './cellLayers'\nimport type { ResolvedScore } from './score'\n\n/**\n * Where an order stands after an update: still `running`, `done`, or `failed`\n *\n * @beta\n */\nexport type OrderStatus = 'running' | 'done' | 'failed'\n\n/**\n * What an order can be given, every order's field in one: for what reads an order of any type (the queue, a save, a\n * screen's waypoints). An order of a type is given its own of them (`OrderInits`)\n *\n * @beta\n */\nexport interface OrderParams {\n\t/** The entity an order is aimed at: to attack, follow, harvest from, repair, board or load */\n\ttarget?: EntityId\n\t/** The point an order is aimed at, in world coordinates */\n\tpoint?: Vec2\n\t/** Type to build, for build orders */\n\tunitType?: string\n\t/** Ability to use, for cast orders */\n\tability?: string\n\t/** For an ability aimed along two points (`vector`): the second, the way it goes from `point` */\n\tto?: Vec2\n\t/** An item: the one to use, drop or hand over by its place in the inventory, or the one on the ground to pick up */\n\titem?: number\n\t/** Direction to face at the end. Commands fill this in with the direction of travel */\n\tfacing?: number\n\t/**\n\t * For a move: the group goes at the pace of its slowest (campaign plan GP1), so that it arrives together. The\n\t * command works the pace out (`speedCap`)\n\t */\n\ttogether?: boolean\n\t/** For a move: the fastest it goes, set by the command for a group that goes `together`: the slowest one's speed */\n\tspeedCap?: number\n\t/** A path of the map, by its name (`MapPath`): for the orders that go along one (`followPath`, `attackPath`) */\n\tpath?: string\n\t/**\n\t * Which way along `path`: to its first point or its last. Away from the end the unit is nearer to when left out: a\n\t * minion back on its lane after a chase, past its middle, goes on the way it was going\n\t */\n\ttowards?: 'first' | 'last'\n}\n\n/**\n * What each order type is given (`Order.init`), by type (design review E14): the engine's, and a game's own added by\n * declaration merging, as `OrderStates` is:\n *\n * ```ts\n * declare module '@v12-engine/engine' {\n * \tinterface OrderInits {\n * \t\t'mygame.dig': { point?: Vec2 }\n * \t}\n * }\n * ```\n *\n * Every field may be missing from what a command sends, which comes from a player: the behaviour's `accepts` checks\n * what it needs\n *\n * @beta\n */\nexport interface OrderInits {\n\t/** What a `move` order is given (`Order.init`): point, facing, target, together and speedCap: where to, which way to face at the end, an entity to go to, group pace */\n\tmove: Pick<OrderParams, 'point' | 'facing' | 'target' | 'together' | 'speedCap'>\n\t/** What a `hold` order is given (`Order.init`): facing: which way to face while holding */\n\thold: Pick<OrderParams, 'facing'>\n\t/** What a `attack` order is given (`Order.init`): the target to attack and the facing to keep */\n\tattack: Pick<OrderParams, 'target' | 'facing'>\n\t/** What a `attackMove` order is given (`Order.init`): the point to advance to, fighting what it meets, and the facing at the end */\n\tattackMove: Pick<OrderParams, 'point' | 'facing'>\n\t/** What a `followPath` order is given (`Order.init`): the map path to follow by name and which end (`towards`) to go to */\n\tfollowPath: Pick<OrderParams, 'path' | 'towards'>\n\t/** What a `attackPath` order is given (`Order.init`): the map path to advance along, fighting, and which end (`towards`) to go to */\n\tattackPath: Pick<OrderParams, 'path' | 'towards'>\n\t/** What a `patrolPath` order is given (`Order.init`): the map path to patrol along and which end (`towards`) to start towards */\n\tpatrolPath: Pick<OrderParams, 'path' | 'towards'>\n\t/** What a `patrol` order is given (`Order.init`): the point to patrol to and back from, and the facing */\n\tpatrol: Pick<OrderParams, 'point' | 'facing'>\n\t/** What a `follow` order is given (`Order.init`): the entity to follow */\n\tfollow: Pick<OrderParams, 'target'>\n\t/** What a `attackGround` order is given (`Order.init`): the point to attack and optionally an entity there */\n\tattackGround: Pick<OrderParams, 'point' | 'target'>\n\t/** What a `cast` order is given (`Order.init`): the ability, an item to use, the target, the point and the second point (`to`) of a vector ability */\n\tcast: Pick<OrderParams, 'ability' | 'item' | 'target' | 'point' | 'to'>\n\t/** What a `harvest` order is given (`Order.init`): the resource entity to gather from */\n\tharvest: Pick<OrderParams, 'target'>\n\t/** What a `return` order is given (`Order.init`): the hall to hand in at; the resource to go back to when left out */\n\treturn: Pick<OrderParams, 'target'>\n\t/** What a `build` order is given (`Order.init`): the unit type to build, the point and the facing of the site */\n\tbuild: Pick<OrderParams, 'unitType' | 'point' | 'facing'>\n\t/** What a `construct` order is given (`Order.init`): the unfinished building to work on */\n\tconstruct: Pick<OrderParams, 'target'>\n\t/** What a `repair` order is given (`Order.init`): the building to repair */\n\trepair: Pick<OrderParams, 'target'>\n\t/** What a `pickUp` order is given (`Order.init`): the item on the ground to pick up (`target`) and the inventory slot */\n\tpickUp: Pick<OrderParams, 'target' | 'item'>\n\t/** What a `dropItem` order is given (`Order.init`): the inventory slot to drop, and the point or the unit to drop it at */\n\tdropItem: Pick<OrderParams, 'item' | 'point' | 'target'>\n\t/** What a `board` order is given (`Order.init`): the transport to board */\n\tboard: Pick<OrderParams, 'target'>\n\t/** What a `load` order is given (`Order.init`): the unit for a transport to load */\n\tload: Pick<OrderParams, 'target'>\n\t/** What a `unload` order is given (`Order.init`): the point to unload the cargo at */\n\tunload: Pick<OrderParams, 'point'>\n}\n\n/**\n * What an order of a type is given: its `OrderInits` entry, every order's fields (`OrderParams`) for a type not in it\n *\n * @beta\n */\nexport type OrderInitOf<Type extends string> = Type extends keyof OrderInits ? OrderInits[Type] : OrderParams\n\n/**\n * What a command asks a unit to do: the order's type and what it is given (`OrderInitOf`). Turned into an `Order` once\n * it is accepted\n *\n * @beta\n */\nexport type OrderInit<Type extends string = string> = {\n\ttype: Type\n\t/**\n\t * The formation units ordered to a point together take, by id (`FormationDef`): the engine's `rows`, `circle`,\n\t * `square` or `none`, or a game's own. What the rules say (`RuleSettings.movement.formation`: `rows`) when left out\n\t */\n\tformation?: string\n} & OrderInitOf<Type>\n\n/**\n * Logic behind an order type. Orders are the only way units act, which is what\n * makes queueing work for everything. Game modules can register their own.\n *\n * `State` is what it keeps in the order (`Order.state`), every field optional: the order starts with none of them.\n * `OrderStates` names each order type's, for `registry.order(type)` to hand back the behaviour typed\n *\n * @public\n */\nexport interface OrderBehavior<State extends object = Record<string, any>, Init extends object = OrderParams> {\n\t/** The order type this behaviour handles, the key of `registry.order` and of `Order.type` */\n\ttype: string\n\t/** Units ordered to a point together are spread out in a formation instead of all walking to the same spot */\n\tformation?: boolean\n\t/** Whether the entity is able to carry out this order at all */\n\taccepts(world: World, entity: Entity, init: Init): boolean\n\t/** Called once when the order reaches the front of the queue */\n\tstart?(world: World, entity: Entity, order: Order<State, Init>): void\n\t/** Runs each tick while the order is at the front; returns whether it is still running, done or failed. `dt` is the tick's seconds */\n\tupdate(world: World, entity: Entity, order: Order<State, Init>, dt: number): OrderStatus\n\t/** Called when the order finishes or is interrupted, to undo anything it left behind */\n\tend?(world: World, entity: Entity, order: Order<State, Init>): void\n\t/**\n\t * Whether the unit is in the middle of it and cannot be called away (a cast past turning back): what was to come\n\t * after is dropped, it is finished first (`interrupt`). Never, when left out\n\t */\n\tcommitted?(order: Order<State, Init>): boolean\n\t/**\n\t * Whether the unit stands waiting by a fight for a spot in it (an attack or an attack-move held up: `holdOff`): an\n\t * ally on its way may ask it aside (`settings.movement.makesWay`). Never, when left out\n\t */\n\twaiting?(order: Order<State, Init>): boolean\n\t/** Whether the unit keeps something up that being stunned breaks off (a channelled ability). Never, when left out */\n\tchannelling?(order: Order<State, Init>): boolean\n\t/** Whether the unit has begun what it builds (its site is down): what it builds is counted as itself. Never, when left out */\n\tbuilding?(order: Order<State, Init>): boolean\n}\n\n/**\n * A fact the engine asks of an order, its behaviour's to say (`OrderBehavior.committed`, `waiting`, `channelling`,\n * `building`)\n *\n * @beta\n */\nexport type OrderFact = 'committed' | 'waiting' | 'channelling' | 'building'\n\n/**\n * What each order type keeps in its orders (`Order.state`), by type: the engine's, and a game's own added to it by\n * declaration merging, for `registry.order(type)` to say what its behaviour keeps:\n *\n * ```ts\n * declare module '@v12-engine/engine' {\n * \tinterface OrderStates {\n * \t\t'mygame.dig': { dug?: number }\n * \t}\n * }\n * ```\n *\n * @beta\n */\nexport interface OrderStates {\n\t/** What a `move` order keeps in `Order.state` */\n\tmove: NoState\n\t/** What a `hold` order keeps in `Order.state` */\n\thold: HoldState\n\t/** What a `attack` order keeps in `Order.state` */\n\tattack: AttackState\n\t/** What a `attackMove` order keeps in `Order.state` */\n\tattackMove: AdvanceState\n\t/** What a `followPath` order keeps in `Order.state` */\n\tfollowPath: AlongPath\n\t/** What a `attackPath` order keeps in `Order.state` */\n\tattackPath: AlongPath & AdvanceState\n\t/** What a `patrol` order keeps in `Order.state` */\n\tpatrol: PatrolState\n\t/** What a `follow` order keeps in `Order.state` */\n\tfollow: FollowState\n\t/** What a `attackGround` order keeps in `Order.state` */\n\tattackGround: AttackGroundState\n\t/** What a `cast` order keeps in `Order.state` */\n\tcast: CastState\n\t/** What a `harvest` order keeps in `Order.state` */\n\tharvest: HarvestState\n\t/** What a `return` order keeps in `Order.state` */\n\treturn: HarvestState\n\t/** What a `build` order keeps in `Order.state` */\n\tbuild: BuildState\n\t/** What a `construct` order keeps in `Order.state` */\n\tconstruct: WorkState\n\t/** What a `repair` order keeps in `Order.state` */\n\trepair: RepairState\n\t/** What a `pickUp` order keeps in `Order.state` */\n\tpickUp: ItemOrderState\n\t/** What a `dropItem` order keeps in `Order.state` */\n\tdropItem: ItemOrderState\n\t/** What a `board` order keeps in `Order.state` */\n\tboard: BoardState\n\t/** What a `load` order keeps in `Order.state` */\n\tload: LoadState\n\t/** What a `unload` order keeps in `Order.state` */\n\tunload: UnloadState\n}\n\n/**\n * What an order that keeps nothing keeps\n *\n * @beta\n */\nexport type NoState = Record<string, never>\n\n/**\n * What an order of a type keeps: its `OrderStates` entry, any plain data for a type not in it\n *\n * @beta\n */\nexport type OrderStateOf<Type extends string> = Type extends keyof OrderStates ? OrderStates[Type] : Record<string, any>\n\n/**\n * The part of a tick a system runs in, see `PHASES` in the scheduler\n *\n * @beta\n */\nexport type SystemPhase = 'commands' | 'decide' | 'move' | 'resolve' | 'cleanup'\n\n/**\n * Something that runs every tick, or every few: moves units, lands attacks, works out what each team sees.\n * When it runs is worked out once, from its phase, then from what it says it comes before and after.\n *\n * @public\n */\nexport interface System {\n\t/** Unique in a world. A game's system with the name of a core one takes its place */\n\tname: string\n\t/** `cleanup` when left out: after everything else in the tick */\n\tphase?: SystemPhase\n\t/** Names of systems in the same phase this one runs ahead of, or after */\n\tbefore?: string[]\n\t/** Names of systems in the same phase this one runs after */\n\tafter?: string[]\n\t/** Runs once in so many ticks, for work that does not need doing every tick. Every tick when left out */\n\tevery?: number\n\t/** With `every`, the tick in each round it runs at: systems with the same `every` and other offsets spread the work */\n\toffset?: number\n\t/**\n\t * `dt` is the time since it last ran: the length of a tick, times `every`. Before `each`, for a system that has\n\t * both. One of the two is needed\n\t */\n\tupdate?(world: World, dt: number): void\n\t/**\n\t * What `each` is run for (OB5): every unit (`'units'`, when left out, in `World.units`' order), what has a component,\n\t * in the order of its id (`EntityIndex.ordered`: a system about a few, like the buildings that train, does not look\n\t * at every unit and tree), or the units a test says yes to. The two orders differ for scenery woken into a unit\n\t * (`Spawning.wake`), which `World.units` has last: moving a system from one to the other can change which of two\n\t * equals goes first, unless it breaks ties by id\n\t *\n\t * @beta\n\t */\n\tover?: SystemOver\n\t/**\n\t * Run for each entity of `over`, in order, after `update`. The dead are not left out: a system that wants only the\n\t * living says so\n\t *\n\t * @beta\n\t */\n\teach?(world: World, entity: Entity, dt: number): void\n\t/**\n\t * What it keeps in itself, for a save: plain data. For state that is easier kept in a system than in a component\n\t * (`World.state`): a computer player's plans, a director's mood\n\t */\n\tsave?(world: World): unknown\n\t/** Takes back what `save` gave, in a world loaded from a save: when it is made, or added again (`addSystem`) */\n\trestore?(world: World, data: unknown): void\n}\n\n/**\n * What a system runs `each` for (`System.over`): every unit, what has a component, or the units a test says yes to\n *\n * @beta\n */\nexport type SystemOver = 'units' | Component<unknown, unknown> | ((entity: Entity, world: World) => boolean)\n\n/**\n * A system, or what makes one for each world: for a system that keeps state of its own, which belongs to one game\n *\n * @public\n */\nexport type SystemDef = System | ((world: World) => System)\n\n/**\n * What is thrown for a component or an event of its own that a game uses without listing it (`Rules.components`,\n * `Rules.events`): no world finds it by its id, so a save, a snapshot or the index would lose it\n *\n * @beta\n */\nexport class UnlistedError extends Error {\n\tconstructor(\n\t\t/** What it is: a component or an event */\n\t\treadonly kind: 'component' | 'event',\n\t\t/** Its id */\n\t\treadonly id: string,\n\t\t/** The id of the game that used it */\n\t\treadonly game: string\n\t) {\n\t\tsuper(`The ${kind} \"${id}\" is used by the game \"${game}\" without being listed in it: add it to Rules.${kind}s, as its timers and listeners are`)\n\t\tthis.name = 'UnlistedError'\n\t}\n}\n\n/** A list's entries by id, with their place: worked out once a list (`tile`, `resource`, `tunable` are asked every tick) */\nconst indexes = new WeakMap<readonly { id: string }[], Map<string, { def: never; at: number }>>()\nfunction indexOf<T extends { id: string }>(list: readonly T[]): Map<string, { def: T; at: number }> {\n\tlet index = indexes.get(list)\n\tif (!index) indexes.set(list, (index = new Map(list.map((def, at) => [def.id, { def: def as never, at }]))))\n\treturn index as Map<string, { def: T; at: number }>\n}\n\n/**\n * The registry of a game's definitions and behaviours: unit types, abilities, orders, systems, buffs and the rest, by id\n *\n * @public\n */\nexport class Registry {\n\t/** The game's unit types, buildings and resources (`Rules.units`) */\n\treadonly units = new Definitions<UnitTypeDef>('unit type', undefined, (def) => {\n\t\tif (def.kind !== 'unit' && !def.footprint) throw new Error(`Unit type \"${def.id}\" needs a footprint`)\n\t})\n\t/** The orders units can be given, the engine's and the game's, by type */\n\treadonly orders = new Definitions<OrderBehavior>('order type', (behavior) => behavior.type)\n\t/** How groups line up (`Rules.formations`) */\n\treadonly formations = new Definitions<FormationDef>('formation')\n\t/** The game's research (`Rules.upgrades`) */\n\treadonly upgrades = new Definitions<UpgradeDef>('upgrade')\n\t/** Every ability there is, of units, heroes and items alike (`Rules.abilities`) */\n\treadonly abilities = new Definitions<AbilityDef>('ability')\n\t/** The game's buffs (`Rules.buffs`) */\n\treadonly buffs = new Definitions<BuffDef>('buff')\n\t/** The game's items (`Rules.items`) */\n\treadonly items = new Definitions<ItemDef>('item')\n\t/** The tags of the game's items named and given a look (`Rules.tags`): a tag none names is its own word */\n\treadonly tags = new Definitions<TagDef>('tag')\n\t/** The game's races, in its order (`Rules.races`): none in a game without */\n\treadonly races = new Definitions<RaceDef>('race')\n\t/** The game's prefabs (`Rules.prefabs`) */\n\treadonly prefabs = new Definitions<PrefabDef>('prefab')\n\t/** The commands a world takes, the engine's and the game's, by type */\n\treadonly commands = new Definitions<CommandDef>('command', (def) => def.type)\n\t/** What each type of an ability's effect does, by type */\n\treadonly effects = new Definitions<EffectType>('effect type', (effect) => effect.type)\n\t/** A game's own ways of aiming an ability (`Rules.targetings`), by name */\n\treadonly targetings = new Definitions<Targeting>('way of aiming')\n\t/**\n\t * The kinds of definition a game's data is kept for (`DataKind`), each its collection: what the Data panel, mods,\n\t * saves and a game's reload walk, one loop each\n\t */\n\treadonly kinds: { readonly [K in DataKind]: Definitions<DataDefs[K]> } = {\n\t\tunits: this.units,\n\t\tabilities: this.abilities,\n\t\tbuffs: this.buffs,\n\t\titems: this.items,\n\t\tupgrades: this.upgrades,\n\t\traces: this.races\n\t}\n\t/** The components the game lists (`Rules.components`), and those its app keeps in its worlds, by id */\n\tprivate readonly components = new Map<string, Component<unknown>>()\n\t/** The engine's own components (`coreComponents`) and the listed, by id: what `component` finds, in one look */\n\tprivate readonly known = new Map<string, Component<unknown>>()\n\t/** The events of its own the game lists (`Rules.events`), by id */\n\tprivate readonly events = new Map<string, EventKey<unknown>>()\n\n\t/**\n\t * Takes in the engine's own components, which every game has (`coreComponents`)\n\t *\n\t * @internal\n\t */\n\tdefineCore(components: readonly Component<unknown>[]): void {\n\t\tfor (const component of components) if (!this.components.has(component.id)) this.known.set(component.id, component)\n\t}\n\n\t/** Takes in the components and events a game lists. Throws for an id that is there twice, another way */\n\tdefineParts(components: readonly Component<unknown>[], events: readonly EventKey<unknown>[]): void {\n\t\tfor (const component of components) {\n\t\t\tconst before = this.components.get(component.id)\n\t\t\tif (before && before !== component) throw new Error(`The component \"${component.id}\" is there twice`)\n\t\t\tthis.components.set(component.id, component)\n\t\t\tthis.known.set(component.id, component)\n\t\t}\n\t\tfor (const event of events) {\n\t\t\tconst before = this.events.get(event.id)\n\t\t\tif (before && before !== event) throw new Error(`The event \"${event.id}\" is there twice`)\n\t\t\tthis.events.set(event.id, event)\n\t\t}\n\t}\n\n\t/** A component of this game by its id: one the game lists, or one of the engine's own (`coreComponents`). None for any other */\n\tcomponent(id: string): Component<unknown> | undefined {\n\t\treturn this.known.get(id)\n\t}\n\n\t/** A component of this game by its id, as something of the world uses it: throws for one the game does not list (`UnlistedError`) */\n\tused(id: string): Component<unknown> {\n\t\tconst found = this.component(id)\n\t\tif (!found) throw new UnlistedError('component', id, this.game)\n\t\treturn found\n\t}\n\n\t/**\n\t * An event of the game's own by its id: listed, or the engine's (`core.`), as the engine defined it. One of a game's\n\t * that it does not list throws (`UnlistedError`). Never another game's: a process may hold more than one, each\n\t * defining an id its own way (E7)\n\t */\n\tevent(id: string): EventKey<unknown> | undefined {\n\t\tconst listed = this.events.get(id) ?? engineEventById(id)\n\t\tif (listed) return listed\n\t\tif (isGameEvent(id)) throw new UnlistedError('event', id, this.game)\n\t\treturn undefined\n\t}\n\n\t/**\n\t * The components the game lists, for what goes through them all: the map's fields they have\n\t *\n\t * @beta\n\t */\n\tlistedComponents(): Iterable<Component<unknown, unknown>> {\n\t\treturn this.components.values()\n\t}\n\n\t/** Whether the game lists a component or an event, or it is one of the engine's own */\n\tlists(kind: 'component' | 'event', id: string): boolean {\n\t\treturn kind === 'component' ? this.known.has(id) : this.events.has(id) || engineEventById(id) !== undefined\n\t}\n\n\t/** The log of the world this is the registry of, once there is one (`World.log`) */\n\tlog?: Logger\n\n\t/**\n\t * Takes the definitions of another registry of the same game over its own (`world.reload`): its unit types,\n\t * abilities, buffs, items, upgrades and races, the code of its effects and orders, its rules, and its module. Those\n\t * it has that the other has not are kept (a world may have units of them). What the game is made of otherwise (its\n\t * resources, stats, components, events) stays as it is: a world was made of it\n\t */\n\ttakeFrom(other: Registry): void {\n\t\tfor (const kind of DATA_KINDS) (this.kinds[kind] as Definitions<unknown>).takeFrom(other.kinds[kind] as Definitions<unknown>)\n\t\tthis.effects.takeFrom(other.effects)\n\t\tthis.targetings.takeFrom(other.targetings)\n\t\tthis.orders.takeFrom(other.orders)\n\t\tthis.formations.takeFrom(other.formations)\n\t\tthis.tags.takeFrom(other.tags)\n\t\tthis.settings = other.settings\n\t\tthis.score = other.score\n\t\tthis.day = other.day\n\t\tthis.report = other.report\n\t\tthis.tunables = other.tunables\n\t\tthis.files = new Map(other.files)\n\t\tthis.fileDefs = new Map(other.fileDefs)\n\t\tthis.upkeep = other.upkeep\n\t\tthis.module = other.module\n\t\t// what identifies the game is worked out again, of the module as it is now\n\t\tthis.hashed = this.dataHashed = undefined\n\t}\n\n\t/** Lowest threshold first. Empty for a game without upkeep */\n\tupkeep: UpkeepTier[] = []\n\t/** Id of the game module it was made from */\n\tgame = ''\n\t/** The game module it was made from */\n\tmodule: Rules | null = null\n\tprivate hashed?: string\n\n\t/** What identifies the game exactly, mods and code included (see `gameHash`). Worked out the first time it is asked for */\n\tget hash(): string {\n\t\treturn (this.hashed ??= this.module ? gameHash(this.module) : '')\n\t}\n\n\tprivate dataHashed?: string\n\n\t/**\n\t * What identifies the game's data: everything but how its code reads (see `gameHash`). What a server and a player\n\t * check they share: the two run builds of the same code that print it differently\n\t */\n\tget dataHash(): string {\n\t\treturn (this.dataHashed ??= this.module ? gameHash(this.module, { code: false }) : '')\n\t}\n\n\t/** The version of what the game keeps in a save (`Rules.saves.version`): 1 for a game that says none */\n\tget saveVersion(): number {\n\t\treturn this.module?.saves?.version ?? 1\n\t}\n\t/** The game's own stats, next to the engine's (`Rules.stats`) */\n\tstats: StatDef[] = []\n\t/** The game put together with its packs (`assembleGame`): set as the registry is made of it */\n\tassembly: AssembledGame | null = null\n\t/** The engine's parts and the game's that give an entity something as it is made (`Component.onSpawn`), in order */\n\tspawning: readonly Component<unknown, unknown>[] = []\n\t/** The engine's parts and the game's that call something off as an entity leaves its owner (`Component.onLeave`) */\n\tleaving: readonly Component<unknown, unknown>[] = []\n\t/** The engine's parts and the game's that may have a structure stand open, in nobody's way (`Component.passable`) */\n\tpassing: readonly Component<unknown, unknown>[] = []\n\t/** Whether a structure stands open now, in nobody's way, by its parts (`Component.passable`): a gate opened */\n\tstandsOpen(entity: Entity): boolean {\n\t\tfor (const part of this.passing) if (entity.has(part) && part.passable!(entity.get(part)!, entity)) return true\n\t\treturn false\n\t}\n\t/** What the game's packs add to a unit's stats (`GamePack.stats`): a hero's growth */\n\tstatFields: StatField[] = []\n\t/** How each event of the world is told to a player, the engine's then the packs' (`replicateEvent`), in order */\n\treplications: readonly ReplicatedEvent[] = []\n\t/** The parts of a player's snapshot, the engine's then the packs' (`SnapshotField`), in order */\n\tsnapshotFields: readonly SnapshotField[] = []\n\t/** What the game counts of its players (`RuleSettings.score`), its stats made: null for a game that counts nothing */\n\tscore: ResolvedScore | null = null\n\t/** What each of the game's own files was read as (`Rules.files`), by id */\n\tprivate files = new Map<string, unknown>()\n\t/** The game's own files (`Rules.files`), by id */\n\tprivate fileDefs = new Map<string, GameFileDef<unknown>>()\n\n\t/** What the rules read of a file of the game's own data (`Rules.files`): throws for one the game does not list */\n\tfile<T>(def: GameFileDef<T>): T {\n\t\tif (!this.files.has(def.id)) throw new Error(`The file \"${def.id}\" is not the game's: list it in Rules.files`)\n\t\treturn this.files.get(def.id) as T\n\t}\n\n\t/** Puts what a file of the game's is read as, for this registry's world alone: the editor's panel, as it is edited */\n\tsetFile<T>(def: GameFileDef<T>, value: T): void {\n\t\tthis.files.set(def.id, value)\n\t\tthis.fileDefs.set(def.id, def as GameFileDef<unknown>)\n\t}\n\n\t/** A file of the game's own data by its id (`waves.json`): what reads it, for an editor that writes it. None for one the game does not list */\n\tfileDef(id: string): GameFileDef<unknown> | undefined {\n\t\treturn this.fileDefs.get(id)\n\t}\n\n\t/** A prefab of the game's by id, for `world.spawnPrefab`; throws for one there is not */\n\tprefab(id: string): PrefabDef {\n\t\tconst def = this.prefabs.find(id)\n\t\tif (!def) throw new Error(`No prefab is called \"${id}\": list it in Rules.prefabs, or give the prefab itself`)\n\t\treturn def\n\t}\n\n\t/** What the ground can be painted with, in the order of their indices: the first is 1 (`Rules.tiles`) */\n\ttiles: TileDef[] = []\n\t/** The game's layers of cells (`Rules.cellLayers`): what `Terrain.cells` is keyed by, with what each means */\n\tcellLayers: CellLayerDef[] = []\n\t/** The numbers of the rules to be tuned while the game plays (`Rules.tunables`) */\n\ttunables: TunableDef[] = []\n\n\t/** A tunable by id, or nothing for one the game does not have */\n\ttunable(id: string): TunableDef | undefined {\n\t\treturn indexOf(this.tunables).get(id)?.def\n\t}\n\n\t/** The index of a tile of the game, for painting the ground in code: `terrain.tiles[cell] = registry.tile('road')` */\n\ttile(id: string): number {\n\t\tconst found = indexOf(this.tiles).get(id)\n\t\tif (!found) throw new Error(`Unknown tile \"${id}\"`)\n\t\treturn found.at + 1\n\t}\n\n\t/** The ids of the game's tiles, in the order of their indices */\n\tget tileIds(): string[] {\n\t\treturn this.tiles.map((tile) => tile.id)\n\t}\n\t/** Every stat there is in the game, the engine's first */\n\tstatKeys: string[] = [...CORE_STAT_KEYS]\n\t/** Every stat of the game at 0, its own at their default: what base stats start from */\n\tstatDefaults: Readonly<Stats> = noStats() as Stats\n\t/** The game's numbers that are not about any one unit (`Rules.settings`) */\n\tsettings: Readonly<RuleSettings> = defaultSettings\n\t/** Null for a game where it is always day */\n\tday: DayCycle | null = null\n\t/** What the game tells each player about itself, see `Rules.report`. Asked by the session that runs the world */\n\treport: ((world: World, player: PlayerId) => Record<string, unknown>) | null = null\n\t/** The resources of the game, in the order players are shown them */\n\tresources: ResourceDef[] = []\n\t/**\n\t * The resource prices, bounties, revives and sales are in: the game's money. Null for a game without one,\n\t * where there is nothing of that kind to pay with\n\t */\n\tcurrency: ResourceId | null = null\n\t/** The command type, or undefined for one the game does not have: commands come from outside, and may name anything */\n\tcommand(type: string): CommandDef | undefined {\n\t\treturn this.commands.find(type)\n\t}\n\n\t/** The definition of a resource, or undefined for one the game does not have */\n\tresource(id: ResourceId): ResourceDef | undefined {\n\t\treturn indexOf(this.resources).get(id)?.def\n\t}\n\n\t/** A unit type by id: throws for one the game does not have (`units`) */\n\tunit(id: string): UnitTypeDef {\n\t\treturn this.units.get(id)\n\t}\n\n\t/** An upgrade by id: throws for one the game does not have (`upgrades`) */\n\tupgrade(id: string): UpgradeDef {\n\t\treturn this.upgrades.get(id)\n\t}\n\n\t/** A race by id: throws for one the game does not have (`races`) */\n\trace(id: string): RaceDef {\n\t\treturn this.races.get(id)\n\t}\n\n\t/** An ability by id: throws for one the game does not have (`abilities`) */\n\tability(id: string): AbilityDef {\n\t\treturn this.abilities.get(id)\n\t}\n\n\t/** A buff by id: throws for one the game does not have (`buffs`) */\n\tbuff(id: string): BuffDef {\n\t\treturn this.buffs.get(id)\n\t}\n\n\t/** An item by id: throws for one the game does not have (`items`) */\n\titem(id: string): ItemDef {\n\t\treturn this.items.get(id)\n\t}\n\n\t/** What an effect type does: throws for one there is not (`effects`) */\n\teffect(type: string): EffectHandler {\n\t\treturn this.effects.get(type).run as EffectHandler\n\t}\n\n\t/** An order type's behaviour, typed by what its orders keep (`OrderStates`): throws for one there is not (`orders`) */\n\torder<Type extends string>(type: Type): OrderBehavior<OrderStateOf<Type>, OrderInitOf<Type>> {\n\t\treturn this.orders.get(type) as unknown as OrderBehavior<OrderStateOf<Type>, OrderInitOf<Type>>\n\t}\n\n\t/** A formation by id: throws for one there is not (`formations`) */\n\tformation(id: string): FormationDef {\n\t\treturn this.formations.get(id)\n\t}\n}\n"],"mappings":"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"}
|
package/dist/remains.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GamePack } from './packs/pack';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResourceId, UnitTypeDef } from './defs';
|
|
3
3
|
import type { Entity, PlayerId } from './entity';
|
|
4
4
|
import type { World } from './world';
|
|
5
5
|
/**
|
|
@@ -9,11 +9,13 @@ import type { World } from './world';
|
|
|
9
9
|
* @beta
|
|
10
10
|
*/
|
|
11
11
|
export interface RemainsSpec {
|
|
12
|
+
/** The unit type of the rubble or pile left behind, a resource-bearing type */
|
|
12
13
|
type: string;
|
|
14
|
+
/** How much of the resource it holds; the type's `resource.amount` when left out */
|
|
13
15
|
amount?: number;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
|
-
* What the remains of a game are made of (`
|
|
18
|
+
* What the remains of a game are made of (`remainsPack`)
|
|
17
19
|
*
|
|
18
20
|
* @beta
|
|
19
21
|
*/
|
|
@@ -39,10 +41,10 @@ export interface RemainsOptions {
|
|
|
39
41
|
* @beta
|
|
40
42
|
*/
|
|
41
43
|
export declare const pileOf: import("./components").Component<{
|
|
42
|
-
kind:
|
|
44
|
+
kind: ResourceId;
|
|
43
45
|
amount: number;
|
|
44
46
|
}, {
|
|
45
|
-
kind:
|
|
47
|
+
kind: ResourceId;
|
|
46
48
|
amount: number;
|
|
47
49
|
}>;
|
|
48
50
|
/** The piles there are and the rubble to put down once the building it is of is gone, kept with the world */
|
|
@@ -72,7 +74,7 @@ export declare const pileTaken: import("./events").EventKey<{
|
|
|
72
74
|
pile: number;
|
|
73
75
|
by: number;
|
|
74
76
|
player: PlayerId;
|
|
75
|
-
kind:
|
|
77
|
+
kind: ResourceId;
|
|
76
78
|
amount: number;
|
|
77
79
|
}>;
|
|
78
80
|
/**
|
|
@@ -88,7 +90,7 @@ export declare function rubbleType(def: {
|
|
|
88
90
|
w: number;
|
|
89
91
|
d: number;
|
|
90
92
|
};
|
|
91
|
-
kind:
|
|
93
|
+
kind: ResourceId;
|
|
92
94
|
amount?: number;
|
|
93
95
|
slots?: number;
|
|
94
96
|
}): UnitTypeDef;
|
|
@@ -102,11 +104,11 @@ export declare function rubbleType(def: {
|
|
|
102
104
|
export declare function pileType(def: {
|
|
103
105
|
id: string;
|
|
104
106
|
name?: string;
|
|
105
|
-
kind:
|
|
107
|
+
kind: ResourceId;
|
|
106
108
|
amount?: number;
|
|
107
109
|
}): UnitTypeDef & {
|
|
108
110
|
pile: {
|
|
109
|
-
kind:
|
|
111
|
+
kind: ResourceId;
|
|
110
112
|
amount: number;
|
|
111
113
|
};
|
|
112
114
|
};
|
|
@@ -116,4 +118,4 @@ export declare function pileType(def: {
|
|
|
116
118
|
*
|
|
117
119
|
* @beta
|
|
118
120
|
*/
|
|
119
|
-
export declare function
|
|
121
|
+
export declare function remainsPack(options?: RemainsOptions): GamePack;
|
package/dist/remains.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { defineComponent } from "./components.js";
|
|
2
|
+
import { defineEngineEvent } from "./events.js";
|
|
3
|
+
import { deposit } from "./entity.js";
|
|
4
|
+
import { earn } from "./player.js";
|
|
5
|
+
import { defineHook } from "./hooks.js";
|
|
6
|
+
import "./map/types.js";
|
|
7
|
+
//#region src/remains.ts
|
|
8
|
+
/**
|
|
9
|
+
* What a pile holds: the resource and how much. Told to everyone, for its look and its tooltip
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
var pileOf = defineComponent({
|
|
14
|
+
id: "core.pile",
|
|
15
|
+
replicate: "everyone"
|
|
16
|
+
});
|
|
17
|
+
/** The piles there are and the rubble to put down once the building it is of is gone, kept with the world */
|
|
18
|
+
var remains = defineComponent({
|
|
19
|
+
id: "core.remains",
|
|
20
|
+
default: () => ({
|
|
21
|
+
piles: [],
|
|
22
|
+
rubble: {}
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* A pile was picked up: by whom (a unit's id and its owner), what and how much
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
var pileTaken = defineEngineEvent({
|
|
31
|
+
id: "core.pileTaken",
|
|
32
|
+
replicate: "everyone"
|
|
33
|
+
});
|
|
34
|
+
/** The player the map's neutral things are of: rubble and piles are */
|
|
35
|
+
function neutralOf(world) {
|
|
36
|
+
for (const player of world.players.values()) if (player.neutral) return player.id;
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
/** Spawns remains of a type, holding so much of their resource */
|
|
40
|
+
function putDown(world, spec, x, z) {
|
|
41
|
+
if (!world.registry.units.has(spec.type)) return void 0;
|
|
42
|
+
const entity = world.spawn(spec.type, neutralOf(world), {
|
|
43
|
+
x,
|
|
44
|
+
z
|
|
45
|
+
});
|
|
46
|
+
if (spec.amount !== void 0 && entity.get(deposit)) entity.get(deposit).amount = spec.amount;
|
|
47
|
+
return entity;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A type of rubble, to put in the game's units: a resource that blocks its footprint, gathered (cleared) as `kind`
|
|
51
|
+
* by the game's workers, with no look of its own (the game's looks give it one)
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
function rubbleType(def) {
|
|
56
|
+
return {
|
|
57
|
+
id: def.id,
|
|
58
|
+
name: def.name ?? "Rubble",
|
|
59
|
+
kind: "resource",
|
|
60
|
+
radius: Math.max(def.footprint.w, def.footprint.d) / 2,
|
|
61
|
+
footprint: def.footprint,
|
|
62
|
+
stats: { health: 1 },
|
|
63
|
+
sight: 0,
|
|
64
|
+
resource: {
|
|
65
|
+
id: def.kind,
|
|
66
|
+
amount: def.amount ?? 100,
|
|
67
|
+
slots: def.slots ?? 3
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A type of pile, to put in the game's units: something lying on the ground that blocks nothing, is fought by nobody,
|
|
73
|
+
* and is handed (`pileOf`: its kind and how much) to who walks over it. `kind` and `amount` are what it holds when the
|
|
74
|
+
* death that drops it says nothing else
|
|
75
|
+
*
|
|
76
|
+
* @beta
|
|
77
|
+
*/
|
|
78
|
+
function pileType(def) {
|
|
79
|
+
return {
|
|
80
|
+
id: def.id,
|
|
81
|
+
name: def.name ?? "Pile",
|
|
82
|
+
kind: "unit",
|
|
83
|
+
radius: .2,
|
|
84
|
+
stats: {
|
|
85
|
+
health: 1,
|
|
86
|
+
moveSpeed: 0
|
|
87
|
+
},
|
|
88
|
+
sight: 0,
|
|
89
|
+
invulnerable: true,
|
|
90
|
+
ignored: true,
|
|
91
|
+
pile: {
|
|
92
|
+
kind: def.kind,
|
|
93
|
+
amount: def.amount ?? 10
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Remains that are things for a game (`RemainsOptions`): rubble where buildings fell, piles where units did. The game
|
|
99
|
+
* is the same otherwise; its units list the types (`rubbleType`, `pileType`, or its own)
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
function remainsPack(options = {}) {
|
|
104
|
+
const reach = options.reach ?? .8;
|
|
105
|
+
const picksUp = options.picksUp ?? ((_world, unit) => !unit.isStructure && !unit.isResource && unit.alive && !unit.get(pileOf));
|
|
106
|
+
const deathHook = defineHook({
|
|
107
|
+
hook: "death",
|
|
108
|
+
id: "core.remains.death",
|
|
109
|
+
run(world, event) {
|
|
110
|
+
const { entity: dead, killer } = event;
|
|
111
|
+
const state = world.state(remains);
|
|
112
|
+
if (dead.isStructure && options.rubble) {
|
|
113
|
+
const said = typeof options.rubble === "function" ? options.rubble(world, dead) : options.rubble;
|
|
114
|
+
const spec = typeof said === "string" ? { type: said } : said;
|
|
115
|
+
if (spec) state.rubble[dead.id] = {
|
|
116
|
+
...spec,
|
|
117
|
+
x: dead.pos.x,
|
|
118
|
+
z: dead.pos.z
|
|
119
|
+
};
|
|
120
|
+
} else if (!dead.isStructure && !dead.isResource && options.piles) {
|
|
121
|
+
const spec = options.piles(world, dead, killer);
|
|
122
|
+
const pile = spec && putDown(world, spec, dead.pos.x, dead.pos.z);
|
|
123
|
+
if (!pile) return;
|
|
124
|
+
const kept = pile.def.pile;
|
|
125
|
+
const kind = kept?.kind ?? world.registry.resources[0]?.id ?? "gold";
|
|
126
|
+
pile.set(pileOf, {
|
|
127
|
+
kind,
|
|
128
|
+
amount: spec.amount ?? kept?.amount ?? 10
|
|
129
|
+
});
|
|
130
|
+
state.piles.push(pile.id);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const removeHook = defineHook({
|
|
135
|
+
hook: "remove",
|
|
136
|
+
id: "core.remains.remove",
|
|
137
|
+
run(world, entity) {
|
|
138
|
+
const state = world.state(remains);
|
|
139
|
+
const rubble = state.rubble[entity.id];
|
|
140
|
+
if (!rubble) return;
|
|
141
|
+
delete state.rubble[entity.id];
|
|
142
|
+
putDown(world, rubble, rubble.x, rubble.z);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const near = [];
|
|
146
|
+
return {
|
|
147
|
+
id: "remains",
|
|
148
|
+
options,
|
|
149
|
+
components: [remains, pileOf],
|
|
150
|
+
events: [pileTaken],
|
|
151
|
+
hooks: [deathHook, removeHook],
|
|
152
|
+
systems: [{
|
|
153
|
+
name: "core.remains.piles",
|
|
154
|
+
update(world) {
|
|
155
|
+
const state = world.state(remains);
|
|
156
|
+
if (!state.piles.length) return;
|
|
157
|
+
state.piles = state.piles.filter((id) => {
|
|
158
|
+
const pile = world.get(id);
|
|
159
|
+
const holds = pile?.get(pileOf);
|
|
160
|
+
if (!pile?.alive || !holds) return false;
|
|
161
|
+
for (const unit of [...world.spatial.query(pile.pos.x, pile.pos.z, reach, near)]) {
|
|
162
|
+
if (world.player(unit.owner).neutral || !picksUp(world, unit, pile)) continue;
|
|
163
|
+
const dx = unit.pos.x - pile.pos.x;
|
|
164
|
+
const dz = unit.pos.z - pile.pos.z;
|
|
165
|
+
const within = reach + unit.def.radius;
|
|
166
|
+
if (dx * dx + dz * dz > within * within) continue;
|
|
167
|
+
const { kind, amount } = holds;
|
|
168
|
+
earn(world.player(unit.owner).resources, kind, amount);
|
|
169
|
+
world.events.emit(pileTaken, {
|
|
170
|
+
pile: pile.id,
|
|
171
|
+
by: unit.id,
|
|
172
|
+
player: unit.owner,
|
|
173
|
+
kind,
|
|
174
|
+
amount
|
|
175
|
+
});
|
|
176
|
+
world.kill(pile, unit, false, "taken");
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}]
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { pileOf, pileTaken, pileType, remains, remainsPack, rubbleType };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=remains.js.map
|