@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/entity.js
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { defineComponent } from "./components.js";
|
|
2
|
+
import { constructionSite } from "./systems/construction.js";
|
|
3
|
+
//#region src/entity.ts
|
|
4
|
+
/**
|
|
5
|
+
* What moves of an entity: where it goes, how fast, how it is doing (`MovementState`). Units that walk, swim or fly
|
|
6
|
+
* have it from their type's speed; a building, a tree, or a unit an upgrade stopped has none. Filed (`index`), for the
|
|
7
|
+
* movement system to go through
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
var moving = defineComponent({
|
|
12
|
+
id: "core.moving",
|
|
13
|
+
index: true
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* How an entity fights (`CombatState`): its cooldown, its swing, what it is engaged with. What attacks has it from its
|
|
17
|
+
* type's attack; an upgrade that takes the attack away takes it. Filed (`index`), for the combat system to go through
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
var fighting = defineComponent({
|
|
22
|
+
id: "core.fighting",
|
|
23
|
+
index: true
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* What is left of what can be gathered from an entity, and who is at it (`ResourceState`): a mine's gold, a tree's
|
|
27
|
+
* lumber. What its type gives (`UnitTypeDef.resource`) as it is made. Filed (`index`), for what looks for the nearest
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
var deposit = defineComponent({
|
|
32
|
+
id: "core.deposit",
|
|
33
|
+
index: true
|
|
34
|
+
});
|
|
35
|
+
/** Seconds by team, kept in a save as its entries: what `exposure` and `detection` are */
|
|
36
|
+
var byTeam = {
|
|
37
|
+
save: (value) => [...value],
|
|
38
|
+
load: (saved) => new Map(saved)
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Seconds an entity stays in sight of other teams, by team, for having attacked them: seen where it stands, in the fog
|
|
42
|
+
* and in a bush. Filed (`index`), for the fog to light those that have it
|
|
43
|
+
*
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
var exposure = defineComponent({
|
|
47
|
+
id: "core.exposure",
|
|
48
|
+
index: true,
|
|
49
|
+
...byTeam
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Seconds the teams that found an invisible entity with something that reveals it can go on seeing it, by team. Filed
|
|
53
|
+
* (`index`), for the fog to light those that have it
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
var detection = defineComponent({
|
|
58
|
+
id: "core.detection",
|
|
59
|
+
index: true,
|
|
60
|
+
...byTeam
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* A point, told from an order's fields: what has a number `x` and `z` (a map's point, an entity's `pos`), which no field
|
|
64
|
+
* of an order is named
|
|
65
|
+
*/
|
|
66
|
+
var isPoint = (aim) => typeof aim.x === "number" && typeof aim.z === "number";
|
|
67
|
+
/**
|
|
68
|
+
* Anything in the world: a unit, a building, a tree.
|
|
69
|
+
*
|
|
70
|
+
* Fields marked `readonly` are kept in step with things elsewhere (the navigation, the spatial index, the lookups
|
|
71
|
+
* of the world), so they are changed through the world's functions only: `World.setOwner`, `World.setHidden`,
|
|
72
|
+
* `World.setLifetime`, `World.place`, `startDash`, `morph` (each through the entity's own internal writes: `moveTo`,
|
|
73
|
+
* `retype`, `changeOwner`…). The rest, like health, mana or cooldowns, a game
|
|
74
|
+
* module may change as it likes: nothing is worked out from them that would not notice.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
var Entity = class Entity {
|
|
79
|
+
id;
|
|
80
|
+
def;
|
|
81
|
+
owner;
|
|
82
|
+
/** Whether the entity is in the world; false once it died */
|
|
83
|
+
alive = true;
|
|
84
|
+
/** Hidden entities are inside something (a gold mine) and do not take part in the world */
|
|
85
|
+
hidden = false;
|
|
86
|
+
/**
|
|
87
|
+
* Only stands there, like a tree: left out of the systems that run every tick, see `isScenery`.
|
|
88
|
+
* Becomes false for good once something gives it anything to do (`World.wake`)
|
|
89
|
+
*/
|
|
90
|
+
scenery = false;
|
|
91
|
+
/** Where it stands in cells (`x`, `z`), changed through the world's functions only */
|
|
92
|
+
pos;
|
|
93
|
+
/** Where it stood at the last tick, for the screen to draw between */
|
|
94
|
+
prevPos;
|
|
95
|
+
/** The way it faces in radians */
|
|
96
|
+
facing = 0;
|
|
97
|
+
/** The way it faced at the last tick, in radians, for the screen to draw between */
|
|
98
|
+
prevFacing = 0;
|
|
99
|
+
/** How big it is drawn, for the look of a map. Nothing in the rules goes by it */
|
|
100
|
+
scale = 1;
|
|
101
|
+
/** Which of the models of its type it is drawn with, for the look of a map. Nothing in the rules goes by it either */
|
|
102
|
+
look;
|
|
103
|
+
/**
|
|
104
|
+
* Drawn as another's type and owner: a soul in the fallen's shape (`SpawnOptions.looksLike`). Its own type and owner
|
|
105
|
+
* decide everything but the picture
|
|
106
|
+
*/
|
|
107
|
+
likeness;
|
|
108
|
+
/** Velocity of the last tick */
|
|
109
|
+
velocity = {
|
|
110
|
+
x: 0,
|
|
111
|
+
z: 0
|
|
112
|
+
};
|
|
113
|
+
/** Hit points it has now; it dies at 0 */
|
|
114
|
+
health;
|
|
115
|
+
/** Teams that have seen this entity at least once, one bit per team as `FogOfWar.teamBit` hands them out. Ask `World.hasSeen` */
|
|
116
|
+
seenBy = 0;
|
|
117
|
+
/** When it was last hurt, in seconds of the game. Long ago for what never was */
|
|
118
|
+
hurtAt = -Infinity;
|
|
119
|
+
/** Seconds until it is gone by itself, for what does not last */
|
|
120
|
+
expires = null;
|
|
121
|
+
/** Seconds it was given to last, for what does not */
|
|
122
|
+
lifetime = 0;
|
|
123
|
+
/** Seconds until enemies cannot see it any more, for what is invisible. 0 once they cannot */
|
|
124
|
+
unseenIn = null;
|
|
125
|
+
/**
|
|
126
|
+
* What it was told to do, the first what it does now and the rest in turn: read here, given and ended through the
|
|
127
|
+
* orders' functions (`giveOrder`, `clearOrders`, `completeOrder`), which write it with the entity's own `addOrder`,
|
|
128
|
+
* `keepOrders` and `removeOrder`
|
|
129
|
+
*/
|
|
130
|
+
orders = [];
|
|
131
|
+
/** Invisible to enemies right now, unless they have found it */
|
|
132
|
+
get unseen() {
|
|
133
|
+
return this.unseenIn === 0;
|
|
134
|
+
}
|
|
135
|
+
/** The most hit points it can have */
|
|
136
|
+
maxHealth;
|
|
137
|
+
/** Mana it has now */
|
|
138
|
+
mana = 0;
|
|
139
|
+
/** The most mana it can have */
|
|
140
|
+
maxMana;
|
|
141
|
+
/** Does nothing by itself until something wakes it, and is drawn sleeping: creeps at night */
|
|
142
|
+
asleep = false;
|
|
143
|
+
/** A fallen hero that is on its way back */
|
|
144
|
+
reviving = false;
|
|
145
|
+
/**
|
|
146
|
+
* What it can cast, with their levels and cooldowns: each state is the game's to change (`cooldown`, `autocast`),
|
|
147
|
+
* the list the engine's (a type's own, what a hero learns), written with the entity's own internal methods
|
|
148
|
+
*/
|
|
149
|
+
abilities = [];
|
|
150
|
+
/** What is on it: each instance the game's to change, the list put on and taken off by `applyBuff`, `removeBuff` */
|
|
151
|
+
buffs = [];
|
|
152
|
+
/** The resource it stands on (`UnitTypeDef.builtOn`), by id: none for what stands on the ground */
|
|
153
|
+
on;
|
|
154
|
+
/** Min corner of the footprint in grid cells, for buildings and resources */
|
|
155
|
+
cell;
|
|
156
|
+
/** Bookkeeping of the spatial index: the last query that found it. Not game state */
|
|
157
|
+
spatialStamp = 0;
|
|
158
|
+
/** Stats as last worked out, see `statsOf`. Derived from the rest, never saved or sent */
|
|
159
|
+
statsCache = null;
|
|
160
|
+
/**
|
|
161
|
+
* What everyone in sight was last told of it (`commonEntityState`), told again as it is while it still says the
|
|
162
|
+
* truth (`commonStillTold`). Derived from the rest, never saved
|
|
163
|
+
*
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
told = null;
|
|
167
|
+
/**
|
|
168
|
+
* What its buffs may hold it to (stunned, rooted, invisible...), one bit each as `buffFlags` works them out, -1 until
|
|
169
|
+
* it does: put back to that by every write of its buffs. Derived from the rest, never saved or sent
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
buffFlags = -1;
|
|
174
|
+
/** @internal The version of the buff definitions `buffFlags` was worked out from (`Definitions.version`) */
|
|
175
|
+
buffFlagsOf = 0;
|
|
176
|
+
/**
|
|
177
|
+
* State of game modules and mods by each component's number (`Component.slot`): the one store of it (design review
|
|
178
|
+
* E4), for `get` and `has` one load from a list. Plain data, which goes into a save (by id: `components`)
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
slots = [];
|
|
183
|
+
/**
|
|
184
|
+
* Its components, in the order it was given them: the order a save, a snapshot and the index go through them in,
|
|
185
|
+
* so that a world hashes and saves the same whatever numbers its process gave its components
|
|
186
|
+
*
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
held = [];
|
|
190
|
+
/**
|
|
191
|
+
* The index of the world it is in (`EntityIndex`), told when it gets or loses a component, and the way to its world
|
|
192
|
+
* (`order`). Not game state
|
|
193
|
+
*/
|
|
194
|
+
index = null;
|
|
195
|
+
constructor(id, def, owner, position) {
|
|
196
|
+
this.id = id;
|
|
197
|
+
this.def = def;
|
|
198
|
+
this.owner = owner;
|
|
199
|
+
this.pos = {
|
|
200
|
+
x: position.x,
|
|
201
|
+
z: position.z
|
|
202
|
+
};
|
|
203
|
+
this.prevPos = {
|
|
204
|
+
x: position.x,
|
|
205
|
+
z: position.z
|
|
206
|
+
};
|
|
207
|
+
this.health = this.maxHealth = def.stats.health;
|
|
208
|
+
this.maxMana = def.stats.mana ?? 0;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Gives it an order, as its owner would: `unit.order('move', point)`, `unit.order('attack', enemy)`,
|
|
212
|
+
* `unit.order('cast', { ability: 'blink', point })`. What it is aimed at is a point (`point`), an entity (`target`)
|
|
213
|
+
* or the order's fields (`OrderInits`). It is the `order` command of its owner through its world (`World.issue`):
|
|
214
|
+
* taken up at the next tick, turned away as a player's would be (an order its type does not take, a target its owner
|
|
215
|
+
* does not know), and kept by a replay. `queue` puts it after what it was told before. Throws for an entity that is
|
|
216
|
+
* in no world (taken out of it)
|
|
217
|
+
*/
|
|
218
|
+
order(type, aim, options = {}) {
|
|
219
|
+
const world = this.index?.world?.();
|
|
220
|
+
if (!world) throw new Error(`${this.def.id}#${this.id} is in no world: it cannot be given an order`);
|
|
221
|
+
let init;
|
|
222
|
+
if (aim instanceof Entity) init = {
|
|
223
|
+
type,
|
|
224
|
+
target: aim.id
|
|
225
|
+
};
|
|
226
|
+
else if (aim && isPoint(aim)) init = {
|
|
227
|
+
type,
|
|
228
|
+
point: {
|
|
229
|
+
x: aim.x,
|
|
230
|
+
z: aim.z
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
else init = {
|
|
234
|
+
...aim,
|
|
235
|
+
type
|
|
236
|
+
};
|
|
237
|
+
world.issue({
|
|
238
|
+
type: "order",
|
|
239
|
+
player: this.owner,
|
|
240
|
+
entities: [this.id],
|
|
241
|
+
order: init,
|
|
242
|
+
...options.queue && { queue: true }
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The engine's writes of what is read-only to everyone else, each kept in step by the world's function that calls it
|
|
247
|
+
* (`World.place`, `World.setOwner`, `World.setHidden`, `World.setLifetime`, `morph`, a death, a hero brought back).
|
|
248
|
+
* A game changes these through those functions, never here
|
|
249
|
+
*
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
moveTo(x, z) {
|
|
253
|
+
const pos = this.pos;
|
|
254
|
+
pos.x = x;
|
|
255
|
+
pos.z = z;
|
|
256
|
+
}
|
|
257
|
+
/** @internal See `moveTo`: its type, which a building's upgrade or a morph changes */
|
|
258
|
+
retype(def) {
|
|
259
|
+
this.def = def;
|
|
260
|
+
}
|
|
261
|
+
/** @internal See `moveTo`: whose it is (`World.setOwner`) */
|
|
262
|
+
changeOwner(owner) {
|
|
263
|
+
this.owner = owner;
|
|
264
|
+
}
|
|
265
|
+
/** @internal See `moveTo`: whether it is in the world (a death, a hero brought back) */
|
|
266
|
+
setAlive(alive) {
|
|
267
|
+
this.alive = alive;
|
|
268
|
+
}
|
|
269
|
+
/** @internal See `moveTo`: whether it is inside something (`World.setHidden`) */
|
|
270
|
+
setInside(hidden) {
|
|
271
|
+
this.hidden = hidden;
|
|
272
|
+
}
|
|
273
|
+
/** @internal See `moveTo`: whether it only stands there (`isScenery`, `World.wake`) */
|
|
274
|
+
setScenery(scenery) {
|
|
275
|
+
this.scenery = scenery;
|
|
276
|
+
}
|
|
277
|
+
/** @internal See `moveTo`: seconds until it is gone by itself, none for what lasts (`World.setLifetime`). Gives them back */
|
|
278
|
+
expireIn(seconds) {
|
|
279
|
+
return this.expires = seconds;
|
|
280
|
+
}
|
|
281
|
+
/** @internal See `moveTo`: an order put at the end of its queue */
|
|
282
|
+
addOrder(order) {
|
|
283
|
+
this.orders.push(order);
|
|
284
|
+
}
|
|
285
|
+
/** @internal See `moveTo`: its queue cut to its first `count` orders, none when left out */
|
|
286
|
+
keepOrders(count = 0) {
|
|
287
|
+
this.orders.length = Math.min(count, this.orders.length);
|
|
288
|
+
}
|
|
289
|
+
/** @internal See `moveTo`: an order out of its queue, wherever it is: whether it was there */
|
|
290
|
+
removeOrder(order) {
|
|
291
|
+
const at = this.orders.indexOf(order);
|
|
292
|
+
if (at >= 0) this.orders.splice(at, 1);
|
|
293
|
+
return at >= 0;
|
|
294
|
+
}
|
|
295
|
+
/** @internal See `moveTo`: what it can cast, all of it (a morph, an upgrade) */
|
|
296
|
+
setAbilities(abilities) {
|
|
297
|
+
this.abilities = abilities;
|
|
298
|
+
}
|
|
299
|
+
/** @internal See `moveTo`: one more it can cast (a hero learning one) */
|
|
300
|
+
addAbility(ability) {
|
|
301
|
+
this.abilities.push(ability);
|
|
302
|
+
}
|
|
303
|
+
/** @internal See `moveTo`: a buff put on (`applyBuff`) */
|
|
304
|
+
addBuff(buff) {
|
|
305
|
+
this.buffs.push(buff);
|
|
306
|
+
this.buffFlags = -1;
|
|
307
|
+
}
|
|
308
|
+
/** @internal See `moveTo`: the buff at an index taken off (`removeBuff`, one run out): it, if there was one */
|
|
309
|
+
dropBuff(index) {
|
|
310
|
+
this.buffFlags = -1;
|
|
311
|
+
return this.buffs.splice(index, 1)[0];
|
|
312
|
+
}
|
|
313
|
+
/** @internal See `moveTo`: every buff off at once (a death, a hero brought back) */
|
|
314
|
+
clearBuffs() {
|
|
315
|
+
this.buffs.length = 0;
|
|
316
|
+
this.buffFlags = -1;
|
|
317
|
+
}
|
|
318
|
+
/** @internal See `moveTo`: its buffs changed in place by who had to (a kill's triggers lending the fallen what it carried) */
|
|
319
|
+
buffsChanged() {
|
|
320
|
+
this.buffFlags = -1;
|
|
321
|
+
}
|
|
322
|
+
/** @internal See `moveTo`: a field a save kept (`ENTITY_SAVE`), as a save is loaded */
|
|
323
|
+
restore(field, value) {
|
|
324
|
+
this[field] = value;
|
|
325
|
+
if (field === "buffs") this.buffFlags = -1;
|
|
326
|
+
}
|
|
327
|
+
/** A component of a game module or a mod, see `defineComponent` */
|
|
328
|
+
get(key) {
|
|
329
|
+
return this.slots[key.slot];
|
|
330
|
+
}
|
|
331
|
+
/** Whether it holds the component */
|
|
332
|
+
has(key) {
|
|
333
|
+
return this.slots[key.slot] !== void 0;
|
|
334
|
+
}
|
|
335
|
+
/** Gives it the component, or a new value of it. `undefined` takes it away (`remove`) */
|
|
336
|
+
set(key, value) {
|
|
337
|
+
if (value === void 0) return this.remove(key);
|
|
338
|
+
const had = this.slots[key.slot] !== void 0;
|
|
339
|
+
this.slots[key.slot] = value;
|
|
340
|
+
if (had) return;
|
|
341
|
+
this.held.push(key);
|
|
342
|
+
this.index?.componentChanged(this, key.id, true);
|
|
343
|
+
}
|
|
344
|
+
/** Takes the component away; nothing happens when it has none */
|
|
345
|
+
remove(key) {
|
|
346
|
+
if (this.slots[key.slot] === void 0) return;
|
|
347
|
+
this.slots[key.slot] = void 0;
|
|
348
|
+
this.held.splice(this.held.findIndex((each) => each.slot === key.slot), 1);
|
|
349
|
+
this.index?.componentChanged(this, key.id, false);
|
|
350
|
+
}
|
|
351
|
+
/** Its components, in the order it was given them: each one's value is `get(component)` */
|
|
352
|
+
heldComponents() {
|
|
353
|
+
return this.held;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Its components' values by id, in the order it was given them: made each time it is asked, for what reads them
|
|
357
|
+
* by id now and then (a save, the inspector). What does it often goes through `heldComponents`
|
|
358
|
+
*/
|
|
359
|
+
get components() {
|
|
360
|
+
const values = {};
|
|
361
|
+
for (const component of this.held) values[component.id] = this.slots[component.slot];
|
|
362
|
+
return values;
|
|
363
|
+
}
|
|
364
|
+
/** Whether its type is a building */
|
|
365
|
+
get isBuilding() {
|
|
366
|
+
return this.def.kind === "building";
|
|
367
|
+
}
|
|
368
|
+
/** Whether its type is a unit */
|
|
369
|
+
get isUnit() {
|
|
370
|
+
return this.def.kind === "unit";
|
|
371
|
+
}
|
|
372
|
+
/** Whether its type is a resource */
|
|
373
|
+
get isResource() {
|
|
374
|
+
return this.def.kind === "resource";
|
|
375
|
+
}
|
|
376
|
+
/** Up in the air, where the ground and what stands on it are not in the way */
|
|
377
|
+
get flying() {
|
|
378
|
+
return this.def.flying === true;
|
|
379
|
+
}
|
|
380
|
+
/** Whether its type is a building or a resource: anything but a unit */
|
|
381
|
+
get isStructure() {
|
|
382
|
+
return this.def.kind !== "unit";
|
|
383
|
+
}
|
|
384
|
+
/** Completed and able to do its job */
|
|
385
|
+
get operational() {
|
|
386
|
+
if (!this.alive) return false;
|
|
387
|
+
if (this.def.kind === "unit") return true;
|
|
388
|
+
return this.slots[constructionSite.slot] === void 0;
|
|
389
|
+
}
|
|
390
|
+
/** The order it carries out now, the first of its orders; nothing when it has none */
|
|
391
|
+
get currentOrder() {
|
|
392
|
+
return this.orders[0];
|
|
393
|
+
}
|
|
394
|
+
/** Ground area covered by a structure: a new rect each time, for who keeps it (an obstacle, a wall's reshape) */
|
|
395
|
+
get rect() {
|
|
396
|
+
return {
|
|
397
|
+
x: this.pos.x,
|
|
398
|
+
z: this.pos.z,
|
|
399
|
+
hw: this.halfWidth,
|
|
400
|
+
hd: this.halfDepth
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
/** Half of what it covers across (`rect.hw`), with no rect made: what is asked all the time (is a structure in sight) */
|
|
404
|
+
get halfWidth() {
|
|
405
|
+
const fp = this.def.footprint;
|
|
406
|
+
return fp ? fp.w / 2 : this.def.radius;
|
|
407
|
+
}
|
|
408
|
+
/** Half of what it covers from front to back (`rect.hd`), as `halfWidth` */
|
|
409
|
+
get halfDepth() {
|
|
410
|
+
const fp = this.def.footprint;
|
|
411
|
+
return fp ? fp.d / 2 : this.def.radius;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* Distance from a point to the edge of an entity
|
|
416
|
+
*
|
|
417
|
+
* @beta
|
|
418
|
+
*/
|
|
419
|
+
function distanceToEdge(point, target) {
|
|
420
|
+
if (target.def.footprint) {
|
|
421
|
+
const fp = target.def.footprint;
|
|
422
|
+
const dx = Math.max(Math.abs(point.x - target.pos.x) - fp.w / 2, 0);
|
|
423
|
+
const dz = Math.max(Math.abs(point.z - target.pos.z) - fp.d / 2, 0);
|
|
424
|
+
return Math.sqrt(dx * dx + dz * dz);
|
|
425
|
+
}
|
|
426
|
+
const dx = point.x - target.pos.x;
|
|
427
|
+
const dz = point.z - target.pos.z;
|
|
428
|
+
return Math.max(Math.sqrt(dx * dx + dz * dz) - target.def.radius, 0);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Distance between the edges of two entities
|
|
432
|
+
*
|
|
433
|
+
* @beta
|
|
434
|
+
*/
|
|
435
|
+
function edgeDistance(a, b) {
|
|
436
|
+
return Math.max(distanceToEdge(a.pos, b) - a.def.radius, 0);
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
export { Entity, deposit, detection, distanceToEdge, edgeDistance, exposure, fighting, moving };
|
|
440
|
+
|
|
441
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","names":[],"sources":["../src/entity.ts"],"sourcesContent":["import { type Cost, type EffectDef, type ResourceId, type UnitTypeDef } from './defs'\nimport { type Component, defineComponent } from './components'\n// (read as a structure asks whether it stands, never as the modules load: the systems' module comes round to this one)\nimport { constructionSite } from './systems/construction'\nimport type { Rect, Vec2 } from './math'\nimport type { StatsCache } from './stats'\nimport type { EntityState } from './session/protocol'\nimport type { OrderInit, OrderParams } from './registry'\nimport type { World } from './world'\n\n/**\n * The number an entity has in its world, unique there\n *\n * @public\n */\nexport type EntityId = number\n/**\n * The number of a player in a world\n *\n * @public\n */\nexport type PlayerId = number\n\n/**\n * An order a unit carries out or has queued. `State` is what its behaviour keeps in it (`OrderBehavior<State>`): empty\n * as the order is given, so every field of it is one that may not be there yet\n *\n * @beta\n */\nexport interface Order<State extends object = Record<string, any>, Init extends object = OrderParams> {\n\t/** The order's number, unique in its world */\n\tid: number\n\t/** The order's type, naming the behaviour that carries it out */\n\ttype: string\n\t/** What it was given, as its type takes it (`OrderInits`): plain data, saved with the order */\n\tinit: Init\n\t/** Shared by every unit that received the order from the same command */\n\tgroupId: number\n\t/** Whether the order has begun being carried out */\n\tstarted: boolean\n\t/** Scratch space owned by the order behavior: plain data, saved with the order */\n\tstate: State\n}\n\n/**\n * What a unit holds of one of its abilities: its level, cooldown, charges and autocast\n *\n * @beta\n */\nexport interface AbilityState {\n\t/** The id of the ability this is the state of */\n\tid: string\n\t/** 0 for an ability a hero has not learned yet */\n\tlevel: number\n\t/** Seconds until it can be used again */\n\tcooldown: number\n\t/**\n\t * Uses left, of an ability with charges (`AbilityDef.charges`): all it holds when left out, and `chargesLeft` says\n\t * how many that is. Set while it holds fewer\n\t */\n\tcharges?: number\n\t/** Seconds until the next use is back, while it holds fewer than it can */\n\trefill?: number\n\t/** Whether the ability is cast by itself when its conditions are met */\n\tautocast: boolean\n\t/** Where it was last aimed */\n\tpoint?: Vec2\n\t/** For one aimed along two points (`vector`): the second, the way it went from `point` */\n\tto?: Vec2\n\t/**\n\t * The game's own state of the ability on this unit, plain data (numbers, text, lists and plain objects of them):\n\t * ammo, a count of what it hit, a mark it left. Saved with the unit and told to its owner's screen with the rest of\n\t * the ability (`AbilityInfo.data`), for a button to show. Nothing of the engine's reads it\n\t *\n\t * @beta\n\t */\n\tdata?: Record<string, unknown>\n\t/**\n\t * Its window to be cast again, while it is open (`AbilityDef.recast`): the next cast is a recast\n\t *\n\t * @beta\n\t */\n\trecast?: RecastWindow\n}\n\n/**\n * An ability's window to be cast again (`AbilityState.recast`, `AbilityDef.recast`)\n *\n * @beta\n */\nexport interface RecastWindow {\n\t/** Seconds left of it */\n\tleft: number\n\t/** Seconds it was open for in all, for a button to show how much is left */\n\ttotal: number\n\t/** Recasts made in it so far */\n\tused: number\n\t/** The cooldown that starts as it closes, for one whose cooldown waits for it (`after`) */\n\tcooldown?: number\n}\n\n/**\n * A buff on a unit: which, from what level, how long is left and who put it there\n *\n * @beta\n */\nexport interface BuffInstance {\n\t/** The id of the buff */\n\tid: string\n\t/** Level of the ability it came from */\n\tlevel: number\n\t/** Seconds left. Infinity for buffs that stay */\n\tremaining: number\n\t/** Seconds the buff has been on */\n\telapsed: number\n\t/** Entity that put it there */\n\tsource: EntityId\n\t/** What is left of the shield it gives */\n\tshield?: number\n\t/** How many of it there are, for buffs that pile up */\n\tstacks?: number\n\t/** The ability it came from, for buffs that do something when their time is up */\n\tability?: string\n\t/**\n\t * Kept up by an ability of its source's for as long as it holds (a passive's buff, an aura's): put on again every\n\t * round for a moment, with no time of its own to show (`EntityState.buffTimes` says -1)\n\t */\n\tkept?: boolean\n\t/** State of the game's own about this one buff: a counter, what it has done so far. Plain data: it is saved */\n\tdata?: Record<string, unknown>\n}\n\n/**\n * An item someone carries\n *\n * @beta\n */\nexport interface ItemInstance {\n\t/** The item instance's number, unique in its world */\n\tid: number\n\t/** The id of the item type */\n\titem: string\n\t/** Uses left, for items that run out */\n\tcharges: number\n\t/** Cooldown of the ability the item gives */\n\tstate?: AbilityState\n\t/** Seconds until its next charge comes back, for an item that refills over time (`ItemDef.refill`) while it is short */\n\trefill?: number\n\t/** State of the game's own about this one item: kills it has seen, what it has stored. Plain data: it is saved */\n\tdata?: Record<string, unknown>\n}\n\n/**\n * What a shop has of one of its wares (`shopStock`, a component of the entity's)\n *\n * @beta\n */\nexport interface StockState {\n\t/** The id of the item type for sale */\n\titem: string\n\t/** How many of it the shop has now */\n\tcount: number\n\t/** Seconds until the next one arrives */\n\trestock: number\n}\n\n/**\n * How a unit's move is going: it is not moving, on its way, got there, or could not\n *\n * @beta\n */\nexport type MoveStatus = 'idle' | 'moving' | 'arrived' | 'failed'\n\n/**\n * What a unit keeps of its moving: speed, goal, status and the path's bookkeeping\n *\n * @beta\n */\nexport interface MovementState {\n\t/** Units per second it goes at now */\n\tspeed: number\n\t/** The fastest it goes for now, whatever its speed: a group's slowest, as it moves together (`OrderParams.together`) */\n\tcap?: number\n\t/** Whether it is idle, on its way, arrived or failed to get there */\n\tstatus: MoveStatus\n\t/** Where it is heading, in cells */\n\tgoal: Vec2\n\t/** When set the goal follows this entity */\n\tgoalEntity: EntityId\n\t/** Arrive once this close to the goal (edge distance for entity goals) */\n\trange: number\n\t/** The group of units that were sent together; the same as the `groupId` of their order */\n\tgroupId: number\n\t/** Last destination handed to the navigation */\n\tnavGoal: Vec2\n\t/** The version of the navigation when the goal was handed to it */\n\tnavVersion: number\n\t/** Corner of the path the unit is heading for. Progress is measured towards it, so a long way round is not mistaken for standing still */\n\tcorner: Vec2\n\t/** Closest the unit has been to its corner, used to detect that it stopped making progress */\n\tbestDistance: number\n\t/** Seconds it has made no progress towards its corner */\n\tstalledTime: number\n\t/**\n\t * Seconds it has gone well under its speed on its way, held up by others (not counting getting going, or slowing\n\t * to arrive): what has those in its way asked to step aside (see `RuleSettings.movement.lookAhead`)\n\t */\n\tslowTime?: number\n\t/**\n\t * The point it goes round standing units by, on its way to the next corner of its path, when that is not much\n\t * longer (`RuleSettings.movement.goesAround`, the `detour` hook): none while it goes straight\n\t */\n\tdetour?: Vec2\n\t/** Where it heads on from `detour`: the corner of its path it went round the knot towards */\n\tdetourAim?: Vec2\n\t/** On a step aside for another (`MoveOptions.aside`): it goes round nobody and asks nobody to make way */\n\taside?: boolean\n\t/** Whether it was sent on past `detour`, towards its path, as it neared it */\n\tdetourPast?: boolean\n\t/**\n\t * The group of the formation it was last sent in (`OrderInit.formation`, the order's `groupId`): those of one swap\n\t * places on the way, and keep the places they get to (`place`)\n\t */\n\tformation?: number\n\t/**\n\t * Its place in its formation, once there. Stepped aside or pushed off it, it walks back once it has stood off it a\n\t * while. None once it walks off on a move of its own, or is given another order\n\t */\n\tplace?: Vec2\n\t/** How many times it went back to its place without getting there: it lets it go after a few */\n\tbackTries?: number\n\t/**\n\t * How many times it tried again on this move, held up 3 seconds by others that may yet go (in a crowd, say): sent on\n\t * anew, round the whole knot, those in it asked aside. It gives up after 4, or none when what holds it up is the\n\t * ground or those holding their ground. Counted again once it gets 2 cells nearer\n\t */\n\ttries?: number\n\t/** How far it had left to go when it last tried again */\n\ttriedAt?: number\n\t/**\n\t * On a step aside asked by one stepping aside itself: how far down that line it is (2, 3). One that far asks nobody\n\t * aside in turn, so that a crowd parts a few deep and no further\n\t */\n\tasideDepth?: number\n\t/** Whether the last move failed by getting stuck on the way (in a crowd, say), not for there being no way there */\n\tstuck?: boolean\n\t/** Whether the unit holds its ground in a fight, so that others come round it */\n\tanchored: boolean\n\t/** Whether the navigation lets it through others, as a ghost */\n\tghost: boolean\n\t/**\n\t * Whether a buff it carries has it walk through others now (`BuffDef.phasing`): a ghost to the navigation as well,\n\t * whatever `ghost` says. Seen to every tick by the movement\n\t */\n\tphased?: boolean\n\t/** Direction the unit turns to while it stands still. Null when it may face wherever it ended up */\n\tfinalFacing: number | null\n\t/**\n\t * The route its side planned to the goal, corner by corner, with what the side knows (`Rules.paths: 'seen'`):\n\t * walked a stretch at a time. None where routes know everything, or there is no route\n\t */\n\troute?: Vec2[]\n\t/** The corner of `route` it heads past next */\n\trouteAt?: number\n\t/** What its side knew when the route was planned (`SidePaths.version`): it is planned again once that changes */\n\trouteVersion?: number\n\t/** Where along `route` the navigation was last sent it: a stretch no longer than it can see */\n\tstretch?: Vec2\n}\n\n/**\n * What moves of an entity: where it goes, how fast, how it is doing (`MovementState`). Units that walk, swim or fly\n * have it from their type's speed; a building, a tree, or a unit an upgrade stopped has none. Filed (`index`), for the\n * movement system to go through\n *\n * @beta\n */\nexport const moving = defineComponent<MovementState>({ id: 'core.moving', index: true })\n\n/**\n * What a unit keeps of its fighting: cooldown, swing, targets and recovery\n *\n * @beta\n */\nexport interface CombatState {\n\t/** Seconds until the next attack may start */\n\tcooldown: number\n\t/** Seconds until the running swing lands. 0 when not swinging */\n\tswing: number\n\t/** The entity the running swing is aimed at */\n\tswingTarget: EntityId\n\t/**\n\t * Which of its attacks the running swing, or the last, is of, by place (`UnitTypeDef.attacks`): the first when left\n\t * out, as for every unit with one. It swings one at a time, and waits out the cooldown of the one that hit\n\t */\n\tweapon?: number\n\t/**\n\t * Seconds left of the recovery after its last blow (`AttackDef.recovery`), while what it is told waits: none when\n\t * it has none\n\t */\n\trecovery?: number\n\t/** Target picked by the unit itself rather than by an order */\n\tautoTarget: EntityId\n\t/** The entity that last hit it */\n\tlastAttacker: EntityId\n\t/** Where an idle unit returns to after chasing */\n\tguard: Vec2 | null\n\t/** Does not pick fights of its own accord until it gets an order (set by a game's rules; `stop` no longer sets it) */\n\tpassive: boolean\n\t/** What it is fighting or closing in on, whoever picked it: 0 for nothing (see `engagement.ts`) */\n\tengaged?: EntityId\n\t/** The spot it holds around that, as an angle seen from it. Null when it has none: it flies, it hits a building */\n\tslot?: number | null\n\t/** Targets it left alone because it could not get at them, and until when, in world time */\n\tshunned?: [EntityId, number][]\n\t/** The tick the allies of whoever it hit were last called to help (`RuleSettings.combat.helpRange`), so that they are asked once in a while, not by every blow. Unset until it hits someone */\n\thelpedAt?: number\n}\n\n/**\n * How an entity fights (`CombatState`): its cooldown, its swing, what it is engaged with. What attacks has it from its\n * type's attack; an upgrade that takes the attack away takes it. Filed (`index`), for the combat system to go through\n *\n * @beta\n */\nexport const fighting = defineComponent<CombatState>({ id: 'core.fighting', index: true })\n\n/**\n * What a worker keeps of its gathering: what it carries and where it gathered\n *\n * @beta\n */\nexport interface HarvesterState {\n\t/** How much of the resource the worker carries */\n\tcarrying: number\n\t/** What it is that the worker carries, or last gathered. Null for one that has not gathered anything yet */\n\tkind: ResourceId | null\n\t/** Last resource this worker gathered from */\n\tresource: EntityId\n}\n\n/**\n * What is left of a deposit and how many are at it\n *\n * @beta\n */\nexport interface ResourceState {\n\t/** How much of the resource is left in it */\n\tamount: number\n\t/** How many workers are at it, inside or working on it */\n\toccupants: number\n\t/** The building that stands on it (`UnitTypeDef.builtOn`), by id: none when nothing does */\n\tunder?: EntityId\n}\n\n/**\n * What is left of what can be gathered from an entity, and who is at it (`ResourceState`): a mine's gold, a tree's\n * lumber. What its type gives (`UnitTypeDef.resource`) as it is made. Filed (`index`), for what looks for the nearest\n *\n * @beta\n */\nexport const deposit = defineComponent<ResourceState>({ id: 'core.deposit', index: true })\n\n/**\n * How far a building under construction has got\n *\n * @beta\n */\nexport interface ConstructionState {\n\t/** 0..1 */\n\tprogress: number\n\t/** Seconds a single builder needs to finish it */\n\tbuildTime: number\n\t/** Builders that worked on it during the current tick */\n\tbuilders: number\n\t/** What was paid for it, when that is not what its type costs. A cancelled site gives part of this back */\n\tpaid?: Cost\n}\n\n/**\n * One thing a building makes: a unit, an upgrade, a revive or a morph\n *\n * @beta\n */\nexport interface ProductionItem {\n\t/** What it makes: a unit, an upgrade, a revived hero or a morph into another type */\n\tkind: 'unit' | 'upgrade' | 'revive' | 'morph'\n\t/** Unit type, upgrade id, the id of the hero to bring back, or the type the building turns into */\n\tid: string\n\t/** What was paid, when that does not follow from the id */\n\tpaid?: Cost\n\t/** Seconds of work done */\n\tprogress: number\n\t/** Seconds it takes in all */\n\tduration: number\n}\n\n/** Seconds by team, kept in a save as its entries: what `exposure` and `detection` are */\nconst byTeam = { save: (value: Map<number, number>) => [...value], load: (saved: unknown) => new Map(saved as [number, number][]) }\n\n/**\n * Seconds an entity stays in sight of other teams, by team, for having attacked them: seen where it stands, in the fog\n * and in a bush. Filed (`index`), for the fog to light those that have it\n *\n * @beta\n */\nexport const exposure = defineComponent<Map<number, number>>({ id: 'core.exposure', index: true, ...byTeam })\n\n/**\n * Seconds the teams that found an invisible entity with something that reveals it can go on seeing it, by team. Filed\n * (`index`), for the fog to light those that have it\n *\n * @beta\n */\nexport const detection = defineComponent<Map<number, number>>({ id: 'core.detection', index: true, ...byTeam })\n\n/**\n * Whose picture an entity wears: the type it is drawn as, and the owner whose colour it is drawn in. Nothing in the\n * rules goes by it\n *\n * @beta\n */\nexport interface Likeness {\n\t/** The unit type whose picture the entity wears */\n\ttype: string\n\t/** The player whose colour the entity is drawn in */\n\towner: PlayerId\n}\n\n/**\n * A rush to a spot: nothing stops it, and what it does happens where it ends\n *\n * @beta\n */\nexport interface Dash {\n\t/** Where it ends, east-west in cells */\n\tx: number\n\t/** Where it ends, north-south in cells */\n\tz: number\n\t/** Where it started */\n\tfrom: Vec2\n\t/** Units per second */\n\tspeed: number\n\t/** The id of the ability that sent it */\n\tability: string\n\t/** The level of the ability it was cast at */\n\tlevel: number\n\t/**\n\t * Which effect of the ability sent it, by its place there (`effectIndex`): what the screen draws it with\n\t * (`AbilityLook.effects`). Nothing to the rules\n\t *\n\t * @beta\n\t */\n\teffect?: number\n\t/** The effects that happen where it ends */\n\teffects: EffectDef[]\n\t/** How high it rises on the way: a leap, over whatever is in between */\n\theight?: number\n\t/** A buff it carries for as long as the rush lasts */\n\tbuff?: string\n\t/**\n\t * Dragged by someone (the effect `pull`): `by` whom, in whose name `effects` happen to it as it arrives, and whether\n\t * it is dragged after them as they move (`follows`) or to the spot (`x`, `z`). It does nothing of its own meanwhile,\n\t * and nothing else moves it\n\t *\n\t * @beta\n\t */\n\tpulled?: { by: EntityId; follows: boolean }\n\t/**\n\t * The unit it rushes to (a `dash` to a unit, in a game with the moves pack): its landing `effects` happen to it, where\n\t * it still is in the world\n\t *\n\t * @beta\n\t */\n\ttarget?: EntityId\n}\n\n/**\n * Where the units a building makes go: a point, or an entity they follow\n *\n * @beta\n */\nexport interface RallyPoint {\n\t/** The place the units go to */\n\tpoint: Vec2\n\t/** The entity they follow; 0 for none */\n\ttarget: EntityId\n}\n\n/**\n * What a building makes: the queue of what it is making, and its rally point\n *\n * @beta\n */\nexport interface ProductionState {\n\t/** What it makes in turn, the first being worked on */\n\tqueue: ProductionItem[]\n\t/** Where the units it makes go, or null for none */\n\trally: RallyPoint | null\n}\n\n/**\n * How an order is given (`Entity.order`)\n *\n * @public\n */\nexport interface OrderOptions {\n\t/** After what it was told before, rather than in its place: Shift held */\n\tqueue?: boolean\n}\n\n/**\n * A point, told from an order's fields: what has a number `x` and `z` (a map's point, an entity's `pos`), which no field\n * of an order is named\n */\nconst isPoint = (aim: object): aim is Vec2 => typeof (aim as Vec2).x === 'number' && typeof (aim as Vec2).z === 'number'\n\n/**\n * Anything in the world: a unit, a building, a tree.\n *\n * Fields marked `readonly` are kept in step with things elsewhere (the navigation, the spatial index, the lookups\n * of the world), so they are changed through the world's functions only: `World.setOwner`, `World.setHidden`,\n * `World.setLifetime`, `World.place`, `startDash`, `morph` (each through the entity's own internal writes: `moveTo`,\n * `retype`, `changeOwner`…). The rest, like health, mana or cooldowns, a game\n * module may change as it likes: nothing is worked out from them that would not notice.\n *\n * @public\n */\nexport class Entity {\n\t/** Whether the entity is in the world; false once it died */\n\treadonly alive: boolean = true\n\t/** Hidden entities are inside something (a gold mine) and do not take part in the world */\n\treadonly hidden: boolean = false\n\t/**\n\t * Only stands there, like a tree: left out of the systems that run every tick, see `isScenery`.\n\t * Becomes false for good once something gives it anything to do (`World.wake`)\n\t */\n\treadonly scenery: boolean = false\n\n\t/** Where it stands in cells (`x`, `z`), changed through the world's functions only */\n\treadonly pos: Readonly<Vec2>\n\t/** Where it stood at the last tick, for the screen to draw between */\n\treadonly prevPos: Vec2\n\t/** The way it faces in radians */\n\tfacing = 0\n\t/** The way it faced at the last tick, in radians, for the screen to draw between */\n\tprevFacing = 0\n\t/** How big it is drawn, for the look of a map. Nothing in the rules goes by it */\n\tscale = 1\n\t/** Which of the models of its type it is drawn with, for the look of a map. Nothing in the rules goes by it either */\n\tlook?: string\n\t/**\n\t * Drawn as another's type and owner: a soul in the fallen's shape (`SpawnOptions.looksLike`). Its own type and owner\n\t * decide everything but the picture\n\t */\n\tlikeness?: Likeness\n\t/** Velocity of the last tick */\n\treadonly velocity: Vec2 = { x: 0, z: 0 }\n\n\t/** Hit points it has now; it dies at 0 */\n\thealth: number\n\t/** Teams that have seen this entity at least once, one bit per team as `FogOfWar.teamBit` hands them out. Ask `World.hasSeen` */\n\tseenBy = 0\n\t/** When it was last hurt, in seconds of the game. Long ago for what never was */\n\thurtAt = -Infinity\n\t/** Seconds until it is gone by itself, for what does not last */\n\treadonly expires: number | null = null\n\t/** Seconds it was given to last, for what does not */\n\tlifetime = 0\n\t/** Seconds until enemies cannot see it any more, for what is invisible. 0 once they cannot */\n\tunseenIn: number | null = null\n\n\t/**\n\t * What it was told to do, the first what it does now and the rest in turn: read here, given and ended through the\n\t * orders' functions (`giveOrder`, `clearOrders`, `completeOrder`), which write it with the entity's own `addOrder`,\n\t * `keepOrders` and `removeOrder`\n\t */\n\treadonly orders: readonly Order[] = []\n\n\t/** Invisible to enemies right now, unless they have found it */\n\tget unseen(): boolean {\n\t\treturn this.unseenIn === 0\n\t}\n\n\t/** The most hit points it can have */\n\tmaxHealth: number\n\t/** Mana it has now */\n\tmana = 0\n\t/** The most mana it can have */\n\tmaxMana: number\n\t/** Does nothing by itself until something wakes it, and is drawn sleeping: creeps at night */\n\tasleep = false\n\t/** A fallen hero that is on its way back */\n\treviving = false\n\t/**\n\t * What it can cast, with their levels and cooldowns: each state is the game's to change (`cooldown`, `autocast`),\n\t * the list the engine's (a type's own, what a hero learns), written with the entity's own internal methods\n\t */\n\treadonly abilities: readonly AbilityState[] = []\n\t/** What is on it: each instance the game's to change, the list put on and taken off by `applyBuff`, `removeBuff` */\n\treadonly buffs: readonly BuffInstance[] = []\n\n\t/** The resource it stands on (`UnitTypeDef.builtOn`), by id: none for what stands on the ground */\n\ton?: EntityId\n\t/** Min corner of the footprint in grid cells, for buildings and resources */\n\tcell?: { x: number; z: number }\n\n\t/** Bookkeeping of the spatial index: the last query that found it. Not game state */\n\tspatialStamp = 0\n\t/** Stats as last worked out, see `statsOf`. Derived from the rest, never saved or sent */\n\tstatsCache: StatsCache | null = null\n\t/**\n\t * What everyone in sight was last told of it (`commonEntityState`), told again as it is while it still says the\n\t * truth (`commonStillTold`). Derived from the rest, never saved\n\t *\n\t * @internal\n\t */\n\ttold: EntityState | null = null\n\t/**\n\t * What its buffs may hold it to (stunned, rooted, invisible...), one bit each as `buffFlags` works them out, -1 until\n\t * it does: put back to that by every write of its buffs. Derived from the rest, never saved or sent\n\t *\n\t * @internal\n\t */\n\tbuffFlags = -1\n\t/** @internal The version of the buff definitions `buffFlags` was worked out from (`Definitions.version`) */\n\tbuffFlagsOf = 0\n\n\t/**\n\t * State of game modules and mods by each component's number (`Component.slot`): the one store of it (design review\n\t * E4), for `get` and `has` one load from a list. Plain data, which goes into a save (by id: `components`)\n\t *\n\t * @internal\n\t */\n\tslots: unknown[] = []\n\t/**\n\t * Its components, in the order it was given them: the order a save, a snapshot and the index go through them in,\n\t * so that a world hashes and saves the same whatever numbers its process gave its components\n\t *\n\t * @internal\n\t */\n\treadonly held: Component<unknown, unknown>[] = []\n\t/**\n\t * The index of the world it is in (`EntityIndex`), told when it gets or loses a component, and the way to its world\n\t * (`order`). Not game state\n\t */\n\tindex: { componentChanged(entity: Entity, id: string, has: boolean): void } | null = null\n\n\tconstructor(\n\t\t/** The entity's number, unique in its world */\n\t\treadonly id: EntityId,\n\t\t/** Changes when a building is upgraded into another type */\n\t\treadonly def: UnitTypeDef,\n\t\t/** The player it belongs to, changed through `World.setOwner` only */\n\t\treadonly owner: PlayerId,\n\t\tposition: Vec2\n\t) {\n\t\tthis.pos = { x: position.x, z: position.z }\n\t\tthis.prevPos = { x: position.x, z: position.z }\n\t\t// what its type starts with: no game rule changes health or mana\n\t\tthis.health = this.maxHealth = def.stats.health\n\t\tthis.maxMana = def.stats.mana ?? 0\n\t}\n\n\t/**\n\t * Gives it an order, as its owner would: `unit.order('move', point)`, `unit.order('attack', enemy)`,\n\t * `unit.order('cast', { ability: 'blink', point })`. What it is aimed at is a point (`point`), an entity (`target`)\n\t * or the order's fields (`OrderInits`). It is the `order` command of its owner through its world (`World.issue`):\n\t * taken up at the next tick, turned away as a player's would be (an order its type does not take, a target its owner\n\t * does not know), and kept by a replay. `queue` puts it after what it was told before. Throws for an entity that is\n\t * in no world (taken out of it)\n\t */\n\torder<Type extends string>(type: Type, aim?: Vec2 | Entity | Omit<OrderInit<Type>, 'type'>, options: OrderOptions = {}): void {\n\t\t// the world by its index (`EntityIndex.world`), which the type of the field leaves out: a type of the data a pack\n\t\t// schema is made of reaches an entity, and must not reach the world through it\n\t\tconst world = (this.index as { world?(): World } | null)?.world?.()\n\t\tif (!world) throw new Error(`${this.def.id}#${this.id} is in no world: it cannot be given an order`)\n\t\tlet init: OrderInit\n\t\tif (aim instanceof Entity) init = { type, target: aim.id }\n\t\telse if (aim && isPoint(aim)) init = { type, point: { x: aim.x, z: aim.z } }\n\t\telse init = { ...(aim as object), type } as OrderInit\n\t\tworld.issue({ type: 'order', player: this.owner, entities: [this.id], order: init, ...(options.queue && { queue: true }) })\n\t}\n\n\t/**\n\t * The engine's writes of what is read-only to everyone else, each kept in step by the world's function that calls it\n\t * (`World.place`, `World.setOwner`, `World.setHidden`, `World.setLifetime`, `morph`, a death, a hero brought back).\n\t * A game changes these through those functions, never here\n\t *\n\t * @internal\n\t */\n\tmoveTo(x: number, z: number): void {\n\t\tconst pos = this.pos as Vec2\n\t\tpos.x = x\n\t\tpos.z = z\n\t}\n\n\t/** @internal See `moveTo`: its type, which a building's upgrade or a morph changes */\n\tretype(def: UnitTypeDef): void {\n\t\t;(this as { def: UnitTypeDef }).def = def\n\t}\n\n\t/** @internal See `moveTo`: whose it is (`World.setOwner`) */\n\tchangeOwner(owner: PlayerId): void {\n\t\t;(this as { owner: PlayerId }).owner = owner\n\t}\n\n\t/** @internal See `moveTo`: whether it is in the world (a death, a hero brought back) */\n\tsetAlive(alive: boolean): void {\n\t\t;(this as { alive: boolean }).alive = alive\n\t}\n\n\t/** @internal See `moveTo`: whether it is inside something (`World.setHidden`) */\n\tsetInside(hidden: boolean): void {\n\t\t;(this as { hidden: boolean }).hidden = hidden\n\t}\n\n\t/** @internal See `moveTo`: whether it only stands there (`isScenery`, `World.wake`) */\n\tsetScenery(scenery: boolean): void {\n\t\t;(this as { scenery: boolean }).scenery = scenery\n\t}\n\n\t/** @internal See `moveTo`: seconds until it is gone by itself, none for what lasts (`World.setLifetime`). Gives them back */\n\texpireIn(seconds: number | null): number | null {\n\t\treturn ((this as { expires: number | null }).expires = seconds)\n\t}\n\n\t/** @internal See `moveTo`: an order put at the end of its queue */\n\taddOrder(order: Order): void {\n\t\t;(this.orders as Order[]).push(order)\n\t}\n\n\t/** @internal See `moveTo`: its queue cut to its first `count` orders, none when left out */\n\tkeepOrders(count = 0): void {\n\t\t;(this.orders as Order[]).length = Math.min(count, this.orders.length)\n\t}\n\n\t/** @internal See `moveTo`: an order out of its queue, wherever it is: whether it was there */\n\tremoveOrder(order: Order): boolean {\n\t\tconst at = this.orders.indexOf(order)\n\t\tif (at >= 0) (this.orders as Order[]).splice(at, 1)\n\t\treturn at >= 0\n\t}\n\n\t/** @internal See `moveTo`: what it can cast, all of it (a morph, an upgrade) */\n\tsetAbilities(abilities: AbilityState[]): void {\n\t\t;(this as { abilities: readonly AbilityState[] }).abilities = abilities\n\t}\n\n\t/** @internal See `moveTo`: one more it can cast (a hero learning one) */\n\taddAbility(ability: AbilityState): void {\n\t\t;(this.abilities as AbilityState[]).push(ability)\n\t}\n\n\t/** @internal See `moveTo`: a buff put on (`applyBuff`) */\n\taddBuff(buff: BuffInstance): void {\n\t\t;(this.buffs as BuffInstance[]).push(buff)\n\t\tthis.buffFlags = -1\n\t}\n\n\t/** @internal See `moveTo`: the buff at an index taken off (`removeBuff`, one run out): it, if there was one */\n\tdropBuff(index: number): BuffInstance | undefined {\n\t\tthis.buffFlags = -1\n\t\treturn (this.buffs as BuffInstance[]).splice(index, 1)[0]\n\t}\n\n\t/** @internal See `moveTo`: every buff off at once (a death, a hero brought back) */\n\tclearBuffs(): void {\n\t\t;(this.buffs as BuffInstance[]).length = 0\n\t\tthis.buffFlags = -1\n\t}\n\n\t/** @internal See `moveTo`: its buffs changed in place by who had to (a kill's triggers lending the fallen what it carried) */\n\tbuffsChanged(): void {\n\t\tthis.buffFlags = -1\n\t}\n\n\t/** @internal See `moveTo`: a field a save kept (`ENTITY_SAVE`), as a save is loaded */\n\trestore(field: string, value: unknown): void {\n\t\t;(this as unknown as Record<string, unknown>)[field] = value\n\t\tif (field === 'buffs') this.buffFlags = -1\n\t}\n\n\t/** A component of a game module or a mod, see `defineComponent` */\n\tget<T>(key: Component<T, unknown>): T | undefined {\n\t\treturn this.slots[key.slot] as T | undefined\n\t}\n\n\t/** Whether it holds the component */\n\thas(key: Component<unknown>): boolean {\n\t\treturn this.slots[key.slot] !== undefined\n\t}\n\n\t/** Gives it the component, or a new value of it. `undefined` takes it away (`remove`) */\n\tset<T>(key: Component<T, unknown>, value: T): void {\n\t\tif (value === undefined) return this.remove(key)\n\t\tconst had = this.slots[key.slot] !== undefined\n\t\tthis.slots[key.slot] = value\n\t\tif (had) return\n\t\tthis.held.push(key as Component<unknown, unknown>)\n\t\tthis.index?.componentChanged(this, key.id, true)\n\t}\n\n\t/** Takes the component away; nothing happens when it has none */\n\tremove(key: Component<unknown>): void {\n\t\tif (this.slots[key.slot] === undefined) return\n\t\tthis.slots[key.slot] = undefined\n\t\t// by its number: a module loaded again (a dev server's) defines another object of the same component\n\t\tthis.held.splice(\n\t\t\tthis.held.findIndex((each) => each.slot === key.slot),\n\t\t\t1\n\t\t)\n\t\tthis.index?.componentChanged(this, key.id, false)\n\t}\n\n\t/** Its components, in the order it was given them: each one's value is `get(component)` */\n\theldComponents(): readonly Component<unknown, unknown>[] {\n\t\treturn this.held\n\t}\n\n\t/**\n\t * Its components' values by id, in the order it was given them: made each time it is asked, for what reads them\n\t * by id now and then (a save, the inspector). What does it often goes through `heldComponents`\n\t */\n\tget components(): Readonly<Record<string, unknown>> {\n\t\tconst values: Record<string, unknown> = {}\n\t\tfor (const component of this.held) values[component.id] = this.slots[component.slot]\n\t\treturn values\n\t}\n\n\t/** Whether its type is a building */\n\tget isBuilding() {\n\t\treturn this.def.kind === 'building'\n\t}\n\n\t/** Whether its type is a unit */\n\tget isUnit() {\n\t\treturn this.def.kind === 'unit'\n\t}\n\n\t/** Whether its type is a resource */\n\tget isResource() {\n\t\treturn this.def.kind === 'resource'\n\t}\n\n\t/** Up in the air, where the ground and what stands on it are not in the way */\n\tget flying() {\n\t\treturn this.def.flying === true\n\t}\n\n\t/** Whether its type is a building or a resource: anything but a unit */\n\tget isStructure() {\n\t\treturn this.def.kind !== 'unit'\n\t}\n\n\t/** Completed and able to do its job */\n\tget operational() {\n\t\t// (a site is a structure's, and what moves is most of what asks)\n\t\tif (!this.alive) return false\n\t\tif (this.def.kind === 'unit') return true\n\t\treturn this.slots[constructionSite.slot] === undefined\n\t}\n\n\t/** The order it carries out now, the first of its orders; nothing when it has none */\n\tget currentOrder(): Order | undefined {\n\t\treturn this.orders[0]\n\t}\n\n\t/** Ground area covered by a structure: a new rect each time, for who keeps it (an obstacle, a wall's reshape) */\n\tget rect(): Rect {\n\t\treturn { x: this.pos.x, z: this.pos.z, hw: this.halfWidth, hd: this.halfDepth }\n\t}\n\n\t/** Half of what it covers across (`rect.hw`), with no rect made: what is asked all the time (is a structure in sight) */\n\tget halfWidth(): number {\n\t\tconst fp = this.def.footprint\n\t\treturn fp ? fp.w / 2 : this.def.radius\n\t}\n\n\t/** Half of what it covers from front to back (`rect.hd`), as `halfWidth` */\n\tget halfDepth(): number {\n\t\tconst fp = this.def.footprint\n\t\treturn fp ? fp.d / 2 : this.def.radius\n\t}\n}\n\n/**\n * Anything with a place and a size: an entity, or what a client knows of one\n *\n * @beta\n */\nexport interface Placed {\n\t/** Where it stands in cells */\n\tpos: Vec2\n\t/** The definition of its type */\n\tdef: UnitTypeDef\n}\n\n/**\n * Distance from a point to the edge of an entity\n *\n * @beta\n */\nexport function distanceToEdge(point: Vec2, target: Placed): number {\n\tif (target.def.footprint) {\n\t\tconst fp = target.def.footprint\n\t\tconst dx = Math.max(Math.abs(point.x - target.pos.x) - fp.w / 2, 0)\n\t\tconst dz = Math.max(Math.abs(point.z - target.pos.z) - fp.d / 2, 0)\n\t\treturn Math.sqrt(dx * dx + dz * dz)\n\t}\n\tconst dx = point.x - target.pos.x\n\tconst dz = point.z - target.pos.z\n\treturn Math.max(Math.sqrt(dx * dx + dz * dz) - target.def.radius, 0)\n}\n\n/**\n * Distance between the edges of two entities\n *\n * @beta\n */\nexport function edgeDistance(a: Placed, b: Placed): number {\n\treturn Math.max(distanceToEdge(a.pos, b) - a.def.radius, 0)\n}\n"],"mappings":"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"}
|
package/dist/entityIndex.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Component } from './components';
|
|
2
2
|
import type { Entity, PlayerId } from './entity';
|
|
3
|
+
import type { World } from './world';
|
|
3
4
|
/**
|
|
4
5
|
* Entities filed by what they are asked for by: whose they are, which have a component (and, for a component that
|
|
5
6
|
* asks, whose they are too: `Component.index`). Answers questions like "the heroes of player 2"
|
|
@@ -14,8 +15,14 @@ import type { Entity, PlayerId } from './entity';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare class EntityIndex {
|
|
16
17
|
private readonly componentOf;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
private readonly worldOf;
|
|
19
|
+
/**
|
|
20
|
+
* `componentOf`: a component of the world's game by its id, an error for one it does not list (`registry.used`);
|
|
21
|
+
* `worldOf`: the world it is the index of, which its entities reach through it (`Entity.order`)
|
|
22
|
+
*/
|
|
23
|
+
constructor(componentOf: (id: string) => Component<unknown, unknown> | undefined, worldOf: () => World);
|
|
24
|
+
/** The world it is the index of */
|
|
25
|
+
world(): World;
|
|
19
26
|
private readonly owned;
|
|
20
27
|
private readonly components;
|
|
21
28
|
/** By component id, then by owner: for the components that ask (`index: 'owner'`) */
|
|
@@ -30,7 +37,7 @@ export declare class EntityIndex {
|
|
|
30
37
|
*/
|
|
31
38
|
with(key: Component<unknown, unknown>, owner?: PlayerId): ReadonlySet<Entity>;
|
|
32
39
|
/**
|
|
33
|
-
* Everything that has the component, in the order of the entities' ids: the order a walk through `World.
|
|
40
|
+
* Everything that has the component, in the order of the entities' ids: the order a walk through `World.units`
|
|
34
41
|
* meets them in. What a system that runs over a component goes through (`System.over`), so a game plays the same
|
|
35
42
|
* as one that looks at every actor. A list of its own, kept until what has the component changes: what is given it
|
|
36
43
|
* or loses it while the list is gone through is in the next one
|