@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/world.js
ADDED
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { GameEnded, modOfPart, siteKey, siteOf, siteWords } from "./errors.js";
|
|
2
|
+
import { isScenery } from "./defs.js";
|
|
3
|
+
import { StateStore } from "./components.js";
|
|
4
|
+
import { statsOf } from "./stats.js";
|
|
5
|
+
import { Emitter } from "./events.js";
|
|
6
|
+
import { cellsChanged, checkpoint, commandHandled, commandRejected, entityRemoved, environmentChanged, groundReshaped, messageSent, worldFailed } from "./engineEvents.js";
|
|
7
|
+
import { constructionSite } from "./systems/construction.js";
|
|
8
|
+
import { detection, exposure } from "./entity.js";
|
|
9
|
+
import { Player } from "./player.js";
|
|
10
|
+
import { toMessage } from "./messages.js";
|
|
11
|
+
import { Hooks } from "./hooks.js";
|
|
12
|
+
import { dashing } from "./dashing.js";
|
|
13
|
+
import { queryWorld } from "./query.js";
|
|
14
|
+
import { Areas } from "./areas.js";
|
|
15
|
+
import { WorldMap, mapInfo, names } from "./names.js";
|
|
16
|
+
import { hasGroundSpeeds, slowsOnFoot, stopsOnFoot } from "./groundSpeed.js";
|
|
17
|
+
import { checksOf } from "./debug2.js";
|
|
18
|
+
import { Timers } from "./timers.js";
|
|
19
|
+
import { Sequences, coreTimers } from "./sequences.js";
|
|
20
|
+
import { cellsIn, rememberUnseenCells } from "./cellLayers.js";
|
|
21
|
+
import { BuildGrid } from "./grid.js";
|
|
22
|
+
import { settleRaces } from "./races.js";
|
|
23
|
+
import { helpListeners } from "./orders/idle.js";
|
|
24
|
+
import { executeCommand } from "./commands.js";
|
|
25
|
+
import { Dialog } from "./dialog.js";
|
|
26
|
+
import { playFx, stopFx } from "./effects.js";
|
|
27
|
+
import { coreHooks } from "./features.js";
|
|
28
|
+
import { errorFields, rootLogger } from "./log.js";
|
|
29
|
+
import { definitionChanged, definitionIn, mergeValues, redefineIn, redefinitions } from "./gameData.js";
|
|
30
|
+
import { Life } from "./life.js";
|
|
31
|
+
import { Rng } from "./rng.js";
|
|
32
|
+
import { Objectives } from "./objectives.js";
|
|
33
|
+
import { applyTerrainPatch } from "./ground.js";
|
|
34
|
+
import { Clock } from "./clock.js";
|
|
35
|
+
import { Score } from "./score.js";
|
|
36
|
+
import { tunableChanged, tunings } from "./tunables.js";
|
|
37
|
+
import { FogOfWar } from "./fog.js";
|
|
38
|
+
import { Sight } from "./sight.js";
|
|
39
|
+
import { Sides } from "./sides.js";
|
|
40
|
+
import { Spawning } from "./spawning.js";
|
|
41
|
+
import { EntityIndex } from "./entityIndex.js";
|
|
42
|
+
import { AirNavigation, LayeredNavigation } from "./navigation/air.js";
|
|
43
|
+
import { Scheduler } from "./scheduler.js";
|
|
44
|
+
import { Computers } from "./computers.js";
|
|
45
|
+
import { SpatialIndex } from "./spatial.js";
|
|
46
|
+
import { spawnPrefab } from "./prefabs.js";
|
|
47
|
+
//#region src/world.ts
|
|
48
|
+
/**
|
|
49
|
+
* The simulation: the ground, entities, players, systems and rules of one game, stepped a tick at a time with `step`
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
var World = class {
|
|
54
|
+
/**
|
|
55
|
+
* Obstacles the navigation had no room for (`RecastNavigationOptions.maxObstacles`): what is put down past it does not block the way
|
|
56
|
+
*
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
obstaclesRefused = 0;
|
|
60
|
+
/**
|
|
61
|
+
* The ground the world stands on
|
|
62
|
+
*
|
|
63
|
+
* @beta
|
|
64
|
+
*/
|
|
65
|
+
terrain;
|
|
66
|
+
/**
|
|
67
|
+
* The ground it started on, where it was made from a map (S36): what a save keeps only the changes of
|
|
68
|
+
*
|
|
69
|
+
* @beta
|
|
70
|
+
*/
|
|
71
|
+
ground;
|
|
72
|
+
/**
|
|
73
|
+
* The ground and the air. Agents find their own layer, everything else is about the ground
|
|
74
|
+
*
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
nav;
|
|
78
|
+
/**
|
|
79
|
+
* The navigations the sides plan their routes on, of the buildings each knows (`Rules.paths: 'seen'`): routes
|
|
80
|
+
* of ground units are planned on their side's, and walked on `nav`. None where routes know everything
|
|
81
|
+
*
|
|
82
|
+
* @beta
|
|
83
|
+
*/
|
|
84
|
+
sidePaths;
|
|
85
|
+
/** The ground, the air and the water, to find where a kind of unit can be */
|
|
86
|
+
layers;
|
|
87
|
+
/** The navigation an entity goes on: the air for what flies, the water for boats where the map has it, the ground for the rest */
|
|
88
|
+
/**
|
|
89
|
+
* The ways a type of entity walks, flies or sails on (`navFor` for one made)
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
layerOf(def) {
|
|
94
|
+
return this.layers.layer(def);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* An id for an entity about to be made (`Spawning`)
|
|
98
|
+
*
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
newEntityId() {
|
|
102
|
+
return this.nextEntityId++;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The navigation an entity walks by: the air, the water or the ground, by its layer
|
|
106
|
+
*
|
|
107
|
+
* @beta
|
|
108
|
+
*/
|
|
109
|
+
navFor(entity) {
|
|
110
|
+
return this.layers.layer(entity.def);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The air alone
|
|
114
|
+
*
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
air;
|
|
118
|
+
/** The game's definitions: unit types, abilities, orders and the rest */
|
|
119
|
+
registry;
|
|
120
|
+
/**
|
|
121
|
+
* Which cells are taken by buildings and what can be built where
|
|
122
|
+
*
|
|
123
|
+
* @beta
|
|
124
|
+
*/
|
|
125
|
+
grid;
|
|
126
|
+
/**
|
|
127
|
+
* What each team has seen and sees, per cell
|
|
128
|
+
*
|
|
129
|
+
* @beta
|
|
130
|
+
*/
|
|
131
|
+
fog;
|
|
132
|
+
/**
|
|
133
|
+
* Index of entities by position, for asking what is near a point.
|
|
134
|
+
*
|
|
135
|
+
* Units are filed once a tick, where they stand as it starts (after the commands, before the systems: `step`).
|
|
136
|
+
* A unit that moves during the tick (the `move` phase) is still filed where it was until the next, so a query in
|
|
137
|
+
* `resolve` searches by where units started and checks distance against where they are now: a unit that walked
|
|
138
|
+
* into range this tick may be found only the next. Structures are filed where they stand, as they are made
|
|
139
|
+
*
|
|
140
|
+
* @beta
|
|
141
|
+
*/
|
|
142
|
+
spatial;
|
|
143
|
+
/** What happened, for whoever watches: sessions, tests. Sent out at the end of each tick. Rules use `hooks` */
|
|
144
|
+
events = new Emitter();
|
|
145
|
+
/**
|
|
146
|
+
* What this world says about what it does: `world.log.warn('waves', 'nothing to send', { wave })`. Each entry says
|
|
147
|
+
* the game and the tick it is from, and goes to whoever asked (`world.log.to(sink)`) and to the logger the world
|
|
148
|
+
* was made under. It changes nothing in the world, and is not in a save
|
|
149
|
+
*/
|
|
150
|
+
log;
|
|
151
|
+
/**
|
|
152
|
+
* The engine's checks on itself this world runs (`DebugChecks`): what it was made with (`CreateWorldOptions.checks`),
|
|
153
|
+
* the process's (`setDebugChecks`) when it says nothing. Slow: tests and development
|
|
154
|
+
*
|
|
155
|
+
* @beta
|
|
156
|
+
*/
|
|
157
|
+
checks = checksOf(void 0);
|
|
158
|
+
/**
|
|
159
|
+
* Moved on by `invalidateStats` without an entity: every entity's stats are added up again when next asked for
|
|
160
|
+
*
|
|
161
|
+
* @beta
|
|
162
|
+
*/
|
|
163
|
+
statsVersion = 0;
|
|
164
|
+
/**
|
|
165
|
+
* What the debug tools follow of the rules as they run: hooks and listeners. Null when nobody asks, see `EventLog`
|
|
166
|
+
*
|
|
167
|
+
* @beta
|
|
168
|
+
*/
|
|
169
|
+
trace = null;
|
|
170
|
+
/** Where game modules and mods take part in damage, deaths, orders and the like, see `HookEvents` */
|
|
171
|
+
hooks;
|
|
172
|
+
/** The areas of the game, and who is in them */
|
|
173
|
+
areas;
|
|
174
|
+
/** What is set to go off later: `world.timers.after(30, waveComes)` */
|
|
175
|
+
timers;
|
|
176
|
+
/** Scripts of steps that run over time: `world.sequences.start(briefing)` */
|
|
177
|
+
sequences;
|
|
178
|
+
/** What each player is set to do, in a mission */
|
|
179
|
+
objectives;
|
|
180
|
+
/**
|
|
181
|
+
* What the game counts of its players (`RuleSettings.score`): `world.score.add(player, 'towersLost')`, `get`, `team`.
|
|
182
|
+
* Counts nothing in a game that does not ask
|
|
183
|
+
*
|
|
184
|
+
* @beta
|
|
185
|
+
*/
|
|
186
|
+
score;
|
|
187
|
+
/** What is said, by whom, to whom: `world.dialog.say(player, line)`, or `talk` in a sequence */
|
|
188
|
+
dialog;
|
|
189
|
+
/** The world's seeded random generator; the only source of randomness the simulation uses */
|
|
190
|
+
rng;
|
|
191
|
+
/** Every player of the world, by id */
|
|
192
|
+
players = /* @__PURE__ */ new Map();
|
|
193
|
+
/**
|
|
194
|
+
* Everything in the world, by id. Fallen heroes stay in here while they wait to be brought back
|
|
195
|
+
*
|
|
196
|
+
* @beta
|
|
197
|
+
*/
|
|
198
|
+
entities = /* @__PURE__ */ new Map();
|
|
199
|
+
/**
|
|
200
|
+
* The entities that act: the ones that move, fight, build or change by themselves, which is everything but scenery.
|
|
201
|
+
* Systems that run every tick go through these instead of `entities`, which on a big map is mostly trees.
|
|
202
|
+
*
|
|
203
|
+
* In the order each became a unit, which is the order of ids except for scenery woken later (`Spawning.wake`: a
|
|
204
|
+
* tree given a buff), which comes last, after units made before it. A save keeps this order, so a loaded world
|
|
205
|
+
* walks it the same. A component's index (`EntityIndex`, `SystemDef.over`) walks in id order instead, so code that
|
|
206
|
+
* picks the first of equals breaks the tie by id, not by which it met first, to stay the same either way
|
|
207
|
+
*/
|
|
208
|
+
units = /* @__PURE__ */ new Map();
|
|
209
|
+
/**
|
|
210
|
+
* The scenery each team sees right now, by team. Kept by the fog system whenever it works out what everyone sees:
|
|
211
|
+
* scenery never moves, so this only changes then. Lets a session describe what is in sight without testing every tree
|
|
212
|
+
*
|
|
213
|
+
* @beta
|
|
214
|
+
*/
|
|
215
|
+
sceneryInSight = /* @__PURE__ */ new Map();
|
|
216
|
+
/**
|
|
217
|
+
* Entities by owner, heroes by owner, shops. For questions that would otherwise go through every entity
|
|
218
|
+
*
|
|
219
|
+
* @beta
|
|
220
|
+
*/
|
|
221
|
+
index = new EntityIndex((id) => this.registry.used(id), () => this);
|
|
222
|
+
/**
|
|
223
|
+
* The shots in flight
|
|
224
|
+
*
|
|
225
|
+
* @beta
|
|
226
|
+
*/
|
|
227
|
+
projectiles = [];
|
|
228
|
+
/**
|
|
229
|
+
* The missiles in flight
|
|
230
|
+
*
|
|
231
|
+
* @beta
|
|
232
|
+
*/
|
|
233
|
+
missiles = [];
|
|
234
|
+
/**
|
|
235
|
+
* Effects waiting for their time to come
|
|
236
|
+
*
|
|
237
|
+
* @beta
|
|
238
|
+
*/
|
|
239
|
+
delayed = [];
|
|
240
|
+
/**
|
|
241
|
+
* The zones that are working on the ground now
|
|
242
|
+
*
|
|
243
|
+
* @beta
|
|
244
|
+
*/
|
|
245
|
+
zones = [];
|
|
246
|
+
/**
|
|
247
|
+
* Switches for trying things out. A game that is played for real leaves them off
|
|
248
|
+
*
|
|
249
|
+
* @beta
|
|
250
|
+
*/
|
|
251
|
+
cheats = {
|
|
252
|
+
/** Abilities and what is carried can be used again at once */
|
|
253
|
+
noCooldowns: false,
|
|
254
|
+
/** Abilities cost no mana, and are cast with none left */
|
|
255
|
+
noManaCosts: false,
|
|
256
|
+
/** What the players allowed the debug tools own (`debugPlayers`) takes no harm, and so does not die of it */
|
|
257
|
+
invulnerable: false,
|
|
258
|
+
/** How fast the game goes, 1 as it should, 0 paused: whoever runs it (a session in the page, a server) goes by it */
|
|
259
|
+
speed: 1
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Players who may use the debug commands (`debug.*`, see `debugCommands.ts`): who a session lets, a seat in the page
|
|
263
|
+
* that asked, a server started to. Not in a save: whoever loads it says again
|
|
264
|
+
*
|
|
265
|
+
* @beta
|
|
266
|
+
*/
|
|
267
|
+
debugPlayers = /* @__PURE__ */ new Set();
|
|
268
|
+
/**
|
|
269
|
+
* The entity each object of the map became, by the object's id (`MapObject.id`): what the map put down as the world
|
|
270
|
+
* was made of it (`createWorldFromMap`), and what the editor's Play here put down since (`debug.mapObject`), for the
|
|
271
|
+
* editor to find again what it moves and takes away (EQ10). Kept in a save
|
|
272
|
+
*
|
|
273
|
+
* @beta
|
|
274
|
+
*/
|
|
275
|
+
fromMap = /* @__PURE__ */ new Map();
|
|
276
|
+
/**
|
|
277
|
+
* Spots a team sees for a while without anything there to see them
|
|
278
|
+
*
|
|
279
|
+
* @beta
|
|
280
|
+
*/
|
|
281
|
+
reveals = [];
|
|
282
|
+
/**
|
|
283
|
+
* State of game modules and mods for the whole game, see `state`
|
|
284
|
+
*
|
|
285
|
+
* @beta
|
|
286
|
+
*/
|
|
287
|
+
states = new StateStore();
|
|
288
|
+
/**
|
|
289
|
+
* Items lying on the ground
|
|
290
|
+
*
|
|
291
|
+
* @beta
|
|
292
|
+
*/
|
|
293
|
+
items = [];
|
|
294
|
+
/**
|
|
295
|
+
* Runs the systems, in order, each as often as it asks
|
|
296
|
+
*
|
|
297
|
+
* @beta
|
|
298
|
+
*/
|
|
299
|
+
scheduler;
|
|
300
|
+
/** The computer players: who is seated, kept in a save and seated again by a load (`world.computers.seat`) */
|
|
301
|
+
computers;
|
|
302
|
+
/**
|
|
303
|
+
* What the world's numbers started from (`rng`): 1 when none was given. A computer player's own numbers start from it and its player
|
|
304
|
+
*
|
|
305
|
+
* @beta
|
|
306
|
+
*/
|
|
307
|
+
seed;
|
|
308
|
+
/** Simulation ticks per second */
|
|
309
|
+
tickRate;
|
|
310
|
+
/**
|
|
311
|
+
* Seconds per tick
|
|
312
|
+
*
|
|
313
|
+
* @beta
|
|
314
|
+
*/
|
|
315
|
+
dt;
|
|
316
|
+
/** The tick number the world is at, from 0; it goes up by one for each `step` */
|
|
317
|
+
tick = 0;
|
|
318
|
+
/**
|
|
319
|
+
* How things are hurt, healed and die (`Life`)
|
|
320
|
+
*
|
|
321
|
+
* @beta
|
|
322
|
+
*/
|
|
323
|
+
life = new Life(this);
|
|
324
|
+
/**
|
|
325
|
+
* What each team sees of the entities (`Sight`): the fog, what is invisible, the game's say
|
|
326
|
+
*
|
|
327
|
+
* @beta
|
|
328
|
+
*/
|
|
329
|
+
sight = new Sight(this);
|
|
330
|
+
/**
|
|
331
|
+
* Who is on whose side (`Sides`): teams, relations, shared vision and control
|
|
332
|
+
*
|
|
333
|
+
* @beta
|
|
334
|
+
*/
|
|
335
|
+
sides = new Sides(this);
|
|
336
|
+
/**
|
|
337
|
+
* How entities come into the world and are moved about in it (`Spawning`)
|
|
338
|
+
*
|
|
339
|
+
* @beta
|
|
340
|
+
*/
|
|
341
|
+
spawning = new Spawning(this);
|
|
342
|
+
/**
|
|
343
|
+
* The time of day (`Clock`): the hour, night, turned forward or stopped
|
|
344
|
+
*
|
|
345
|
+
* @beta
|
|
346
|
+
*/
|
|
347
|
+
clock = new Clock(this);
|
|
348
|
+
/** Team that won, once the game is decided */
|
|
349
|
+
winner = null;
|
|
350
|
+
/**
|
|
351
|
+
* What becomes of a part of the game that throws: a hook's handler, a listener, a system, a timer, an order, a
|
|
352
|
+
* command (`ErrorPolicy`). The game's own (`Rules.onError`), or whoever runs the world's; with neither it
|
|
353
|
+
* throws, as it always did. A server and a launched game end the game where nothing is said (`??= 'end'`)
|
|
354
|
+
*
|
|
355
|
+
* @beta
|
|
356
|
+
*/
|
|
357
|
+
errorPolicy;
|
|
358
|
+
/**
|
|
359
|
+
* Why the game ended on an error, once it has (`end`): the world is not stepped again
|
|
360
|
+
*
|
|
361
|
+
* @beta
|
|
362
|
+
*/
|
|
363
|
+
failure = null;
|
|
364
|
+
/**
|
|
365
|
+
* The parts switched off for having thrown (`disable`), by name (`siteKey`): kept in a save, and off again when it is loaded
|
|
366
|
+
*
|
|
367
|
+
* @beta
|
|
368
|
+
*/
|
|
369
|
+
disabled = /* @__PURE__ */ new Map();
|
|
370
|
+
/** True through a tick: an error then can end the game; outside one it is whoever called's */
|
|
371
|
+
stepping = false;
|
|
372
|
+
toldFailure = false;
|
|
373
|
+
/** Errors already answered `throw` further in: not asked about again on their way out */
|
|
374
|
+
thrown = /* @__PURE__ */ new WeakSet();
|
|
375
|
+
nextEntityId = 1;
|
|
376
|
+
nextId = 1;
|
|
377
|
+
commands = [];
|
|
378
|
+
/** Commands each player gave since the last tick, from outside one: what `commandLimit` counts */
|
|
379
|
+
given = /* @__PURE__ */ new Map();
|
|
380
|
+
/** Commands let go since the last tick, by player: told of at the next (`commandRejected`) */
|
|
381
|
+
overLimit = /* @__PURE__ */ new Map();
|
|
382
|
+
/** Those of them the sender numbered: each answered at the next tick, refused (`commandHandled`), for a screen that waits on it */
|
|
383
|
+
overLimitSeqs = [];
|
|
384
|
+
/**
|
|
385
|
+
* Commands a player may give between two ticks, at most (`issue`, from outside a tick): those past it are let go,
|
|
386
|
+
* and the tick says so once (`commandRejected`, reason `tooManyCommands`), and answers each the sender numbered,
|
|
387
|
+
* refused (`commandHandled`). A server's rate limit keeps far under it; this bounds what has none (a worker, a
|
|
388
|
+
* page's own host, a script gone wrong). The computer and scripts, which give theirs in a tick, are not counted.
|
|
389
|
+
* 100 when left out; `Infinity` for none
|
|
390
|
+
*
|
|
391
|
+
* @beta
|
|
392
|
+
*/
|
|
393
|
+
commandLimit = 100;
|
|
394
|
+
/**
|
|
395
|
+
* Makes an empty world of the options' terrain, rules and players; a game makes one with `createWorld` or
|
|
396
|
+
* `createWorldFromMap`, which also place the map's things and start the rules
|
|
397
|
+
*
|
|
398
|
+
* @beta
|
|
399
|
+
*/
|
|
400
|
+
constructor(options) {
|
|
401
|
+
this.terrain = options.terrain;
|
|
402
|
+
this.air = new AirNavigation(options.terrain.width, options.terrain.depth);
|
|
403
|
+
this.layers = new LayeredNavigation(options.navigation, this.air, options.waterNavigation);
|
|
404
|
+
this.nav = this.layers;
|
|
405
|
+
this.sidePaths = options.sidePaths;
|
|
406
|
+
this.registry = options.registry;
|
|
407
|
+
this.log = (options.log ?? rootLogger).child({
|
|
408
|
+
level: options.logLevel,
|
|
409
|
+
context: () => ({
|
|
410
|
+
game: this.registry.game,
|
|
411
|
+
tick: this.tick
|
|
412
|
+
})
|
|
413
|
+
});
|
|
414
|
+
this.registry.log = this.log;
|
|
415
|
+
this.errorPolicy = options.onError;
|
|
416
|
+
if (options.checks !== void 0) this.checks = checksOf(options.checks);
|
|
417
|
+
this.events.watch((type) => {
|
|
418
|
+
if (typeof type === "string" && !this.registry.lists("event", type)) this.registry.event(type);
|
|
419
|
+
});
|
|
420
|
+
this.hooks = new Hooks(this);
|
|
421
|
+
for (const hook of options.hooks ?? coreHooks) this.hooks.add(hook);
|
|
422
|
+
if (hasGroundSpeeds(this.registry)) this.events.on(cellsChanged, ({ layer, cells }) => {
|
|
423
|
+
if (!slowsOnFoot(this.registry, layer)) return;
|
|
424
|
+
const walkability = stopsOnFoot(this.registry, layer);
|
|
425
|
+
this.nav.groundChanged?.(cells, walkability);
|
|
426
|
+
this.sidePaths?.groundChanged(cells, walkability);
|
|
427
|
+
});
|
|
428
|
+
this.tickRate = options.tickRate ?? 30;
|
|
429
|
+
this.dt = 1 / this.tickRate;
|
|
430
|
+
this.seed = options.seed ?? 1;
|
|
431
|
+
this.rng = new Rng(this.seed);
|
|
432
|
+
this.computers = new Computers(this);
|
|
433
|
+
for (const init of options.players) this.players.set(init.id, new Player(init));
|
|
434
|
+
settleRaces(this.players.values(), this.registry, (count) => this.rng.int(0, count - 1), options.randomRaces);
|
|
435
|
+
this.grid = new BuildGrid(this.terrain);
|
|
436
|
+
const teams = /* @__PURE__ */ new Set();
|
|
437
|
+
for (const player of this.players.values()) if (!player.neutral) teams.add(player.team);
|
|
438
|
+
this.fog = new FogOfWar(this.terrain.width, this.terrain.depth, [], this.terrain.levels);
|
|
439
|
+
this.fog.exploredFromStart = !!this.settings.fog?.startExplored;
|
|
440
|
+
for (const team of teams) this.fog.addTeam(team);
|
|
441
|
+
this.spatial = new SpatialIndex(this.terrain.width, this.terrain.depth);
|
|
442
|
+
this.scheduler = new Scheduler(options.systems(this));
|
|
443
|
+
this.areas = new Areas(this, options.areas ?? []);
|
|
444
|
+
this.timers = new Timers(this, [...coreTimers, ...options.timers ?? []]);
|
|
445
|
+
this.sequences = new Sequences(this, options.sequences ?? []);
|
|
446
|
+
this.objectives = new Objectives(this);
|
|
447
|
+
this.dialog = new Dialog(this);
|
|
448
|
+
this.score = new Score(this);
|
|
449
|
+
const ids = /* @__PURE__ */ new Set();
|
|
450
|
+
for (const listener of [
|
|
451
|
+
...helpListeners,
|
|
452
|
+
...options.listeners ?? [],
|
|
453
|
+
...Sequences.listenersFor(options.sequences ?? [])
|
|
454
|
+
]) {
|
|
455
|
+
if (ids.has(listener.id)) throw new Error(`Listener "${listener.id}" is there twice`);
|
|
456
|
+
ids.add(listener.id);
|
|
457
|
+
const off = `listener:${listener.id}`;
|
|
458
|
+
this.events.on(listener.event, (payload) => {
|
|
459
|
+
if (this.disabled.size && this.disabled.has(off)) return;
|
|
460
|
+
this.trace?.listener(listener.id);
|
|
461
|
+
try {
|
|
462
|
+
listener.run(this, payload);
|
|
463
|
+
} catch (error) {
|
|
464
|
+
this.caught(error, {
|
|
465
|
+
kind: "listener",
|
|
466
|
+
id: listener.id
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* The systems, in the order they run
|
|
474
|
+
*
|
|
475
|
+
* @beta
|
|
476
|
+
*/
|
|
477
|
+
get systems() {
|
|
478
|
+
return this.scheduler.systems;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Adds a system to the running world, like a computer player. It takes its place by its phase, `before` and `after`
|
|
482
|
+
*
|
|
483
|
+
* @beta
|
|
484
|
+
*/
|
|
485
|
+
addSystem(system) {
|
|
486
|
+
this.scheduler.add(system);
|
|
487
|
+
const saved = this.savedSystems.get(system.name);
|
|
488
|
+
if (saved !== void 0 && system.restore) {
|
|
489
|
+
this.savedSystems.delete(system.name);
|
|
490
|
+
system.restore(this, saved);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/** What systems kept in themselves when the game was saved, for those not added yet */
|
|
494
|
+
savedSystems = /* @__PURE__ */ new Map();
|
|
495
|
+
/**
|
|
496
|
+
* Gives the systems what they kept in a save (see `System.save`): those there now, and those added later
|
|
497
|
+
*
|
|
498
|
+
* @beta
|
|
499
|
+
*/
|
|
500
|
+
restoreSystems(saved) {
|
|
501
|
+
this.savedSystems.clear();
|
|
502
|
+
for (const [name, data] of Object.entries(saved)) {
|
|
503
|
+
const system = this.systems.find((each) => each.name === name);
|
|
504
|
+
if (system?.restore) system.restore(this, data);
|
|
505
|
+
else this.savedSystems.set(name, data);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Takes a system out by name. False when there is none of that name
|
|
510
|
+
*
|
|
511
|
+
* @beta
|
|
512
|
+
*/
|
|
513
|
+
removeSystem(name) {
|
|
514
|
+
return this.scheduler.remove(name);
|
|
515
|
+
}
|
|
516
|
+
/** Seconds of game time that have passed: `tick` times `dt` */
|
|
517
|
+
get time() {
|
|
518
|
+
return this.tick * this.dt;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* A number of the rules as it is tuned now (`TunableDef`): what it was set to while playing, or its default
|
|
522
|
+
*
|
|
523
|
+
* @beta
|
|
524
|
+
*/
|
|
525
|
+
tunable(id) {
|
|
526
|
+
const def = this.registry.tunable(id);
|
|
527
|
+
if (!def) throw new Error(`The game has no tunable "${id}"`);
|
|
528
|
+
return this.state(tunings)[id] ?? def.default;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Tunes a number of the rules, within its bounds, and says so (`tunableChanged`)
|
|
532
|
+
*
|
|
533
|
+
* @beta
|
|
534
|
+
*/
|
|
535
|
+
setTunable(id, value) {
|
|
536
|
+
const def = this.registry.tunable(id);
|
|
537
|
+
if (!def || !Number.isFinite(value)) return;
|
|
538
|
+
const set = Math.min(Math.max(value, def.min), def.max);
|
|
539
|
+
this.setState(tunings, {
|
|
540
|
+
...this.state(tunings),
|
|
541
|
+
[id]: set
|
|
542
|
+
});
|
|
543
|
+
this.events.emit(tunableChanged, {
|
|
544
|
+
id,
|
|
545
|
+
value: set
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Changes a definition while the game runs (S61): a unit type's health, an ability's cooldown, as the editor's Data
|
|
550
|
+
* panel tries them. What is made of it from then on is made of the new one; a unit type's units already in the world
|
|
551
|
+
* take it at once, with as much of their health lost as before. Kept with the world and in its save, and said
|
|
552
|
+
* (`definitionChanged`). False for a definition the game does not have. Not held to what the game lets be changed
|
|
553
|
+
* (`Rules.editable`), as `layData` and a map's definitions are: any field is taken. The check is the command's that
|
|
554
|
+
* the Data panel sends (`redefineCommand`); code that calls this says what it allows itself
|
|
555
|
+
*
|
|
556
|
+
* @beta
|
|
557
|
+
*/
|
|
558
|
+
redefine(kind, id, values) {
|
|
559
|
+
if (!redefineIn(this.registry, kind, id, values)) return false;
|
|
560
|
+
const kept = this.state(redefinitions);
|
|
561
|
+
const before = kept[kind] ?? {};
|
|
562
|
+
this.setState(redefinitions, {
|
|
563
|
+
...kept,
|
|
564
|
+
[kind]: {
|
|
565
|
+
...before,
|
|
566
|
+
[id]: mergeValues(before[id] ?? {}, values)
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
if (kind === "units") this.retype(/* @__PURE__ */ new Set([id]));
|
|
570
|
+
this.events.emit(definitionChanged, {
|
|
571
|
+
kind,
|
|
572
|
+
id,
|
|
573
|
+
values
|
|
574
|
+
});
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* The units of these types take their type as the registry has it now, with as much of their health lost as
|
|
579
|
+
* before: after it was changed (`redefine`, `reloadGame`). Every type when none are said
|
|
580
|
+
*
|
|
581
|
+
* @internal
|
|
582
|
+
*/
|
|
583
|
+
retype(types) {
|
|
584
|
+
for (const entity of this.entities.values()) {
|
|
585
|
+
if (types && !types.has(entity.def.id)) continue;
|
|
586
|
+
const def = definitionIn(this.registry, "units", entity.def.id);
|
|
587
|
+
if (!def || def === entity.def) continue;
|
|
588
|
+
this.index.remove(entity);
|
|
589
|
+
entity.retype(def);
|
|
590
|
+
this.index.add(entity);
|
|
591
|
+
const hurt = entity.maxHealth - entity.health;
|
|
592
|
+
entity.maxHealth = statsOf(this, entity).health;
|
|
593
|
+
if (entity.alive) entity.health = Math.max(entity.maxHealth - hurt, 1);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/** State of a game module or a mod for the whole game: made from the component's default when first asked for */
|
|
597
|
+
state(key) {
|
|
598
|
+
if (!this.registry.lists("component", key.id)) this.registry.used(key.id);
|
|
599
|
+
return this.states.get(key);
|
|
600
|
+
}
|
|
601
|
+
/** Sets the whole game's state for a component, replacing what `state` gives for it */
|
|
602
|
+
setState(key, value) {
|
|
603
|
+
this.states.set(key, value);
|
|
604
|
+
}
|
|
605
|
+
/** The game's numbers that are not about any one unit, like the supply cap (`Rules.settings`) */
|
|
606
|
+
get settings() {
|
|
607
|
+
return this.registry.settings;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Hour of the day, 0..24. Noon in a game without days (`clock.hour`)
|
|
611
|
+
*
|
|
612
|
+
* @beta
|
|
613
|
+
*/
|
|
614
|
+
get hour() {
|
|
615
|
+
return this.clock.hour;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Whether the sun is down (`clock.night`): asked for every unit's sight and stats, many times a tick
|
|
619
|
+
*
|
|
620
|
+
* @beta
|
|
621
|
+
*/
|
|
622
|
+
get night() {
|
|
623
|
+
return this.clock.night;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Unique id for orders, order groups and projectiles
|
|
627
|
+
*
|
|
628
|
+
* @beta
|
|
629
|
+
*/
|
|
630
|
+
newId() {
|
|
631
|
+
return this.nextId++;
|
|
632
|
+
}
|
|
633
|
+
/** The player of this id; throws when there is none */
|
|
634
|
+
player(id) {
|
|
635
|
+
const player = this.players.get(id);
|
|
636
|
+
if (!player) throw new Error(`Unknown player ${id}`);
|
|
637
|
+
return player;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Whether an entity of this id was ever made here: one that died was, one of a number not yet given out never was
|
|
641
|
+
*
|
|
642
|
+
* @beta
|
|
643
|
+
*/
|
|
644
|
+
made(id) {
|
|
645
|
+
return Number.isInteger(id) && id >= 1 && id < this.nextEntityId;
|
|
646
|
+
}
|
|
647
|
+
/** Living entity with this id */
|
|
648
|
+
get(id) {
|
|
649
|
+
if (!id) return void 0;
|
|
650
|
+
const entity = this.entities.get(id);
|
|
651
|
+
return entity?.alive ? entity : void 0;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* The entity of this name, while it lives: one named on the map in the editor, or in code. Nothing once it is
|
|
655
|
+
* dead, or when there never was one. A game can say which names there are: `world.named<RoadNames>('gate')`
|
|
656
|
+
*/
|
|
657
|
+
named(name) {
|
|
658
|
+
return this.get(this.state(names)[name]);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* The name an entity was given, if any
|
|
662
|
+
*
|
|
663
|
+
* @beta
|
|
664
|
+
*/
|
|
665
|
+
nameOf(entity) {
|
|
666
|
+
const all = this.state(names);
|
|
667
|
+
for (const name in all) if (all[name] === entity.id) return name;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Names an entity, for the rules to find it by (`named`), or takes its name away with none. It has one name, and a
|
|
671
|
+
* name is one entity's: taking that of another that still lives throws. The name of the dead is free
|
|
672
|
+
*
|
|
673
|
+
* @beta
|
|
674
|
+
*/
|
|
675
|
+
setName(entity, name) {
|
|
676
|
+
const all = this.state(names);
|
|
677
|
+
const before = this.nameOf(entity);
|
|
678
|
+
if (before === name) return;
|
|
679
|
+
if (name !== void 0) {
|
|
680
|
+
const holder = this.named(name);
|
|
681
|
+
if (holder) throw new Error(`"${name}" is the name of ${holder.def.id}#${holder.id} already: ${entity.def.id}#${entity.id} cannot have it too`);
|
|
682
|
+
all[name] = entity.id;
|
|
683
|
+
}
|
|
684
|
+
if (before !== void 0) delete all[before];
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* What the map this world was made from says that is not an entity: its name, and what the game kept with it
|
|
688
|
+
* (`GameMap.data`). Kept in the world, so a save has it. Empty for a world made without a map
|
|
689
|
+
*/
|
|
690
|
+
get map() {
|
|
691
|
+
return new WorldMap(this.state(mapInfo));
|
|
692
|
+
}
|
|
693
|
+
/** Whether two players fight each other (`sides.enemies`): asked of every target, every tick */
|
|
694
|
+
areEnemies(a, b) {
|
|
695
|
+
return this.sides.enemies(a, b);
|
|
696
|
+
}
|
|
697
|
+
/** Whether two players are on one side (`sides.allies`) */
|
|
698
|
+
areAllies(a, b) {
|
|
699
|
+
return this.sides.allies(a, b);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Whether a player may command an entity (`sides.mayCommand`): what every command is checked against
|
|
703
|
+
*
|
|
704
|
+
* @beta
|
|
705
|
+
*/
|
|
706
|
+
mayCommand(player, entity) {
|
|
707
|
+
return this.sides.mayCommand(player, entity);
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Whether a team currently sees the entity (`sight.sees`): asked of every entity, team and snapshot
|
|
711
|
+
*
|
|
712
|
+
* @beta
|
|
713
|
+
*/
|
|
714
|
+
isVisibleTo(entity, team) {
|
|
715
|
+
return this.sight.sees(entity, team);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Creates an entity. Structures are centered on the grid cells closest to `position`;
|
|
719
|
+
* the caller is responsible for checking `grid.canPlace` when that matters.
|
|
720
|
+
*/
|
|
721
|
+
/**
|
|
722
|
+
* A prefab put down as one: its objects spawned for the owner given, its camps and areas with them, turned and sized
|
|
723
|
+
* around its middle (`spawnPrefab`)
|
|
724
|
+
*
|
|
725
|
+
* @beta
|
|
726
|
+
*/
|
|
727
|
+
spawnPrefab(prefab, options) {
|
|
728
|
+
return spawnPrefab(this, prefab, options);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* The neutral player, who owns what belongs to nobody (a soul, a mine, a tree): the first of them, the game's
|
|
732
|
+
* `MAP_NEUTRAL`. Throws for a game that has none
|
|
733
|
+
*
|
|
734
|
+
* @beta
|
|
735
|
+
*/
|
|
736
|
+
get neutral() {
|
|
737
|
+
for (const player of this.players.values()) if (player.neutral && !player.creeps) return player.id;
|
|
738
|
+
throw new Error("The world has no neutral player");
|
|
739
|
+
}
|
|
740
|
+
spawn(typeId, owner, position, options = {}) {
|
|
741
|
+
if (typeof owner === "object") {
|
|
742
|
+
const { at, owner: player, ...rest } = owner;
|
|
743
|
+
return this.spawning.spawn(typeId, player, at, rest);
|
|
744
|
+
}
|
|
745
|
+
return this.spawning.spawn(typeId, owner, position, options);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* What its parts call off as an entity leaves its owner, dying or given away (`Component.onLeave`)
|
|
749
|
+
*
|
|
750
|
+
* @internal
|
|
751
|
+
*/
|
|
752
|
+
leave(entity) {
|
|
753
|
+
this.spawning.leave(entity);
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Turns scenery into an actor, for good: something gave it a reason to be looked at every tick, like a buff
|
|
757
|
+
* that has to run out. Whatever does that to an entity calls this; the debug checks catch what forgets to.
|
|
758
|
+
*
|
|
759
|
+
* @beta
|
|
760
|
+
*/
|
|
761
|
+
wake(entity) {
|
|
762
|
+
this.spawning.wake(entity);
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Sets cells of one of the game's layers (`Terrain.cells`, `CellLayerDef`) to a value: by their indices, or those in
|
|
766
|
+
* a shape. A bush burnt, grass grown. The players who see a cell are told at once (a `cells` event), the others as it
|
|
767
|
+
* comes into their sight (`TeamMemory.cells`), and saves keep it. Returns the cells that changed
|
|
768
|
+
*/
|
|
769
|
+
/**
|
|
770
|
+
* Changes what the map looks like beyond its ground, as the game goes: a storm rolling in (`weather`), night mist
|
|
771
|
+
* (`fog`), the sky going red. Over what it was, field by field; a field given as undefined goes back to none. Every
|
|
772
|
+
* player sees it (an `environment` event), a save keeps it, and a player who joins later is told it as it is.
|
|
773
|
+
*
|
|
774
|
+
* `over` (seconds) has the screens ease into it, from what they show: the rain comes on, the wind gets up, the mist
|
|
775
|
+
* thickens. The world has the new look at once: a save or a player who joins sees it as it ends
|
|
776
|
+
*/
|
|
777
|
+
setEnvironment(change, options = {}) {
|
|
778
|
+
const info = this.state(mapInfo);
|
|
779
|
+
const environment = { ...info.environment };
|
|
780
|
+
for (const [key, value] of Object.entries(change)) if (value === void 0) delete environment[key];
|
|
781
|
+
else Object.assign(environment, { [key]: structuredClone(value) });
|
|
782
|
+
this.setState(mapInfo, {
|
|
783
|
+
...info,
|
|
784
|
+
environment
|
|
785
|
+
});
|
|
786
|
+
const over = options.over && options.over > 0 ? options.over : void 0;
|
|
787
|
+
this.events.emit(environmentChanged, {
|
|
788
|
+
environment: structuredClone(environment),
|
|
789
|
+
...over && { over }
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Plays one of the view's fx (`GameView.fx.defs`) on the screens of the players who see where it is, or those it is
|
|
794
|
+
* for (`to`): at a place (`at`), or on an entity (`on`, at a `point` of its model), with knobs (`params`). Its random
|
|
795
|
+
* parts go by a seed, the same on every screen. Nothing it does decides anything: it is not in the world's state, a
|
|
796
|
+
* save, or what a player who joins later is told. What it gives back stops it (`stopFx`)
|
|
797
|
+
*
|
|
798
|
+
* @beta
|
|
799
|
+
*/
|
|
800
|
+
fx(fx, options = {}) {
|
|
801
|
+
return playFx(this, fx, options);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Stops an fx the rules played (`fx`) on every screen, as its own `stop` says, over `fade` seconds
|
|
805
|
+
*
|
|
806
|
+
* @beta
|
|
807
|
+
*/
|
|
808
|
+
stopFx(id, options = {}) {
|
|
809
|
+
stopFx(this, id, options);
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Sets the cells of a cell layer, given as indices or an area, to a value 0..255, and returns the cells that changed.
|
|
813
|
+
* `over`: the seconds the screens that see them ease into the value over (grass growing back), told with the cells;
|
|
814
|
+
* a screen told of them later, as they come into its sight, eases in as it can
|
|
815
|
+
*
|
|
816
|
+
* @beta
|
|
817
|
+
*/
|
|
818
|
+
setCells(layer, cells, value, options = {}) {
|
|
819
|
+
const { terrain } = this;
|
|
820
|
+
if (!Number.isInteger(value) || value < 0 || value > 255) throw new Error(`setCells: ${value} is not a value a cell holds, 0 to 255`);
|
|
821
|
+
const values = terrain.cellLayer(layer);
|
|
822
|
+
const changed = [];
|
|
823
|
+
const was = [];
|
|
824
|
+
for (const c of Array.isArray(cells) ? cells : cellsIn(terrain, cells)) {
|
|
825
|
+
if (c < 0 || c >= values.length || values[c] === value) continue;
|
|
826
|
+
was.push(values[c]);
|
|
827
|
+
values[c] = value;
|
|
828
|
+
changed.push(c);
|
|
829
|
+
}
|
|
830
|
+
if (!changed.length) return changed;
|
|
831
|
+
rememberUnseenCells(this, layer, changed, was, value);
|
|
832
|
+
const { over } = options;
|
|
833
|
+
this.events.emit(cellsChanged, {
|
|
834
|
+
layer,
|
|
835
|
+
cells: changed,
|
|
836
|
+
value,
|
|
837
|
+
...over !== void 0 && over > 0 && { over }
|
|
838
|
+
});
|
|
839
|
+
return changed;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Reshapes a part of the ground as the game goes (`TerrainPatch`): its heights, cliffs, water, paint, what is kept
|
|
843
|
+
* off it and the game's layers of cells, all at once, as the editor's Play here pushes the map's ground into the game
|
|
844
|
+
* played (`debug.ground`, EQ10). What the rules go by follows: who sees whom from the levels, where can be built, and
|
|
845
|
+
* the ways, cut again of the ground as it is now (`Navigation.reshape`: on this thread, every machine the same; only
|
|
846
|
+
* the tiles of the ways the patch reaches, a few milliseconds for a field, where the ground is still cut on the same
|
|
847
|
+
* grid, else all of them, which is not for nothing on a big map). What stands on it stays where it is. Every player
|
|
848
|
+
* is told (a `ground` event), and saves keep it. Throws where the patch does not fit the ground (`terrainPatchProblem`)
|
|
849
|
+
*
|
|
850
|
+
* @beta
|
|
851
|
+
*/
|
|
852
|
+
reshapeGround(patch) {
|
|
853
|
+
applyTerrainPatch(this.terrain, patch);
|
|
854
|
+
this.fog.levelsChanged();
|
|
855
|
+
this.grid.groundChanged(patch);
|
|
856
|
+
const area = {
|
|
857
|
+
x: patch.x,
|
|
858
|
+
z: patch.z,
|
|
859
|
+
width: patch.width,
|
|
860
|
+
depth: patch.depth
|
|
861
|
+
};
|
|
862
|
+
this.nav.reshape?.(area);
|
|
863
|
+
this.sidePaths?.reshape(area);
|
|
864
|
+
this.events.emit(groundReshaped, { patch });
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Lets a team see a spot for a while, with nothing standing there
|
|
868
|
+
*
|
|
869
|
+
* @beta
|
|
870
|
+
*/
|
|
871
|
+
reveal(team, point, radius, seconds, options = {}) {
|
|
872
|
+
const reveal = {
|
|
873
|
+
id: this.nextId++,
|
|
874
|
+
team,
|
|
875
|
+
x: point.x,
|
|
876
|
+
z: point.z,
|
|
877
|
+
radius,
|
|
878
|
+
left: seconds,
|
|
879
|
+
...options.quiet && { quiet: true }
|
|
880
|
+
};
|
|
881
|
+
this.reveals.push(reveal);
|
|
882
|
+
return reveal;
|
|
883
|
+
}
|
|
884
|
+
/** Puts a unit somewhere else, where it stands: the way through is not its concern. Structures stay where they were built */
|
|
885
|
+
place(entity, point) {
|
|
886
|
+
this.spawning.place(entity, point);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Gives an entity to another player, from now on in everything: whose it is, whom it fights, what it counts for.
|
|
890
|
+
* What it was doing is called off, and what it was making is given back to the one it belonged to
|
|
891
|
+
*/
|
|
892
|
+
setOwner(entity, owner) {
|
|
893
|
+
this.spawning.setOwner(entity, owner);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Takes a unit out of the world for a while, or puts it back: a worker inside a gold mine, a unit carried in
|
|
897
|
+
* something. While hidden it is not found, not seen and in nobody's way, and its orders wait. It comes back at
|
|
898
|
+
* `at`, or where it went in, on the nearest ground it can stand on. Structures cannot hide
|
|
899
|
+
*
|
|
900
|
+
* @beta
|
|
901
|
+
*/
|
|
902
|
+
setHidden(entity, hidden, at) {
|
|
903
|
+
this.spawning.setHidden(entity, hidden, at);
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Gives an entity a time after which it is gone by itself, like a ward, or takes it away with `null`
|
|
907
|
+
*
|
|
908
|
+
* @beta
|
|
909
|
+
*/
|
|
910
|
+
setLifetime(entity, seconds) {
|
|
911
|
+
this.spawning.setLifetime(entity, seconds);
|
|
912
|
+
}
|
|
913
|
+
/** Deals damage (`life.damage`): the hooks, armor and shields, health, death */
|
|
914
|
+
damage(target, amount, source, options = {}) {
|
|
915
|
+
this.life.damage(target, amount, source, options);
|
|
916
|
+
}
|
|
917
|
+
/** Heals (`life.heal`): how much it healed */
|
|
918
|
+
heal(target, amount, source) {
|
|
919
|
+
return this.life.heal(target, amount, source);
|
|
920
|
+
}
|
|
921
|
+
/** Kills (`life.kill`) */
|
|
922
|
+
kill(entity, killer, attack = false, reason = "killed") {
|
|
923
|
+
this.life.kill(entity, killer, attack, reason);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Tells a player something, like why what they asked for cannot be done. The world says which message,
|
|
927
|
+
* and the player's screen finds the words for it (see `Message`). A bare string is a key without params
|
|
928
|
+
*/
|
|
929
|
+
message(player, message, kind = "error") {
|
|
930
|
+
const said = toMessage(message);
|
|
931
|
+
const { handling } = this;
|
|
932
|
+
if (handling && handling.player === player && kind === "error") handling.refusal ??= said;
|
|
933
|
+
this.events.emit(messageSent, {
|
|
934
|
+
player,
|
|
935
|
+
message: said,
|
|
936
|
+
kind
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Gives a player a hint (campaign plan CP5): a message of the kind `hint`, shown for `seconds` (the screen's own
|
|
941
|
+
* time when left out), which a player who turned hints off in the settings does not see
|
|
942
|
+
*
|
|
943
|
+
* @beta
|
|
944
|
+
*/
|
|
945
|
+
hint(player, message, options = {}) {
|
|
946
|
+
const said = {
|
|
947
|
+
player,
|
|
948
|
+
message: toMessage(message),
|
|
949
|
+
kind: "hint"
|
|
950
|
+
};
|
|
951
|
+
if (options.seconds !== void 0) said.seconds = options.seconds;
|
|
952
|
+
this.events.emit(messageSent, said);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* The command being carried out, to find out whether it was refused: see `executeCommand`
|
|
956
|
+
*
|
|
957
|
+
* @beta
|
|
958
|
+
*/
|
|
959
|
+
handling;
|
|
960
|
+
/**
|
|
961
|
+
* What a save needs that is the world's own business: id counters, the clock and the commands waiting for
|
|
962
|
+
* the next tick. For `saveWorld` and `loadWorld` only
|
|
963
|
+
*
|
|
964
|
+
* @beta
|
|
965
|
+
*/
|
|
966
|
+
internals() {
|
|
967
|
+
return {
|
|
968
|
+
nextEntityId: this.nextEntityId,
|
|
969
|
+
nextId: this.nextId,
|
|
970
|
+
clockShift: this.clock.shift,
|
|
971
|
+
...this.clock.still !== void 0 && { stillHour: this.clock.still },
|
|
972
|
+
commands: this.commands,
|
|
973
|
+
...this.life.dead.length > 0 && { dead: this.life.dead.map((entity) => entity.id) }
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Puts back what `internals` gave, for `loadWorld` only
|
|
978
|
+
*
|
|
979
|
+
* @beta
|
|
980
|
+
*/
|
|
981
|
+
restoreInternals(internals) {
|
|
982
|
+
this.nextEntityId = internals.nextEntityId;
|
|
983
|
+
this.nextId = internals.nextId;
|
|
984
|
+
this.clock.shift = internals.clockShift;
|
|
985
|
+
this.clock.still = internals.stillHour;
|
|
986
|
+
this.commands = [...internals.commands];
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Puts back who died and waits to be taken out (`WorldInternals.dead`), once the entities are back. For `loadWorld` only
|
|
990
|
+
*
|
|
991
|
+
* @beta
|
|
992
|
+
*/
|
|
993
|
+
restoreDead(ids) {
|
|
994
|
+
for (const id of ids) {
|
|
995
|
+
const entity = this.entities.get(id);
|
|
996
|
+
if (!entity) throw new Error(`Save: the dead ${id} is not in it`);
|
|
997
|
+
this.life.dead.push(entity);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Queues a player command. It is applied at the start of the next tick; talk (a command whose def says
|
|
1002
|
+
* `outsideTick`: chat, a ping) given between ticks is carried out at once, a paused game's too (RV14)
|
|
1003
|
+
*/
|
|
1004
|
+
issue(command) {
|
|
1005
|
+
if (!this.stepping && typeof command?.type === "string" && this.registry.command(command.type)?.outsideTick) {
|
|
1006
|
+
for (const watcher of this.watchers) watcher.command?.(command);
|
|
1007
|
+
executeCommand(this, command);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (!this.stepping && typeof command?.player === "number") {
|
|
1011
|
+
const given = (this.given.get(command.player) ?? 0) + 1;
|
|
1012
|
+
this.given.set(command.player, given);
|
|
1013
|
+
if (given > this.commandLimit) {
|
|
1014
|
+
this.overLimit.set(command.player, (this.overLimit.get(command.player) ?? 0) + 1);
|
|
1015
|
+
if (typeof command.seq === "number") this.overLimitSeqs.push({
|
|
1016
|
+
player: command.player,
|
|
1017
|
+
seq: command.seq
|
|
1018
|
+
});
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
this.commands.push(command);
|
|
1023
|
+
if (!this.stepping) for (const watcher of this.watchers) watcher.command?.(command);
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Whether a debug command (`debug.*`) waits for a tick: a game paused by `debug.speed` runs the tick it takes, or
|
|
1027
|
+
* nothing of the debug tools would be done again, the command to go on included
|
|
1028
|
+
*
|
|
1029
|
+
* @internal
|
|
1030
|
+
*/
|
|
1031
|
+
get debugWaiting() {
|
|
1032
|
+
return this.commands.some((command) => typeof command?.type === "string" && command.type.startsWith("debug."));
|
|
1033
|
+
}
|
|
1034
|
+
/** What watches the world from outside (`watch`) */
|
|
1035
|
+
watchers = /* @__PURE__ */ new Set();
|
|
1036
|
+
/**
|
|
1037
|
+
* Watches the world from outside, for what records it (a replay of commands, `recordGame`): each command a player
|
|
1038
|
+
* gives it, each save taken of it, each tick. Changes nothing. Gives what stops watching
|
|
1039
|
+
*
|
|
1040
|
+
* @beta
|
|
1041
|
+
*/
|
|
1042
|
+
watch(watcher) {
|
|
1043
|
+
this.watchers.add(watcher);
|
|
1044
|
+
return () => void this.watchers.delete(watcher);
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* A save of the world was taken, which put its crowd back (`saveWorld`): told to what watches it. The engine's
|
|
1048
|
+
*
|
|
1049
|
+
* @beta
|
|
1050
|
+
*/
|
|
1051
|
+
saved() {
|
|
1052
|
+
for (const watcher of this.watchers) watcher.saved?.();
|
|
1053
|
+
}
|
|
1054
|
+
/** Advances the simulation by one fixed tick */
|
|
1055
|
+
/**
|
|
1056
|
+
* The entities that are all of what is asked, for scripts: whose they are, of which type, in which area. Only the
|
|
1057
|
+
* living, unless asked. A new list: for what runs every tick, go through `index` or `areas` instead; by place and condition, `query`
|
|
1058
|
+
*/
|
|
1059
|
+
find(filter = {}) {
|
|
1060
|
+
const from = filter.area !== void 0 ? this.areas.inside(filter.area) : filter.owner !== void 0 ? this.index.ownedBy(filter.owner) : this.entities.values();
|
|
1061
|
+
const found = [];
|
|
1062
|
+
for (const entity of from) {
|
|
1063
|
+
if (filter.owner !== void 0 && entity.owner !== filter.owner) continue;
|
|
1064
|
+
if (filter.type !== void 0 && entity.def.id !== filter.type) continue;
|
|
1065
|
+
if (!filter.dead && !entity.alive) continue;
|
|
1066
|
+
found.push(entity);
|
|
1067
|
+
}
|
|
1068
|
+
return found;
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* What in the world is all a query asks (`WorldQuery`): around a point or a unit (`near`, `radius`), in an area, of
|
|
1072
|
+
* whom, of which type, kind and layer, what it carries and how hurt it is (`UnitCondition`), what a player sees, or
|
|
1073
|
+
* code (`where`); in an order (`sort`: `nearest`, `lowestHealthShare`, `random`…), as many as `limit` says. A new list:
|
|
1074
|
+
* `world.query({ near: hero, radius: 8, is: 'enemy', healthBelow: 0.3, sort: 'nearest', limit: 3 })`
|
|
1075
|
+
*
|
|
1076
|
+
* @beta
|
|
1077
|
+
*/
|
|
1078
|
+
query(query = {}) {
|
|
1079
|
+
return queryWorld(this, query);
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Marks a moment to start again from, like the start of a wave, with what the player is told it is ("Wave 6").
|
|
1083
|
+
* A session keeps a save of the world as it is at the end of this tick, for "Retry from wave 6"
|
|
1084
|
+
*/
|
|
1085
|
+
checkpoint(label) {
|
|
1086
|
+
this.events.emit(checkpoint, { label: toMessage(label) });
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Steps the world one tick; does nothing once the game failed. In this order:
|
|
1090
|
+
*
|
|
1091
|
+
* 1. The commands sent since the last tick are carried out.
|
|
1092
|
+
* 2. Units are filed by where they stand (`spatial`).
|
|
1093
|
+
* 3. The systems run, phase by phase (`commands`, `decide`, `move`, `resolve`, `cleanup`).
|
|
1094
|
+
* 4. The dead are taken out of the world (`remove` hook, `entityRemoved`).
|
|
1095
|
+
* 5. `tick` goes up by one.
|
|
1096
|
+
* 6. The tick's events go out to listeners (`world.events.on`), held until now.
|
|
1097
|
+
*
|
|
1098
|
+
* So a listener runs after the tick is over: `world.tick` is already the next one, and an entity that died this
|
|
1099
|
+
* tick is no longer in `world.entities` (the event still carries it; a fallen hero waiting to be brought back
|
|
1100
|
+
* stays). Hooks run at once, inside the tick, where
|
|
1101
|
+
* what they are asked about happens
|
|
1102
|
+
*/
|
|
1103
|
+
step() {
|
|
1104
|
+
if (this.failure) return;
|
|
1105
|
+
this.events.hold();
|
|
1106
|
+
this.stepping = true;
|
|
1107
|
+
try {
|
|
1108
|
+
this.advance();
|
|
1109
|
+
} catch (error) {
|
|
1110
|
+
if (!(error instanceof GameEnded)) throw error;
|
|
1111
|
+
} finally {
|
|
1112
|
+
try {
|
|
1113
|
+
this.events.release();
|
|
1114
|
+
} catch (error) {
|
|
1115
|
+
if (!(error instanceof GameEnded)) throw error;
|
|
1116
|
+
} finally {
|
|
1117
|
+
this.stepping = false;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
this.nav.settleGround?.();
|
|
1121
|
+
this.sidePaths?.settleGround();
|
|
1122
|
+
if (this.failure && !this.toldFailure) {
|
|
1123
|
+
this.toldFailure = true;
|
|
1124
|
+
this.events.emit(worldFailed, this.failure);
|
|
1125
|
+
}
|
|
1126
|
+
for (const watcher of this.watchers) watcher.stepped?.();
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* What a part of the game that threw comes to, by what the world says of errors (`errorPolicy`). It returns when
|
|
1130
|
+
* the part is to be switched off or let go (`disable`): the caller does that, and goes on. It throws otherwise: the
|
|
1131
|
+
* error itself (`throw`), or what leaves the tick of a game that ends there (`end`)
|
|
1132
|
+
*
|
|
1133
|
+
* @beta
|
|
1134
|
+
*/
|
|
1135
|
+
caught(error, where) {
|
|
1136
|
+
if (error instanceof GameEnded) throw error;
|
|
1137
|
+
const judged = typeof error === "object" && error !== null;
|
|
1138
|
+
if (judged && this.thrown.has(error)) throw error;
|
|
1139
|
+
const policy = this.errorPolicy ?? "throw";
|
|
1140
|
+
const mod = modOfPart(this.registry.module, where);
|
|
1141
|
+
if (mod) where = {
|
|
1142
|
+
...where,
|
|
1143
|
+
mod
|
|
1144
|
+
};
|
|
1145
|
+
let answer = typeof policy === "function" ? policy(error, where, this) : policy;
|
|
1146
|
+
if (answer === "end" && !this.stepping) answer = "throw";
|
|
1147
|
+
if (answer === "throw") {
|
|
1148
|
+
if (judged) this.thrown.add(error);
|
|
1149
|
+
throw error;
|
|
1150
|
+
}
|
|
1151
|
+
const fields = {
|
|
1152
|
+
...where,
|
|
1153
|
+
error: errorFields(error)
|
|
1154
|
+
};
|
|
1155
|
+
if (answer === "disable") {
|
|
1156
|
+
const kept = where.kind === "order" ? "the order is taken off the unit" : where.kind === "command" ? "the command is refused" : "it is switched off";
|
|
1157
|
+
this.log.error("game", `${siteWords(where)} threw: ${kept}, and the game goes on`, fields);
|
|
1158
|
+
if (where.kind !== "order" && where.kind !== "command") this.disabled.set(siteKey(where), siteOf(where));
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
this.failure = {
|
|
1162
|
+
message: `The game stopped: ${siteWords(where)} failed`,
|
|
1163
|
+
where,
|
|
1164
|
+
error: errorFields(error),
|
|
1165
|
+
tick: this.tick
|
|
1166
|
+
};
|
|
1167
|
+
this.log.error("game", `${siteWords(where)} threw: the game ends`, fields);
|
|
1168
|
+
throw new GameEnded(this.failure);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Switches off the parts a save says were (`world.disabled`): the same game goes on as the one that was saved
|
|
1172
|
+
*
|
|
1173
|
+
* @beta
|
|
1174
|
+
*/
|
|
1175
|
+
disable(sites) {
|
|
1176
|
+
for (const site of sites) {
|
|
1177
|
+
this.disabled.set(siteKey(site), siteOf(site));
|
|
1178
|
+
if (site.kind === "system") this.scheduler.disable(site.id);
|
|
1179
|
+
else if (site.kind === "hook") this.hooks.remove(site.hook, site.id);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
advance() {
|
|
1183
|
+
if (this.checks.scenery) this.checkScenery();
|
|
1184
|
+
if (this.checks.index) this.index.check(this.entities.values());
|
|
1185
|
+
for (const entity of this.units.values()) {
|
|
1186
|
+
entity.prevPos.x = entity.pos.x;
|
|
1187
|
+
entity.prevPos.z = entity.pos.z;
|
|
1188
|
+
entity.prevFacing = entity.facing;
|
|
1189
|
+
}
|
|
1190
|
+
this.given.clear();
|
|
1191
|
+
if (this.overLimit.size) {
|
|
1192
|
+
for (const [player, count] of this.overLimit) this.events.emit(commandRejected, {
|
|
1193
|
+
player,
|
|
1194
|
+
kind: "tooMany",
|
|
1195
|
+
reason: `tooManyCommands: ${count} past the ${this.commandLimit} a tick takes`
|
|
1196
|
+
});
|
|
1197
|
+
this.overLimit.clear();
|
|
1198
|
+
}
|
|
1199
|
+
if (this.commands.length) {
|
|
1200
|
+
const commands = this.commands;
|
|
1201
|
+
this.commands = [];
|
|
1202
|
+
for (const command of commands) executeCommand(this, command);
|
|
1203
|
+
}
|
|
1204
|
+
if (this.overLimitSeqs.length) {
|
|
1205
|
+
for (const { player, seq } of this.overLimitSeqs) this.events.emit(commandHandled, {
|
|
1206
|
+
player,
|
|
1207
|
+
seq,
|
|
1208
|
+
refusal: { key: "tooManyCommands" }
|
|
1209
|
+
});
|
|
1210
|
+
this.overLimitSeqs.length = 0;
|
|
1211
|
+
}
|
|
1212
|
+
this.spatial.rebuild(this.units.values());
|
|
1213
|
+
this.scheduler.run(this);
|
|
1214
|
+
if (this.life.dead.length) {
|
|
1215
|
+
for (const entity of this.life.dead) {
|
|
1216
|
+
this.entities.delete(entity.id);
|
|
1217
|
+
this.units.delete(entity.id);
|
|
1218
|
+
this.index.remove(entity);
|
|
1219
|
+
this.hooks.run("remove", entity);
|
|
1220
|
+
this.events.emit(entityRemoved, entity);
|
|
1221
|
+
}
|
|
1222
|
+
this.life.dead.length = 0;
|
|
1223
|
+
}
|
|
1224
|
+
this.tick++;
|
|
1225
|
+
}
|
|
1226
|
+
/** Throws when scenery has something that only units get looked after for. See `debugChecks` */
|
|
1227
|
+
checkScenery() {
|
|
1228
|
+
for (const entity of this.entities.values()) {
|
|
1229
|
+
if (!entity.scenery || !entity.alive) continue;
|
|
1230
|
+
const problem = !isScenery(entity.def) && "a type that is not scenery" || !this.player(entity.owner).neutral && "an owner" || entity.buffs.length > 0 && "buffs" || entity.orders.length > 0 && "orders" || entity.hidden && "been hidden" || entity.get(dashing) && "a dash" || entity.has(constructionSite) && "a construction site" || entity.expires !== null && "a lifetime" || (entity.has(exposure) || entity.has(detection)) && "been exposed or detected";
|
|
1231
|
+
if (problem) throw new Error(`Scenery ${entity.def.id}#${entity.id} has ${problem}, but nothing woke it up (World.wake)`);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Whether it was disposed: its navigation is freed, and it is not to be stepped again
|
|
1236
|
+
*
|
|
1237
|
+
* @beta
|
|
1238
|
+
*/
|
|
1239
|
+
get disposed() {
|
|
1240
|
+
return this.wasDisposed;
|
|
1241
|
+
}
|
|
1242
|
+
wasDisposed = false;
|
|
1243
|
+
/**
|
|
1244
|
+
* Frees what the world holds outside of JavaScript's memory: its navigation (a navmesh, its tiles and its crowd, in
|
|
1245
|
+
* WebAssembly, which is never collected by itself). Whoever made the world disposes it once done with it: the
|
|
1246
|
+
* session that owns it (`LocalSession`'s `ownsWorld`), the host (`SessionHost`'s), a test. Once is enough: again does
|
|
1247
|
+
* nothing
|
|
1248
|
+
*/
|
|
1249
|
+
dispose() {
|
|
1250
|
+
if (this.wasDisposed) return;
|
|
1251
|
+
this.wasDisposed = true;
|
|
1252
|
+
this.events.clear();
|
|
1253
|
+
this.nav.dispose();
|
|
1254
|
+
this.sidePaths?.dispose();
|
|
1255
|
+
this.entities.clear();
|
|
1256
|
+
this.units.clear();
|
|
1257
|
+
this.index.clear();
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
//#endregion
|
|
1261
|
+
export { World };
|
|
1262
|
+
|
|
1263
|
+
//# sourceMappingURL=world.js.map
|