@v12-engine/engine 0.1.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abilities/amounts.d.ts +28 -0
- package/dist/abilities/amounts.js +74 -0
- package/dist/abilities/amounts.js.map +1 -0
- package/dist/abilities/buffs.d.ts +106 -6
- package/dist/abilities/buffs.js +443 -0
- package/dist/abilities/buffs.js.map +1 -0
- package/dist/abilities/castTold.d.ts +2 -0
- package/dist/abilities/castTold.js +66 -0
- package/dist/abilities/castTold.js.map +1 -0
- package/dist/abilities/chance.d.ts +38 -0
- package/dist/abilities/chance.js +77 -0
- package/dist/abilities/chance.js.map +1 -0
- package/dist/abilities/charges.d.ts +18 -0
- package/dist/abilities/charges.js +101 -0
- package/dist/abilities/charges.js.map +1 -0
- package/dist/abilities/control.d.ts +28 -0
- package/dist/abilities/control.js +113 -0
- package/dist/abilities/control.js.map +1 -0
- package/dist/abilities/dispel.js +51 -0
- package/dist/abilities/dispel.js.map +1 -0
- package/dist/abilities/effectFields.d.ts +1 -1
- package/dist/abilities/effectFields.js +676 -0
- package/dist/abilities/effectFields.js.map +1 -0
- package/dist/abilities/effectIndex.d.ts +27 -0
- package/dist/abilities/effectIndex.js +64 -0
- package/dist/abilities/effectIndex.js.map +1 -0
- package/dist/abilities/effects/buff.d.ts +9 -3
- package/dist/abilities/effects/buff.js +84 -0
- package/dist/abilities/effects/buff.js.map +1 -0
- package/dist/abilities/effects/conditions.d.ts +2 -0
- package/dist/abilities/effects/conditions.js +41 -0
- package/dist/abilities/effects/conditions.js.map +1 -0
- package/dist/abilities/effects/core.js +54 -0
- package/dist/abilities/effects/core.js.map +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -1
- package/dist/abilities/effects/damage.js +43 -0
- package/dist/abilities/effects/damage.js.map +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -2
- package/dist/abilities/effects/heal.js +51 -0
- package/dist/abilities/effects/heal.js.map +1 -0
- package/dist/abilities/effects/missile.d.ts +13 -1
- package/dist/abilities/effects/missile.js +104 -0
- package/dist/abilities/effects/missile.js.map +1 -0
- package/dist/abilities/effects/morph.d.ts +5 -0
- package/dist/abilities/effects/morph.js +43 -0
- package/dist/abilities/effects/morph.js.map +1 -0
- package/dist/abilities/effects/moves.d.ts +16 -4
- package/dist/abilities/effects/moves.js +212 -0
- package/dist/abilities/effects/moves.js.map +1 -0
- package/dist/abilities/effects/passives.d.ts +19 -9
- package/dist/abilities/effects/passives.js +131 -0
- package/dist/abilities/effects/passives.js.map +1 -0
- package/dist/abilities/effects/proxy.d.ts +5 -0
- package/dist/abilities/effects/proxy.js +60 -0
- package/dist/abilities/effects/proxy.js.map +1 -0
- package/dist/abilities/effects/sight.d.ts +2 -2
- package/dist/abilities/effects/sight.js +39 -0
- package/dist/abilities/effects/sight.js.map +1 -0
- package/dist/abilities/effects/spawn.d.ts +5 -2
- package/dist/abilities/effects/spawn.js +40 -0
- package/dist/abilities/effects/spawn.js.map +1 -0
- package/dist/abilities/effects/timed.d.ts +2 -2
- package/dist/abilities/effects/timed.js +96 -0
- package/dist/abilities/effects/timed.js.map +1 -0
- package/dist/abilities/effects/trade.d.ts +1 -1
- package/dist/abilities/effects/trade.js +25 -0
- package/dist/abilities/effects/trade.js.map +1 -0
- package/dist/abilities/effects.d.ts +97 -23
- package/dist/abilities/effects.js +860 -0
- package/dist/abilities/effects.js.map +1 -0
- package/dist/abilities/land.d.ts +38 -4
- package/dist/abilities/land.js +189 -0
- package/dist/abilities/land.js.map +1 -0
- package/dist/abilities/recast.d.ts +45 -0
- package/dist/abilities/recast.js +118 -0
- package/dist/abilities/recast.js.map +1 -0
- package/dist/abilities/scaled.js +40 -0
- package/dist/abilities/scaled.js.map +1 -0
- package/dist/abilities/screen.d.ts +6 -0
- package/dist/abilities/screen.js +83 -0
- package/dist/abilities/screen.js.map +1 -0
- package/dist/abilities/shapes.d.ts +66 -0
- package/dist/abilities/shapes.js +122 -0
- package/dist/abilities/shapes.js.map +1 -0
- package/dist/abilities/text.d.ts +14 -2
- package/dist/abilities/text.js +204 -0
- package/dist/abilities/text.js.map +1 -0
- package/dist/abilities/triggers.d.ts +98 -0
- package/dist/abilities/triggers.js +351 -0
- package/dist/abilities/triggers.js.map +1 -0
- package/dist/abilityChanges.d.ts +131 -0
- package/dist/abilityChanges.js +345 -0
- package/dist/abilityChanges.js.map +1 -0
- package/dist/ai/area.d.ts +4 -1
- package/dist/ai/brain.d.ts +4 -1
- package/dist/ai/brain.js +844 -0
- package/dist/ai/brain.js.map +1 -0
- package/dist/ai/budget.js +74 -0
- package/dist/ai/budget.js.map +1 -0
- package/dist/ai/checks.d.ts +9 -1
- package/dist/ai/checks.js +242 -0
- package/dist/ai/checks.js.map +1 -0
- package/dist/ai/computer.d.ts +11 -4
- package/dist/ai/computer.js +251 -0
- package/dist/ai/computer.js.map +1 -0
- package/dist/ai/defence.d.ts +4 -0
- package/dist/ai/defence.js +430 -0
- package/dist/ai/defence.js.map +1 -0
- package/dist/ai/define.d.ts +3 -2
- package/dist/ai/define.js +31 -0
- package/dist/ai/define.js.map +1 -0
- package/dist/ai/economy.d.ts +10 -7
- package/dist/ai/economy.js +780 -0
- package/dist/ai/economy.js.map +1 -0
- package/dist/ai/geometry.js +38 -0
- package/dist/ai/geometry.js.map +1 -0
- package/dist/ai/goals.d.ts +1 -0
- package/dist/ai/goals.js +560 -0
- package/dist/ai/goals.js.map +1 -0
- package/dist/ai/knowledge.d.ts +72 -7
- package/dist/ai/knowledge.js +804 -0
- package/dist/ai/knowledge.js.map +1 -0
- package/dist/ai/lanes.d.ts +10 -2
- package/dist/ai/lanes.js +715 -0
- package/dist/ai/lanes.js.map +1 -0
- package/dist/ai/melee/build.js +264 -0
- package/dist/ai/melee/build.js.map +1 -0
- package/dist/ai/melee/goals.d.ts +7 -0
- package/dist/ai/melee/goals.js +720 -0
- package/dist/ai/melee/goals.js.map +1 -0
- package/dist/ai/melee/heroes.js +68 -0
- package/dist/ai/melee/heroes.js.map +1 -0
- package/dist/ai/melee/index.d.ts +1 -1
- package/dist/ai/melee/index.js +51 -0
- package/dist/ai/melee/index.js.map +1 -0
- package/dist/ai/melee/production.js +29 -0
- package/dist/ai/melee/production.js.map +1 -0
- package/dist/ai/melee/surrender.js +64 -0
- package/dist/ai/melee/surrender.js.map +1 -0
- package/dist/ai/micro.d.ts +9 -0
- package/dist/ai/micro.js +1316 -0
- package/dist/ai/micro.js.map +1 -0
- package/dist/ai/mission.d.ts +9 -2
- package/dist/ai/mission.js +538 -0
- package/dist/ai/mission.js.map +1 -0
- package/dist/ai/missionRules.d.ts +1 -1
- package/dist/ai/missionRules.js +26 -0
- package/dist/ai/missionRules.js.map +1 -0
- package/dist/ai/module.d.ts +6 -2
- package/dist/ai/module.js +37 -0
- package/dist/ai/module.js.map +1 -0
- package/dist/ai/options.d.ts +3 -3
- package/dist/ai/plans/build.d.ts +20 -1
- package/dist/ai/plans/build.js +608 -0
- package/dist/ai/plans/build.js.map +1 -0
- package/dist/ai/plans/placement.d.ts +4 -1
- package/dist/ai/plans/placement.js +295 -0
- package/dist/ai/plans/placement.js.map +1 -0
- package/dist/ai/plans/plans.d.ts +9 -0
- package/dist/ai/plans/plans.js +110 -0
- package/dist/ai/plans/plans.js.map +1 -0
- package/dist/ai/plans/production.d.ts +14 -2
- package/dist/ai/plans/production.js +434 -0
- package/dist/ai/plans/production.js.map +1 -0
- package/dist/ai/plans/purse.d.ts +6 -3
- package/dist/ai/plans/purse.js +139 -0
- package/dist/ai/plans/purse.js.map +1 -0
- package/dist/ai/plans/tech.d.ts +6 -0
- package/dist/ai/plans/tech.js +122 -0
- package/dist/ai/plans/tech.js.map +1 -0
- package/dist/ai/profiles.d.ts +4 -4
- package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
- package/dist/ai/profiles.js.map +1 -0
- package/dist/ai/reach.js +54 -0
- package/dist/ai/reach.js.map +1 -0
- package/dist/ai/report.d.ts +8 -0
- package/dist/ai/report.js +87 -0
- package/dist/ai/report.js.map +1 -0
- package/dist/ai/roles.d.ts +4 -0
- package/dist/ai/roles.js +207 -0
- package/dist/ai/roles.js.map +1 -0
- package/dist/ai/rules.d.ts +8 -2
- package/dist/ai/rules.js +416 -0
- package/dist/ai/rules.js.map +1 -0
- package/dist/ai/scouting.d.ts +6 -0
- package/dist/ai/scouting.js +324 -0
- package/dist/ai/scouting.js.map +1 -0
- package/dist/ai/settings.js +99 -0
- package/dist/ai/settings.js.map +1 -0
- package/dist/ai/squads.d.ts +21 -2
- package/dist/ai/squads.js +916 -0
- package/dist/ai/squads.js.map +1 -0
- package/dist/ai/strength.js +320 -0
- package/dist/ai/strength.js.map +1 -0
- package/dist/ai/task.d.ts +3 -1
- package/dist/ai/task.js +17 -0
- package/dist/ai/task.js.map +1 -0
- package/dist/ai/tasks/attack.js +24 -0
- package/dist/ai/tasks/attack.js.map +1 -0
- package/dist/ai/tasks/capture.d.ts +3 -3
- package/dist/ai/tasks/capture.js +37 -0
- package/dist/ai/tasks/capture.js.map +1 -0
- package/dist/ai/tasks/creep.js +29 -0
- package/dist/ai/tasks/creep.js.map +1 -0
- package/dist/ai/tasks/defend.js +61 -0
- package/dist/ai/tasks/defend.js.map +1 -0
- package/dist/ai/tasks/drop.js +81 -0
- package/dist/ai/tasks/drop.js.map +1 -0
- package/dist/ai/tasks/escort.js +59 -0
- package/dist/ai/tasks/escort.js.map +1 -0
- package/dist/ai/tasks/gather.js +48 -0
- package/dist/ai/tasks/gather.js.map +1 -0
- package/dist/ai/tasks/harass.js +39 -0
- package/dist/ai/tasks/harass.js.map +1 -0
- package/dist/ai/tasks/hold.js +32 -0
- package/dist/ai/tasks/hold.js.map +1 -0
- package/dist/ai/tasks/index.js +34 -0
- package/dist/ai/tasks/index.js.map +1 -0
- package/dist/ai/tasks/move.js +26 -0
- package/dist/ai/tasks/move.js.map +1 -0
- package/dist/ai/tasks/patrol.js +59 -0
- package/dist/ai/tasks/patrol.js.map +1 -0
- package/dist/ai/tasks/retreat.js +28 -0
- package/dist/ai/tasks/retreat.js.map +1 -0
- package/dist/ai/tasks/scout.js +73 -0
- package/dist/ai/tasks/scout.js.map +1 -0
- package/dist/ai/tasks/shared.d.ts +1 -1
- package/dist/ai/tasks/shared.js +137 -0
- package/dist/ai/tasks/shared.js.map +1 -0
- package/dist/ai/team.d.ts +18 -1
- package/dist/ai/team.js +492 -0
- package/dist/ai/team.js.map +1 -0
- package/dist/ai/threat.d.ts +6 -0
- package/dist/ai/threat.js +206 -0
- package/dist/ai/threat.js.map +1 -0
- package/dist/ai/view.d.ts +21 -7
- package/dist/ai/view.js +677 -0
- package/dist/ai/view.js.map +1 -0
- package/dist/ai/waves.d.ts +6 -0
- package/dist/ai/waves.js +410 -0
- package/dist/ai/waves.js.map +1 -0
- package/dist/ai.js +54 -6239
- package/dist/aiTesting.d.ts +6 -3
- package/dist/aiTesting.js +229 -0
- package/dist/aiTesting.js.map +1 -0
- package/dist/areas.d.ts +4 -1
- package/dist/areas.js +295 -0
- package/dist/areas.js.map +1 -0
- package/dist/attacks.d.ts +3 -3
- package/dist/attacks.js +127 -0
- package/dist/attacks.js.map +1 -0
- package/dist/burning.d.ts +267 -0
- package/dist/burning.js +795 -0
- package/dist/burning.js.map +1 -0
- package/dist/bytes.js +21 -0
- package/dist/bytes.js.map +1 -0
- package/dist/callings.d.ts +71 -0
- package/dist/callings.js +157 -0
- package/dist/callings.js.map +1 -0
- package/dist/cameraOrders.d.ts +78 -0
- package/dist/cameraOrders.js +114 -0
- package/dist/cameraOrders.js.map +1 -0
- package/dist/camps.d.ts +70 -4
- package/dist/camps.js +501 -0
- package/dist/camps.js.map +1 -0
- package/dist/capture.d.ts +15 -3
- package/dist/capture.js +304 -0
- package/dist/capture.js.map +1 -0
- package/dist/cellLayers.d.ts +78 -13
- package/dist/cellLayers.js +275 -0
- package/dist/cellLayers.js.map +1 -0
- package/dist/cellPatches.d.ts +24 -0
- package/dist/cellPatches.js +73 -0
- package/dist/cellPatches.js.map +1 -0
- package/dist/cinematics.d.ts +10 -5
- package/dist/cinematics.js +161 -0
- package/dist/cinematics.js.map +1 -0
- package/dist/clock.d.ts +2 -2
- package/dist/clock.js +78 -0
- package/dist/clock.js.map +1 -0
- package/dist/commands.d.ts +36 -4
- package/dist/commands.js +636 -0
- package/dist/commands.js.map +1 -0
- package/dist/components.d.ts +31 -10
- package/dist/components.js +74 -0
- package/dist/components.js.map +1 -0
- package/dist/computers.d.ts +4 -4
- package/dist/computers.js +194 -0
- package/dist/computers.js.map +1 -0
- package/dist/concealment.d.ts +25 -2
- package/dist/concealment.js +409 -0
- package/dist/concealment.js.map +1 -0
- package/dist/coreComponents.js +130 -0
- package/dist/coreComponents.js.map +1 -0
- package/dist/createGame.d.ts +306 -0
- package/dist/createGame.js +405 -0
- package/dist/createGame.js.map +1 -0
- package/dist/dashing.d.ts +18 -2
- package/dist/dashing.js +41 -0
- package/dist/dashing.js.map +1 -0
- package/dist/debug.d.ts +8 -0
- package/dist/debug.js +5 -3
- package/dist/debug2.js +76 -0
- package/dist/debug2.js.map +1 -0
- package/dist/debugCommands.d.ts +6 -6
- package/dist/debugCommands.js +537 -0
- package/dist/debugCommands.js.map +1 -0
- package/dist/debugging.d.ts +1 -0
- package/dist/defaultSets.d.ts +183 -0
- package/dist/defaultSets.js +216 -0
- package/dist/defaultSets.js.map +1 -0
- package/dist/definitions.d.ts +6 -0
- package/dist/definitions.js +78 -0
- package/dist/definitions.js.map +1 -0
- package/dist/defs.d.ts +1895 -165
- package/dist/defs.js +380 -0
- package/dist/defs.js.map +1 -0
- package/dist/denying.d.ts +4 -4
- package/dist/denying.js +106 -0
- package/dist/denying.js.map +1 -0
- package/dist/destructibles.d.ts +2 -2
- package/dist/destructibles.js +36 -0
- package/dist/destructibles.js.map +1 -0
- package/dist/determinism.d.ts +4 -4
- package/dist/determinism.js +247 -0
- package/dist/determinism.js.map +1 -0
- package/dist/dialog.d.ts +17 -2
- package/dist/dialog.js +108 -0
- package/dist/dialog.js.map +1 -0
- package/dist/effectRefs.js +28 -0
- package/dist/effectRefs.js.map +1 -0
- package/dist/effects.d.ts +27 -11
- package/dist/effects.js +110 -0
- package/dist/effects.js.map +1 -0
- package/dist/endings.d.ts +1 -1
- package/dist/endings.js +78 -0
- package/dist/endings.js.map +1 -0
- package/dist/engagement.d.ts +40 -6
- package/dist/engagement.js +530 -0
- package/dist/engagement.js.map +1 -0
- package/dist/engineEvents.d.ts +72 -9
- package/dist/engineEvents.js +520 -0
- package/dist/engineEvents.js.map +1 -0
- package/dist/entity.d.ts +275 -26
- package/dist/entity.js +441 -0
- package/dist/entity.js.map +1 -0
- package/dist/entityIndex.d.ts +10 -3
- package/dist/entityIndex.js +149 -0
- package/dist/entityIndex.js.map +1 -0
- package/dist/errors.d.ts +6 -2
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +11 -5
- package/dist/events.js +158 -0
- package/dist/events.js.map +1 -0
- package/dist/exactMath.js +273 -0
- package/dist/exactMath.js.map +1 -0
- package/dist/features.d.ts +1 -1
- package/dist/features.js +127 -0
- package/dist/features.js.map +1 -0
- package/dist/fields.d.ts +25 -5
- package/dist/fields.js +140 -0
- package/dist/fields.js.map +1 -0
- package/dist/fixture.d.ts +3 -3
- package/dist/fixture.js +512 -0
- package/dist/fixture.js.map +1 -0
- package/dist/fog.d.ts +26 -3
- package/dist/fog.js +333 -0
- package/dist/fog.js.map +1 -0
- package/dist/foliage.d.ts +476 -0
- package/dist/foliage.js +1478 -0
- package/dist/foliage.js.map +1 -0
- package/dist/foliageDebug.d.ts +57 -0
- package/dist/foliageDebug.js +172 -0
- package/dist/foliageDebug.js.map +1 -0
- package/dist/foliageRegrowth.d.ts +20 -0
- package/dist/foliageRegrowth.js +332 -0
- package/dist/foliageRegrowth.js.map +1 -0
- package/dist/formState.d.ts +67 -0
- package/dist/formState.js +65 -0
- package/dist/formState.js.map +1 -0
- package/dist/formation.d.ts +46 -8
- package/dist/formation.js +297 -0
- package/dist/formation.js.map +1 -0
- package/dist/forms.d.ts +58 -0
- package/dist/forms.js +146 -0
- package/dist/forms.js.map +1 -0
- package/dist/friendlyFire.d.ts +2 -2
- package/dist/friendlyFire.js +37 -0
- package/dist/friendlyFire.js.map +1 -0
- package/dist/game.d.ts +141 -48
- package/dist/game.js +834 -0
- package/dist/game.js.map +1 -0
- package/dist/gameData.d.ts +96 -22
- package/dist/gameData.js +1690 -0
- package/dist/gameData.js.map +1 -0
- package/dist/gameFiles.d.ts +3 -3
- package/dist/gameFiles.js +14 -0
- package/dist/gameFiles.js.map +1 -0
- package/dist/gates.js +92 -0
- package/dist/gates.js.map +1 -0
- package/dist/generate.d.ts +28 -1
- package/dist/generate.js +1062 -0
- package/dist/generate.js.map +1 -0
- package/dist/generateWorker.d.ts +7 -3
- package/dist/generateWorker.js +86 -0
- package/dist/generateWorker.js.map +1 -0
- package/dist/grid.d.ts +9 -0
- package/dist/grid.js +102 -0
- package/dist/grid.js.map +1 -0
- package/dist/ground.d.ts +17 -1
- package/dist/ground.js +375 -0
- package/dist/ground.js.map +1 -0
- package/dist/groundObjects.d.ts +70 -0
- package/dist/groundObjects.js +371 -0
- package/dist/groundObjects.js.map +1 -0
- package/dist/groundSpeed.d.ts +20 -3
- package/dist/groundSpeed.js +117 -0
- package/dist/groundSpeed.js.map +1 -0
- package/dist/hero.d.ts +126 -10
- package/dist/hero.js +432 -0
- package/dist/hero.js.map +1 -0
- package/dist/holds.d.ts +94 -0
- package/dist/holds.js +305 -0
- package/dist/holds.js.map +1 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.js +30 -0
- package/dist/home.js.map +1 -0
- package/dist/hooks.d.ts +339 -57
- package/dist/hooks.js +105 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hotReload.d.ts +6 -5
- package/dist/hotReload.js +145 -0
- package/dist/hotReload.js.map +1 -0
- package/dist/ids.d.ts +3 -3
- package/dist/ids.js +30 -0
- package/dist/ids.js.map +1 -0
- package/dist/idsFile.d.ts +36 -0
- package/dist/idsFile.js +134 -0
- package/dist/idsFile.js.map +1 -0
- package/dist/index.d.ts +105 -68
- package/dist/index.js +194 -4701
- package/dist/inspect.d.ts +29 -2
- package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
- package/dist/inspect.js.map +1 -0
- package/dist/inventory.d.ts +14 -1
- package/dist/inventory.js +84 -0
- package/dist/inventory.js.map +1 -0
- package/dist/items.d.ts +136 -8
- package/dist/items.js +585 -0
- package/dist/items.js.map +1 -0
- package/dist/lanes.d.ts +12 -3
- package/dist/lanes.js +496 -0
- package/dist/lanes.js.map +1 -0
- package/dist/life.d.ts +6 -2
- package/dist/life.js +287 -0
- package/dist/life.js.map +1 -0
- package/dist/log.d.ts +26 -3
- package/dist/log.js +192 -0
- package/dist/log.js.map +1 -0
- package/dist/manaBurn.d.ts +2 -2
- package/dist/manaBurn.js +75 -0
- package/dist/manaBurn.js.map +1 -0
- package/dist/map/file.d.ts +56 -3
- package/dist/map/file.js +264 -0
- package/dist/map/file.js.map +1 -0
- package/dist/map/images.js +61 -0
- package/dist/map/images.js.map +1 -0
- package/dist/map/look.d.ts +1 -1
- package/dist/map/look.js +30 -0
- package/dist/map/look.js.map +1 -0
- package/dist/map/pathProfile.js +183 -0
- package/dist/map/pathProfile.js.map +1 -0
- package/dist/map/resize.d.ts +4 -0
- package/dist/map/resize.js +136 -0
- package/dist/map/resize.js.map +1 -0
- package/dist/map/schema.js +257 -0
- package/dist/map/schema.js.map +1 -0
- package/dist/map/terrain.js +214 -0
- package/dist/map/terrain.js.map +1 -0
- package/dist/map/types.d.ts +92 -13
- package/dist/map/types.js +251 -0
- package/dist/map/types.js.map +1 -0
- package/dist/mapCheck/cells.js +94 -0
- package/dist/mapCheck/cells.js.map +1 -0
- package/dist/mapCheck/rules/foliage.d.ts +9 -0
- package/dist/mapCheck/rules/foliage.js +83 -0
- package/dist/mapCheck/rules/foliage.js.map +1 -0
- package/dist/mapCheck/rules/names.js +39 -0
- package/dist/mapCheck/rules/names.js.map +1 -0
- package/dist/mapCheck/rules/objects.d.ts +1 -1
- package/dist/mapCheck/rules/objects.js +56 -0
- package/dist/mapCheck/rules/objects.js.map +1 -0
- package/dist/mapCheck/rules/paths.js +32 -0
- package/dist/mapCheck/rules/paths.js.map +1 -0
- package/dist/mapCheck/rules/players.js +20 -0
- package/dist/mapCheck/rules/players.js.map +1 -0
- package/dist/mapCheck/rules/races.js +56 -0
- package/dist/mapCheck/rules/races.js.map +1 -0
- package/dist/mapCheck/rules/random.js +47 -0
- package/dist/mapCheck/rules/random.js.map +1 -0
- package/dist/mapCheck/rules/regions.js +30 -0
- package/dist/mapCheck/rules/regions.js.map +1 -0
- package/dist/mapCheck/rules/targets.js +31 -0
- package/dist/mapCheck/rules/targets.js.map +1 -0
- package/dist/mapCheck/rules/walking.js +45 -0
- package/dist/mapCheck/rules/walking.js.map +1 -0
- package/dist/mapCheck.d.ts +2 -2
- package/dist/mapCheck.js +63 -0
- package/dist/mapCheck.js.map +1 -0
- package/dist/mapFields.d.ts +25 -2
- package/dist/mapFields.js +134 -0
- package/dist/mapFields.js.map +1 -0
- package/dist/mapFile.js +176 -0
- package/dist/mapFile.js.map +1 -0
- package/dist/mapMeasure.d.ts +8 -0
- package/dist/mapMeasure.js +283 -0
- package/dist/mapMeasure.js.map +1 -0
- package/dist/mapMerge.d.ts +1 -0
- package/dist/mapMerge.js +172 -0
- package/dist/mapMerge.js.map +1 -0
- package/dist/mapObjectives.js +138 -0
- package/dist/mapObjectives.js.map +1 -0
- package/dist/mapObjects.js +80 -0
- package/dist/mapObjects.js.map +1 -0
- package/dist/math.d.ts +37 -7
- package/dist/math.js +155 -0
- package/dist/math.js.map +1 -0
- package/dist/messages.d.ts +71 -4
- package/dist/messages.js +29 -0
- package/dist/messages.js.map +1 -0
- package/dist/missionRules.d.ts +10 -2
- package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
- package/dist/missionRules.js.map +1 -0
- package/dist/mods.d.ts +39 -20
- package/dist/mods.js +271 -0
- package/dist/mods.js.map +1 -0
- package/dist/moves.d.ts +87 -0
- package/dist/moves.js +539 -0
- package/dist/moves.js.map +1 -0
- package/dist/names.d.ts +7 -0
- package/dist/names.js +122 -0
- package/dist/names.js.map +1 -0
- package/dist/navigation/agentParams.js +14 -0
- package/dist/navigation/agentParams.js.map +1 -0
- package/dist/navigation/air.d.ts +7 -3
- package/dist/navigation/air.js +401 -0
- package/dist/navigation/air.js.map +1 -0
- package/dist/navigation/builds.d.ts +34 -2
- package/dist/navigation/builds.js +287 -0
- package/dist/navigation/builds.js.map +1 -0
- package/dist/navigation/groundAreas.d.ts +59 -1
- package/dist/navigation/groundAreas.js +407 -0
- package/dist/navigation/groundAreas.js.map +1 -0
- package/dist/navigation/navigation.d.ts +98 -9
- package/dist/navigation/recast.d.ts +194 -18
- package/dist/navigation/recast.js +1379 -0
- package/dist/navigation/recast.js.map +1 -0
- package/dist/navigation/sidePaths.d.ts +8 -3
- package/dist/navigation/sidePaths.js +241 -0
- package/dist/navigation/sidePaths.js.map +1 -0
- package/dist/navigation/sized.js +243 -0
- package/dist/navigation/sized.js.map +1 -0
- package/dist/nearest.js +32 -0
- package/dist/nearest.js.map +1 -0
- package/dist/noise.js +59 -0
- package/dist/noise.js.map +1 -0
- package/dist/objectives.d.ts +12 -3
- package/dist/objectives.js +144 -0
- package/dist/objectives.js.map +1 -0
- package/dist/orders/basic.d.ts +5 -5
- package/dist/orders/basic.js +417 -0
- package/dist/orders/basic.js.map +1 -0
- package/dist/orders/build.js +278 -0
- package/dist/orders/build.js.map +1 -0
- package/dist/orders/cast.d.ts +13 -3
- package/dist/orders/cast.js +558 -0
- package/dist/orders/cast.js.map +1 -0
- package/dist/orders/facts.js +16 -0
- package/dist/orders/facts.js.map +1 -0
- package/dist/orders/harvest.d.ts +21 -5
- package/dist/orders/harvest.js +540 -0
- package/dist/orders/harvest.js.map +1 -0
- package/dist/orders/idle.d.ts +3 -1
- package/dist/orders/idle.js +234 -0
- package/dist/orders/idle.js.map +1 -0
- package/dist/orders/items.js +92 -0
- package/dist/orders/items.js.map +1 -0
- package/dist/orders/queue.js +108 -0
- package/dist/orders/queue.js.map +1 -0
- package/dist/orders/waiting.d.ts +39 -0
- package/dist/orders/waiting.js +149 -0
- package/dist/orders/waiting.js.map +1 -0
- package/dist/pack.schema.js +13 -0
- package/dist/pack.schema.js.map +1 -0
- package/dist/pack.schema.json +7622 -841
- package/dist/packs/director/index.d.ts +13 -5
- package/dist/packs/director/index.js +204 -0
- package/dist/packs/director/index.js.map +1 -0
- package/dist/packs/heroes/campaign.d.ts +3 -2
- package/dist/packs/heroes/campaign.js +241 -0
- package/dist/packs/heroes/campaign.js.map +1 -0
- package/dist/packs/heroes/carry.d.ts +6 -0
- package/dist/packs/heroes/carry.js +112 -0
- package/dist/packs/heroes/carry.js.map +1 -0
- package/dist/packs/heroes/commands.js +115 -0
- package/dist/packs/heroes/commands.js.map +1 -0
- package/dist/packs/heroes/fallen.d.ts +43 -0
- package/dist/packs/heroes/fallen.js +61 -0
- package/dist/packs/heroes/fallen.js.map +1 -0
- package/dist/packs/heroes/hire.js +60 -0
- package/dist/packs/heroes/hire.js.map +1 -0
- package/dist/packs/heroes/index.d.ts +7 -6
- package/dist/packs/heroes/index.js +130 -0
- package/dist/packs/heroes/index.js.map +1 -0
- package/dist/packs/heroes/loop.d.ts +95 -0
- package/dist/packs/heroes/loop.js +250 -0
- package/dist/packs/heroes/loop.js.map +1 -0
- package/dist/packs/heroes/making.d.ts +6 -3
- package/dist/packs/heroes/making.js +55 -0
- package/dist/packs/heroes/making.js.map +1 -0
- package/dist/packs/heroes/respawn.d.ts +3 -3
- package/dist/packs/heroes/respawn.js +87 -0
- package/dist/packs/heroes/respawn.js.map +1 -0
- package/dist/packs/heroes/sets.d.ts +32 -0
- package/dist/packs/heroes/sets.js +51 -0
- package/dist/packs/heroes/sets.js.map +1 -0
- package/dist/packs/heroes/spells.d.ts +16 -0
- package/dist/packs/heroes/spells.js +269 -0
- package/dist/packs/heroes/spells.js.map +1 -0
- package/dist/packs/items/defaults.d.ts +43 -0
- package/dist/packs/items/defaults.js +1504 -0
- package/dist/packs/items/defaults.js.map +1 -0
- package/dist/packs/items/index.d.ts +27 -0
- package/dist/packs/items/index.js +214 -0
- package/dist/packs/items/index.js.map +1 -0
- package/dist/packs/moba/index.d.ts +3 -3
- package/dist/packs/moba/index.js +174 -0
- package/dist/packs/moba/index.js.map +1 -0
- package/dist/packs/pack.d.ts +15 -15
- package/dist/packs/pack.js +14 -0
- package/dist/packs/pack.js.map +1 -0
- package/dist/packs.d.ts +15 -7
- package/dist/packs.js +222 -0
- package/dist/packs.js.map +1 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +109 -0
- package/dist/paths.js.map +1 -0
- package/dist/plain.js +57 -0
- package/dist/plain.js.map +1 -0
- package/dist/player.d.ts +33 -10
- package/dist/player.js +159 -0
- package/dist/player.js.map +1 -0
- package/dist/portals.d.ts +1 -1
- package/dist/portals.js +194 -0
- package/dist/portals.js.map +1 -0
- package/dist/prefabs.d.ts +25 -2
- package/dist/prefabs.js +239 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/presetBuildings.js +58 -0
- package/dist/presetBuildings.js.map +1 -0
- package/dist/presetFoliage.d.ts +27 -0
- package/dist/presetFoliage.js +98 -0
- package/dist/presetFoliage.js.map +1 -0
- package/dist/presetGround.js +65 -0
- package/dist/presetGround.js.map +1 -0
- package/dist/proxies.d.ts +12 -0
- package/dist/proxies.js +79 -0
- package/dist/proxies.js.map +1 -0
- package/dist/query.d.ts +56 -0
- package/dist/query.js +88 -0
- package/dist/query.js.map +1 -0
- package/dist/races.d.ts +15 -14
- package/dist/races.js +172 -0
- package/dist/races.js.map +1 -0
- package/dist/randomGroups.js +91 -0
- package/dist/randomGroups.js.map +1 -0
- package/dist/registry.d.ts +117 -53
- package/dist/registry.js +323 -0
- package/dist/registry.js.map +1 -0
- package/dist/remains.d.ts +11 -9
- package/dist/remains.js +188 -0
- package/dist/remains.js.map +1 -0
- package/dist/replication.d.ts +12 -7
- package/dist/replication.js +100 -0
- package/dist/replication.js.map +1 -0
- package/dist/rng.d.ts +2 -0
- package/dist/rng.js +40 -0
- package/dist/rng.js.map +1 -0
- package/dist/rules.d.ts +186 -99
- package/dist/rules.js +179 -0
- package/dist/rules.js.map +1 -0
- package/dist/rulesCheck.d.ts +5 -4
- package/dist/rulesCheck.js +693 -0
- package/dist/rulesCheck.js.map +1 -0
- package/dist/runes.d.ts +2 -2
- package/dist/runes.js +80 -0
- package/dist/runes.js.map +1 -0
- package/dist/save.d.ts +37 -12
- package/dist/save.js +532 -0
- package/dist/save.js.map +1 -0
- package/dist/scenario.d.ts +2 -2
- package/dist/scenario.js +99 -0
- package/dist/scenario.js.map +1 -0
- package/dist/scheduler.d.ts +3 -0
- package/dist/scheduler.js +156 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/score.d.ts +19 -19
- package/dist/score.js +709 -0
- package/dist/score.js.map +1 -0
- package/dist/sequences.d.ts +10 -6
- package/dist/sequences.js +206 -0
- package/dist/sequences.js.map +1 -0
- package/dist/server/doorman.js +154 -0
- package/dist/server/doorman.js.map +1 -0
- package/dist/server/gameServer.d.ts +16 -1
- package/dist/server/gameServer.js +643 -0
- package/dist/server/gameServer.js.map +1 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/lobby.js +199 -0
- package/dist/server/lobby.js.map +1 -0
- package/dist/server/log.js +18 -0
- package/dist/server/log.js.map +1 -0
- package/dist/server/match.js +267 -0
- package/dist/server/match.js.map +1 -0
- package/dist/server/mode.d.ts +18 -9
- package/dist/server/mode.js +220 -0
- package/dist/server/mode.js.map +1 -0
- package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
- package/dist/server/navigation-worker.js.map +1 -0
- package/dist/server/navigation.js +39 -0
- package/dist/server/navigation.js.map +1 -0
- package/dist/server/ops.d.ts +4 -0
- package/dist/server/ops.js +137 -0
- package/dist/server/ops.js.map +1 -0
- package/dist/server/packs.d.ts +3 -3
- package/dist/server/packs.js +32 -0
- package/dist/server/packs.js.map +1 -0
- package/dist/server/ratings.d.ts +5 -0
- package/dist/server/ratings.js +104 -0
- package/dist/server/ratings.js.map +1 -0
- package/dist/server/relay.d.ts +12 -2
- package/dist/server/relay.js +144 -0
- package/dist/server/relay.js.map +1 -0
- package/dist/server/rooms.d.ts +9 -2
- package/dist/server/rooms.js +442 -0
- package/dist/server/rooms.js.map +1 -0
- package/dist/server/seat.js +116 -0
- package/dist/server/seat.js.map +1 -0
- package/dist/server/seatSettings.d.ts +3 -3
- package/dist/server/seatSettings.js +63 -0
- package/dist/server/seatSettings.js.map +1 -0
- package/dist/server/secret.js +13 -0
- package/dist/server/secret.js.map +1 -0
- package/dist/server/start.d.ts +13 -6
- package/dist/server/start.js +76 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/websocket.d.ts +9 -1
- package/dist/server/websocket.js +306 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server.js +15 -2861
- package/dist/session/can.js +26 -0
- package/dist/session/can.js.map +1 -0
- package/dist/session/commandReplay.d.ts +8 -2
- package/dist/session/commandReplay.js +293 -0
- package/dist/session/commandReplay.js.map +1 -0
- package/dist/session/debug.js +151 -0
- package/dist/session/debug.js.map +1 -0
- package/dist/session/delay.js +62 -0
- package/dist/session/delay.js.map +1 -0
- package/dist/session/delta.d.ts +14 -1
- package/dist/session/delta.js +407 -0
- package/dist/session/delta.js.map +1 -0
- package/dist/session/entityState.js +415 -0
- package/dist/session/entityState.js.map +1 -0
- package/dist/session/local.d.ts +47 -5
- package/dist/session/local.js +670 -0
- package/dist/session/local.js.map +1 -0
- package/dist/session/memory.d.ts +20 -2
- package/dist/session/memory.js +131 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/protocol.d.ts +325 -31
- package/dist/session/protocol.js +55 -0
- package/dist/session/protocol.js.map +1 -0
- package/dist/session/remote.d.ts +74 -12
- package/dist/session/remote.js +1394 -0
- package/dist/session/remote.js.map +1 -0
- package/dist/session/replay.d.ts +11 -2
- package/dist/session/replay.js +160 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/seed.js +12 -0
- package/dist/session/seed.js.map +1 -0
- package/dist/session/share.d.ts +5 -1
- package/dist/session/share.js +94 -0
- package/dist/session/share.js.map +1 -0
- package/dist/session/socket.d.ts +1 -1
- package/dist/session/socket.js +29 -0
- package/dist/session/socket.js.map +1 -0
- package/dist/session/wire.d.ts +5 -0
- package/dist/session/wire.js +84 -0
- package/dist/session/wire.js.map +1 -0
- package/dist/session/worker.d.ts +77 -12
- package/dist/session/worker.js +499 -0
- package/dist/session/worker.js.map +1 -0
- package/dist/shared.d.ts +31 -5
- package/dist/shared.js +166 -0
- package/dist/shared.js.map +1 -0
- package/dist/sides.d.ts +9 -3
- package/dist/sides.js +149 -0
- package/dist/sides.js.map +1 -0
- package/dist/sight.js +85 -0
- package/dist/sight.js.map +1 -0
- package/dist/simulate-worker.js +1 -1
- package/dist/simulate.d.ts +12 -8
- package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
- package/dist/simulate.js.map +1 -0
- package/dist/smart.js +77 -0
- package/dist/smart.js.map +1 -0
- package/dist/spatial.d.ts +32 -16
- package/dist/spatial.js +234 -0
- package/dist/spatial.js.map +1 -0
- package/dist/spawning.d.ts +1 -0
- package/dist/spawning.js +224 -0
- package/dist/spawning.js.map +1 -0
- package/dist/stances.d.ts +6 -3
- package/dist/stances.js +169 -0
- package/dist/stances.js.map +1 -0
- package/dist/start.d.ts +10 -10
- package/dist/start.js +75 -0
- package/dist/start.js.map +1 -0
- package/dist/stats.d.ts +42 -16
- package/dist/stats.js +290 -0
- package/dist/stats.js.map +1 -0
- package/dist/summoned.d.ts +52 -0
- package/dist/summoned.js +38 -0
- package/dist/summoned.js.map +1 -0
- package/dist/summons.d.ts +10 -13
- package/dist/summons.js +271 -0
- package/dist/summons.js.map +1 -0
- package/dist/systems/abilities.js +224 -0
- package/dist/systems/abilities.js.map +1 -0
- package/dist/systems/combat.d.ts +35 -1
- package/dist/systems/combat.js +677 -0
- package/dist/systems/combat.js.map +1 -0
- package/dist/systems/combatTold.d.ts +3 -1
- package/dist/systems/combatTold.js +85 -0
- package/dist/systems/combatTold.js.map +1 -0
- package/dist/systems/construction.js +80 -0
- package/dist/systems/construction.js.map +1 -0
- package/dist/systems/economy.d.ts +0 -6
- package/dist/systems/economy.js +128 -0
- package/dist/systems/economy.js.map +1 -0
- package/dist/systems/fog.d.ts +1 -1
- package/dist/systems/fog.js +120 -0
- package/dist/systems/fog.js.map +1 -0
- package/dist/systems/life.js +32 -0
- package/dist/systems/life.js.map +1 -0
- package/dist/systems/movement.d.ts +24 -12
- package/dist/systems/movement.js +1247 -0
- package/dist/systems/movement.js.map +1 -0
- package/dist/systems/orders.js +64 -0
- package/dist/systems/orders.js.map +1 -0
- package/dist/systems/production.js +322 -0
- package/dist/systems/production.js.map +1 -0
- package/dist/systems/productionQueue.js +120 -0
- package/dist/systems/productionQueue.js.map +1 -0
- package/dist/systems/victory.d.ts +1 -1
- package/dist/systems/victory.js +56 -0
- package/dist/systems/victory.js.map +1 -0
- package/dist/talk.d.ts +6 -6
- package/dist/talk.js +153 -0
- package/dist/talk.js.map +1 -0
- package/dist/targeting.d.ts +142 -0
- package/dist/targeting.js +49 -0
- package/dist/targeting.js.map +1 -0
- package/dist/tech.d.ts +20 -3
- package/dist/tech.js +239 -0
- package/dist/tech.js.map +1 -0
- package/dist/techTree.d.ts +7 -0
- package/dist/techTree.js +90 -0
- package/dist/techTree.js.map +1 -0
- package/dist/terrain.d.ts +59 -7
- package/dist/terrain.js +389 -0
- package/dist/terrain.js.map +1 -0
- package/dist/terrainSave.d.ts +6 -0
- package/dist/terrainSave.js +74 -0
- package/dist/terrainSave.js.map +1 -0
- package/dist/testing.d.ts +8 -7
- package/dist/testing.js +13 -739
- package/dist/testing.js.map +1 -1
- package/dist/tiles.d.ts +1 -1
- package/dist/tiles.js +43 -0
- package/dist/tiles.js.map +1 -0
- package/dist/timers.d.ts +29 -4
- package/dist/timers.js +242 -0
- package/dist/timers.js.map +1 -0
- package/dist/tomes.d.ts +4 -4
- package/dist/tomes.js +94 -0
- package/dist/tomes.js.map +1 -0
- package/dist/trade.js +103 -0
- package/dist/trade.js.map +1 -0
- package/dist/transport.d.ts +6 -1
- package/dist/transport.js +281 -0
- package/dist/transport.js.map +1 -0
- package/dist/tunables.d.ts +10 -3
- package/dist/tunables.js +56 -0
- package/dist/tunables.js.map +1 -0
- package/dist/unitResources.d.ts +67 -0
- package/dist/unitResources.js +266 -0
- package/dist/unitResources.js.map +1 -0
- package/dist/upkeep.d.ts +6 -1
- package/dist/upkeep.js +26 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/veterancy.d.ts +8 -3
- package/dist/veterancy.js +131 -0
- package/dist/veterancy.js.map +1 -0
- package/dist/vision.d.ts +36 -0
- package/dist/vision.js +133 -0
- package/dist/vision.js.map +1 -0
- package/dist/walls.d.ts +1 -1
- package/dist/walls.js +278 -0
- package/dist/walls.js.map +1 -0
- package/dist/world.d.ts +606 -88
- package/dist/world.js +1263 -0
- package/dist/world.js.map +1 -0
- package/package.json +2 -2
- package/dist/ai.js.map +0 -1
- package/dist/attributes.d.ts +0 -66
- package/dist/brain-BvVdUhX8.js +0 -7659
- package/dist/brain-BvVdUhX8.js.map +0 -1
- package/dist/builds-C6LfgvEU.js +0 -460
- package/dist/builds-C6LfgvEU.js.map +0 -1
- package/dist/coreComponents-syuh2fPG.js +0 -5149
- package/dist/coreComponents-syuh2fPG.js.map +0 -1
- package/dist/debugCommands-CzjrSm66.js +0 -14739
- package/dist/debugCommands-CzjrSm66.js.map +0 -1
- package/dist/determinism-BCymQwiE.js +0 -518
- package/dist/determinism-BCymQwiE.js.map +0 -1
- package/dist/game-DiJEN-Ks.js +0 -5800
- package/dist/game-DiJEN-Ks.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspect-D9dWHmZ0.js.map +0 -1
- package/dist/local-Dkovq42k.js +0 -1379
- package/dist/local-Dkovq42k.js.map +0 -1
- package/dist/missionRules-C-bGxm0Q.js.map +0 -1
- package/dist/navigation-worker.js.map +0 -1
- package/dist/packs-g5thvmGn.js +0 -3199
- package/dist/packs-g5thvmGn.js.map +0 -1
- package/dist/profiles-B3NS9jwk.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/simulate-oXBiw1Ff.js.map +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { cos, hypot, sin } from "./exactMath.js";
|
|
2
|
+
import { footprintOf } from "./defs.js";
|
|
3
|
+
import { defineComponent } from "./components.js";
|
|
4
|
+
import { distanceToEdge, moving } from "./entity.js";
|
|
5
|
+
import { effectOrigin, land } from "./abilities/land.js";
|
|
6
|
+
import { defineHook } from "./hooks.js";
|
|
7
|
+
import { moveToEntity } from "./systems/movement.js";
|
|
8
|
+
import { valueOf } from "./abilities/amounts.js";
|
|
9
|
+
import { effectHeading } from "./abilities/shapes.js";
|
|
10
|
+
import { defineEffect, removeMissile } from "./abilities/effects.js";
|
|
11
|
+
import { createOrder, giveOrder } from "./orders/queue.js";
|
|
12
|
+
//#region src/groundObjects.ts
|
|
13
|
+
/**
|
|
14
|
+
* The ground objects pack's id
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
var GROUND_OBJECTS = "core.groundObjects";
|
|
19
|
+
/**
|
|
20
|
+
* Who put a unit down (`MadeBy`): on what a `spawn` of the pack makes
|
|
21
|
+
*
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
var madeBy = /* @__PURE__ */ defineComponent({
|
|
25
|
+
id: "core.madeBy",
|
|
26
|
+
refs: (saved) => ({ abilities: [saved.ability] })
|
|
27
|
+
});
|
|
28
|
+
/** Whether a unit type is something the pack looks after: a trap, a thing used, a missile wall, a barrel */
|
|
29
|
+
var isGroundObject = (entity) => {
|
|
30
|
+
const { def } = entity;
|
|
31
|
+
return !!(def.trigger || def.use || def.blocksMissiles || def.burst);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* What a ground object keeps (`GroundObjectState`): on every unit whose type has a `trigger`, a `use`,
|
|
35
|
+
* `blocksMissiles` or a `burst`, from the moment it is made
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
var groundObject = /* @__PURE__ */ defineComponent({
|
|
40
|
+
id: "core.groundObject",
|
|
41
|
+
index: true,
|
|
42
|
+
onSpawn: (entity) => {
|
|
43
|
+
if (!isGroundObject(entity)) return;
|
|
44
|
+
const arm = entity.def.trigger?.arm;
|
|
45
|
+
entity.set(groundObject, arm ? { arm } : {});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
/** The spots of a line or a ring of a `spawn`, worked out where it landed */
|
|
49
|
+
function spots(context, line, ring) {
|
|
50
|
+
const { point } = context;
|
|
51
|
+
const heading = effectHeading(context);
|
|
52
|
+
if (ring) {
|
|
53
|
+
const count = Math.max(1, Math.round(ring.count));
|
|
54
|
+
return Array.from({ length: count }, (_, i) => {
|
|
55
|
+
const turn = heading + i * 2 * Math.PI / count;
|
|
56
|
+
return {
|
|
57
|
+
x: point.x + sin(turn) * ring.radius,
|
|
58
|
+
z: point.z + cos(turn) * ring.radius
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (!line) return [point];
|
|
63
|
+
const count = Math.max(1, Math.round(line.count));
|
|
64
|
+
if (count === 1) return [point];
|
|
65
|
+
let from;
|
|
66
|
+
let to;
|
|
67
|
+
if (line.length === void 0) {
|
|
68
|
+
from = effectOrigin(context);
|
|
69
|
+
to = point;
|
|
70
|
+
} else {
|
|
71
|
+
const way = heading + (line.across ? Math.PI / 2 : 0);
|
|
72
|
+
const half = line.length / 2;
|
|
73
|
+
from = {
|
|
74
|
+
x: point.x - sin(way) * half,
|
|
75
|
+
z: point.z - cos(way) * half
|
|
76
|
+
};
|
|
77
|
+
to = {
|
|
78
|
+
x: point.x + sin(way) * half,
|
|
79
|
+
z: point.z + cos(way) * half
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
83
|
+
x: from.x + (to.x - from.x) * i / (count - 1),
|
|
84
|
+
z: from.z + (to.z - from.z) * i / (count - 1)
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
/** A `spawn` that lays its units along a `line` or round a `ring`, each knowing who put it down (`madeBy`) */
|
|
88
|
+
var spawnHere = /* @__PURE__ */ defineEffect({
|
|
89
|
+
type: "spawn",
|
|
90
|
+
run: (context, effect) => {
|
|
91
|
+
const { world, caster, ability, level } = context;
|
|
92
|
+
if (!effect.unit) return;
|
|
93
|
+
const def = world.registry.unit(effect.unit);
|
|
94
|
+
const lifetime = effect.duration === void 0 ? void 0 : valueOf(context, effect.duration);
|
|
95
|
+
const looksLike = effect.looksLike === "target" ? context.target : effect.looksLike === "caster" ? caster : void 0;
|
|
96
|
+
const data = effect.data && Object.fromEntries(Object.entries(effect.data).map(([id, value]) => {
|
|
97
|
+
const component = world.registry.component(id);
|
|
98
|
+
return [id, component?.load ? component.load(value, world.registry) : value];
|
|
99
|
+
}));
|
|
100
|
+
const owner = effect.owner === "neutral" ? world.neutral : caster.owner;
|
|
101
|
+
const made = [];
|
|
102
|
+
const taken = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const spot of spots(context, effect.line, effect.ring)) {
|
|
104
|
+
if (def.kind !== "unit") {
|
|
105
|
+
const fp = footprintOf(def);
|
|
106
|
+
const cell = world.grid.cellFor(spot.x, spot.z, fp.w, fp.d);
|
|
107
|
+
const key = cell.z * world.terrain.width + cell.x;
|
|
108
|
+
if (taken.has(key) || !free(world, cell, fp)) continue;
|
|
109
|
+
taken.add(key);
|
|
110
|
+
}
|
|
111
|
+
made.push(world.spawn(effect.unit, owner, spot, {
|
|
112
|
+
facing: caster.facing,
|
|
113
|
+
lifetime,
|
|
114
|
+
looksLike,
|
|
115
|
+
data
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
const group = made.length > 1 ? made.map((entity) => entity.id) : void 0;
|
|
119
|
+
for (const entity of made) entity.set(madeBy, {
|
|
120
|
+
by: caster.id,
|
|
121
|
+
ability: ability.id,
|
|
122
|
+
level,
|
|
123
|
+
...group && { group }
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
fields: [
|
|
127
|
+
"unit",
|
|
128
|
+
"duration",
|
|
129
|
+
"owner",
|
|
130
|
+
"looksLike",
|
|
131
|
+
{
|
|
132
|
+
path: "line.count",
|
|
133
|
+
kind: "integer",
|
|
134
|
+
min: 1,
|
|
135
|
+
hint: "So many along a line, ends included"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
path: "line.length",
|
|
139
|
+
kind: "number",
|
|
140
|
+
min: 0,
|
|
141
|
+
hint: "How long the line is, around where it landed: from the caster to there when left out"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
path: "line.across",
|
|
145
|
+
kind: "boolean",
|
|
146
|
+
hint: "The line lies across the way it was aimed (a wall in front), not along it"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
path: "ring.count",
|
|
150
|
+
kind: "integer",
|
|
151
|
+
min: 1,
|
|
152
|
+
hint: "So many round a circle about where it landed"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
path: "ring.radius",
|
|
156
|
+
kind: "number",
|
|
157
|
+
min: 0,
|
|
158
|
+
hint: "How far out the circle is"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
/** Whether the cells of a footprint are free to stand a building on */
|
|
163
|
+
function free(world, cell, fp) {
|
|
164
|
+
for (let z = cell.z; z < cell.z + fp.d; z++) for (let x = cell.x; x < cell.x + fp.w; x++) if (!world.grid.isFree(x, z)) return false;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
/** Whether one is of those a ground object is for (`by`), as its owner and maker go */
|
|
168
|
+
function isFor(world, object, other, by) {
|
|
169
|
+
if (by === "all") return true;
|
|
170
|
+
if (by === "maker") return object.get(madeBy)?.by === other.id;
|
|
171
|
+
return by === "enemies" ? world.areEnemies(object.owner, other.owner) : world.areAllies(object.owner, other.owner);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* What a ground object's ability does (a trap's, a thing used's, a barrel's): its effects in the name of its maker (its
|
|
175
|
+
* own where there is none any more), from it, to `target`, at `point`
|
|
176
|
+
*/
|
|
177
|
+
function goOff(world, object, id, target, point) {
|
|
178
|
+
if (!world.registry.abilities.has(id)) return;
|
|
179
|
+
const made = object.get(madeBy);
|
|
180
|
+
const maker = made && world.get(made.by);
|
|
181
|
+
const caster = maker?.alive ? maker : object;
|
|
182
|
+
const ability = world.registry.ability(id);
|
|
183
|
+
land({
|
|
184
|
+
world,
|
|
185
|
+
caster,
|
|
186
|
+
ability,
|
|
187
|
+
level: made?.level ?? 1,
|
|
188
|
+
target,
|
|
189
|
+
point: {
|
|
190
|
+
x: point.x,
|
|
191
|
+
z: point.z
|
|
192
|
+
},
|
|
193
|
+
origin: object
|
|
194
|
+
}, ability.effects);
|
|
195
|
+
}
|
|
196
|
+
var near = [];
|
|
197
|
+
/** Who has come within a trap's reach, and sets it off once each; gone after so many times */
|
|
198
|
+
function watch(world, object, state, dt) {
|
|
199
|
+
const trigger = object.def.trigger;
|
|
200
|
+
if (state.arm !== void 0) {
|
|
201
|
+
state.arm -= dt;
|
|
202
|
+
if (state.arm > 0) return;
|
|
203
|
+
delete state.arm;
|
|
204
|
+
}
|
|
205
|
+
const radius = trigger.radius ?? 1;
|
|
206
|
+
const by = trigger.by ?? "enemies";
|
|
207
|
+
const now = [];
|
|
208
|
+
for (const other of world.spatial.query(object.pos.x, object.pos.z, radius + 2, near)) {
|
|
209
|
+
if (other === object || !other.alive || other.hidden || !other.isUnit || isGroundObject(other)) continue;
|
|
210
|
+
if (distanceToEdge(object.pos, other) > radius || !isFor(world, object, other, by)) continue;
|
|
211
|
+
now.push(other);
|
|
212
|
+
}
|
|
213
|
+
now.sort((a, b) => a.id - b.id);
|
|
214
|
+
const before = new Set(state.inside ?? []);
|
|
215
|
+
state.inside = now.length ? now.map((entity) => entity.id) : void 0;
|
|
216
|
+
const times = trigger.times ?? 1;
|
|
217
|
+
for (const other of now) {
|
|
218
|
+
if (before.has(other.id) || !object.alive) continue;
|
|
219
|
+
state.went = (state.went ?? 0) + 1;
|
|
220
|
+
goOff(world, object, trigger.ability, other, object.pos);
|
|
221
|
+
if (times > 0 && state.went >= times) {
|
|
222
|
+
if (object.alive) world.kill(object, void 0, false, "depleted");
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** Missiles about to meet a wall of the pack (`blocksMissiles`): gone, nothing happening */
|
|
228
|
+
function stopMissiles(world, walls, dt) {
|
|
229
|
+
for (const missile of [...world.missiles]) {
|
|
230
|
+
if (missile.delay > 0 || missile.effect.arc) continue;
|
|
231
|
+
const step = missile.speed * dt;
|
|
232
|
+
const next = {
|
|
233
|
+
x: missile.x + missile.dx * step,
|
|
234
|
+
z: missile.z + missile.dz * step
|
|
235
|
+
};
|
|
236
|
+
for (const wall of walls) {
|
|
237
|
+
if (!wall.alive || wall.hidden) continue;
|
|
238
|
+
if (wall.def.blocksMissiles === "enemies" && !world.areEnemies(wall.owner, missile.owner)) continue;
|
|
239
|
+
const reach = wall.def.radius + missile.radius;
|
|
240
|
+
if (gap({
|
|
241
|
+
x: missile.prevX,
|
|
242
|
+
z: missile.prevZ
|
|
243
|
+
}, missile, wall.pos) > reach && gap(missile, next, wall.pos) > reach) continue;
|
|
244
|
+
removeMissile(world, missile);
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** How near a step from `a` to `b` comes to `p` */
|
|
250
|
+
function gap(a, b, p) {
|
|
251
|
+
const dx = b.x - a.x;
|
|
252
|
+
const dz = b.z - a.z;
|
|
253
|
+
const length = dx * dx + dz * dz;
|
|
254
|
+
const t = length > 0 ? Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.z - a.z) * dz) / length)) : 0;
|
|
255
|
+
return hypot(a.x + dx * t - p.x, a.z + dz * t - p.z);
|
|
256
|
+
}
|
|
257
|
+
/** Traps watched, walls of wind standing in missiles' way: before the missiles move */
|
|
258
|
+
var groundObjectsSystem = {
|
|
259
|
+
name: "groundObjects",
|
|
260
|
+
phase: "decide",
|
|
261
|
+
before: ["abilities"],
|
|
262
|
+
update(world, dt) {
|
|
263
|
+
const walls = [];
|
|
264
|
+
for (const object of [...world.index.with(groundObject)]) {
|
|
265
|
+
const state = object.get(groundObject);
|
|
266
|
+
if (!state || !object.alive) continue;
|
|
267
|
+
if (object.def.blocksMissiles) walls.push(object);
|
|
268
|
+
if (object.def.trigger) watch(world, object, state, dt);
|
|
269
|
+
}
|
|
270
|
+
if (walls.length && world.missiles.length) stopMissiles(world, walls, dt);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
/** How near a thing used one has to come */
|
|
274
|
+
var reachOf = (object) => object.def.use?.range ?? 1;
|
|
275
|
+
/**
|
|
276
|
+
* Uses a ground object (`UnitTypeDef.use`), as the `useObject` order does once there: its ability goes off, the user
|
|
277
|
+
* its target, and it is gone after its `times`. False where it is no such thing, or not for this one
|
|
278
|
+
*
|
|
279
|
+
* @beta
|
|
280
|
+
*/
|
|
281
|
+
function useObject(world, user, object) {
|
|
282
|
+
const use = object.def.use;
|
|
283
|
+
if (!use || !object.alive || object.hidden || !user.alive || !isFor(world, object, user, use.by ?? "allies")) return false;
|
|
284
|
+
const state = object.get(groundObject);
|
|
285
|
+
const went = (state?.went ?? 0) + 1;
|
|
286
|
+
if (state) state.went = went;
|
|
287
|
+
const group = object.get(madeBy)?.group ?? [];
|
|
288
|
+
const others = group.map((id) => world.get(id)).filter((each) => !!each?.alive && each !== object);
|
|
289
|
+
const index = group.indexOf(object.id);
|
|
290
|
+
const next = others.find((each) => group.indexOf(each.id) > index) ?? others[0];
|
|
291
|
+
goOff(world, object, use.ability, user, (next ?? object).pos);
|
|
292
|
+
if (use.times && went >= use.times && object.alive) world.kill(object, void 0, false, "depleted");
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
/** A thing others use standing on a point, as a right-click on one of an enemy's sends a unit onto it */
|
|
296
|
+
function usableAt(world, point) {
|
|
297
|
+
for (const object of world.index.with(groundObject)) if (object.def.use && object.alive && Math.abs(object.pos.x - point.x) < .01 && Math.abs(object.pos.z - point.z) < .01) return object;
|
|
298
|
+
}
|
|
299
|
+
/** Walking up to a thing others use, and using it */
|
|
300
|
+
var useOrder = {
|
|
301
|
+
type: "useObject",
|
|
302
|
+
accepts(world, entity, init) {
|
|
303
|
+
const object = world.get(init.target);
|
|
304
|
+
return !!entity.get(moving) && !!object?.def.use && isFor(world, object, entity, object.def.use.by ?? "allies");
|
|
305
|
+
},
|
|
306
|
+
update(world, entity, order) {
|
|
307
|
+
const object = world.get(order.init.target);
|
|
308
|
+
if (!object?.alive || object.hidden) return "failed";
|
|
309
|
+
if (distanceToEdge(entity.pos, object) - entity.def.radius <= reachOf(object)) return useObject(world, entity, object) ? "done" : "failed";
|
|
310
|
+
const m = entity.get(moving);
|
|
311
|
+
if (m.status === "moving") return "running";
|
|
312
|
+
if (m.status === "failed" && order.state.tried === world.tick - 1) return "failed";
|
|
313
|
+
order.state.tried = world.tick;
|
|
314
|
+
moveToEntity(world, entity, object, reachOf(object) * .5);
|
|
315
|
+
return "running";
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Ground objects: what a game with it (`Rules.packs`) gets for what abilities put down. Its `spawn` lays units along a
|
|
320
|
+
* `line` or round a `ring` (buildings one to a cell, standing in the way as any building does), each knowing who put it
|
|
321
|
+
* down (`madeBy`); a unit type may be a trap or a pickup (`trigger`: its ability goes off as one it is for comes near,
|
|
322
|
+
* armed after `arm`, gone after `times`), a thing others use (`use`: right-clicked, walked up to and used, the
|
|
323
|
+
* `useObject` order; `useObject` in code), a wall that stops missiles (`blocksMissiles`) or a barrel that bursts as it
|
|
324
|
+
* dies and sets off those of its kind near it (`burst`)
|
|
325
|
+
*
|
|
326
|
+
* @beta
|
|
327
|
+
*/
|
|
328
|
+
function groundObjectsPack() {
|
|
329
|
+
const toUse = defineHook({
|
|
330
|
+
hook: "beforeOrder",
|
|
331
|
+
id: "groundObjects",
|
|
332
|
+
run(world, event) {
|
|
333
|
+
const { order, entity } = event;
|
|
334
|
+
if (order.type !== "move" && order.type !== "attack") return;
|
|
335
|
+
const object = order.init.target !== void 0 ? world.get(order.init.target) : order.init.point && usableAt(world, order.init.point);
|
|
336
|
+
const use = object?.def.use;
|
|
337
|
+
if (!object || !use || order.type === "attack" && !object.def.invulnerable) return;
|
|
338
|
+
if (!entity.get(moving) || !isFor(world, object, entity, use.by ?? "allies")) return;
|
|
339
|
+
event.rejected = true;
|
|
340
|
+
giveOrder(world, entity, createOrder(world, {
|
|
341
|
+
type: "useObject",
|
|
342
|
+
target: object.id
|
|
343
|
+
}, order.groupId), event.queued);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
const bursts = defineHook({
|
|
347
|
+
hook: "death",
|
|
348
|
+
id: "groundObjects",
|
|
349
|
+
run(world, death) {
|
|
350
|
+
const { entity, killer } = death;
|
|
351
|
+
const burst = entity.def.burst;
|
|
352
|
+
if (!burst) return;
|
|
353
|
+
goOff(world, entity, burst.ability, killer, entity.pos);
|
|
354
|
+
if (!burst.chain) return;
|
|
355
|
+
const chained = world.spatial.query(entity.pos.x, entity.pos.z, burst.chain + 2).filter((other) => other !== entity && other.alive && other.def.id === entity.def.id && other.owner === entity.owner).filter((other) => hypot(other.pos.x - entity.pos.x, other.pos.z - entity.pos.z) <= burst.chain).sort((a, b) => a.id - b.id);
|
|
356
|
+
for (const other of chained) if (other.alive) world.kill(other, killer, false);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
id: GROUND_OBJECTS,
|
|
361
|
+
components: [madeBy, groundObject],
|
|
362
|
+
effects: [spawnHere],
|
|
363
|
+
orders: [useOrder],
|
|
364
|
+
systems: [groundObjectsSystem],
|
|
365
|
+
hooks: [toUse, bursts]
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
export { GROUND_OBJECTS, groundObject, groundObjectsPack, madeBy, useObject };
|
|
370
|
+
|
|
371
|
+
//# sourceMappingURL=groundObjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groundObjects.js","names":[],"sources":["../src/groundObjects.ts"],"sourcesContent":["import { valueOf } from './abilities/amounts'\nimport { defineEffect, type EffectContext, removeMissile } from './abilities/effects'\nimport { effectOrigin, land } from './abilities/land'\nimport { effectHeading } from './abilities/shapes'\nimport { defineComponent } from './components'\nimport { footprintOf, type SpawnLine } from './defs'\nimport { distanceToEdge, type Entity, type EntityId, moving } from './entity'\nimport { cos, hypot, sin } from './exactMath'\nimport { defineHook } from './hooks'\nimport type { Vec2 } from './math'\nimport { createOrder, giveOrder } from './orders/queue'\nimport type { GamePack } from './packs/pack'\nimport type { OrderBehavior, OrderParams, System } from './registry'\nimport { moveToEntity } from './systems/movement'\nimport type { World } from './world'\n\n/*\n * Ground objects, an opt-in pack (E2E-PLAN AB13): what an ability puts down that stays and is acted on: lines and rings\n * of it (walls of ice, of rock, of wind, a ring of earth), traps and pickups set off by who comes near, things others\n * click on and use (a lantern, a portal), walls that stop missiles, and barrels that burst and set each other off. A game\n * without it keeps the engine's `spawn`, and pays nothing for these\n */\n\n/**\n * The ground objects pack's id\n *\n * @beta\n */\nexport const GROUND_OBJECTS = 'core.groundObjects'\n\n/**\n * Who put a unit down, for one made by a `spawn` of the ground objects pack: in whose name what it does goes off (`by`),\n * by which ability and at what level, and the others put down with it (`group`, in order: a portal's other end)\n *\n * @beta\n */\nexport interface MadeBy {\n\t/** Who put it down */\n\tby: EntityId\n\t/** The ability it was put down by */\n\tability: string\n\t/** The level it was cast at */\n\tlevel: number\n\t/** Those put down with it, itself among them, in the order they were laid: where there were more than one */\n\tgroup?: EntityId[]\n}\n\n/**\n * What a ground object keeps of what it does (`UnitTypeDef.trigger`, `use`): seconds before it is armed, times it went\n * off or was used, and who is within its reach now (each sets it off as it comes, not again while it stays)\n *\n * @beta\n */\nexport interface GroundObjectState {\n\t/** Seconds before its trigger works */\n\tarm?: number\n\t/** Times it went off, or was used */\n\twent?: number\n\t/** Who is within its trigger's reach now, by id */\n\tinside?: EntityId[]\n}\n\n/**\n * Who put a unit down (`MadeBy`): on what a `spawn` of the pack makes\n *\n * @beta\n */\nexport const madeBy = /* @__PURE__ */ defineComponent<MadeBy>({\n\tid: 'core.madeBy',\n\trefs: (saved) => ({ abilities: [(saved as MadeBy).ability] })\n})\n\n/** Whether a unit type is something the pack looks after: a trap, a thing used, a missile wall, a barrel */\nconst isGroundObject = (entity: Entity): boolean => {\n\tconst { def } = entity\n\treturn !!(def.trigger || def.use || def.blocksMissiles || def.burst)\n}\n\n/**\n * What a ground object keeps (`GroundObjectState`): on every unit whose type has a `trigger`, a `use`,\n * `blocksMissiles` or a `burst`, from the moment it is made\n *\n * @beta\n */\nexport const groundObject = /* @__PURE__ */ defineComponent<GroundObjectState>({\n\tid: 'core.groundObject',\n\tindex: true,\n\tonSpawn: (entity) => {\n\t\tif (!isGroundObject(entity)) return\n\t\tconst arm = entity.def.trigger?.arm\n\t\tentity.set(groundObject, arm ? { arm } : {})\n\t}\n})\n\n/** The spots of a line or a ring of a `spawn`, worked out where it landed */\nfunction spots(context: EffectContext, line: SpawnLine | undefined, ring: { count: number; radius: number } | undefined): Vec2[] {\n\tconst { point } = context\n\tconst heading = effectHeading(context)\n\tif (ring) {\n\t\tconst count = Math.max(1, Math.round(ring.count))\n\t\treturn Array.from({ length: count }, (_, i) => {\n\t\t\tconst turn = heading + (i * 2 * Math.PI) / count\n\t\t\treturn { x: point.x + sin(turn) * ring.radius, z: point.z + cos(turn) * ring.radius }\n\t\t})\n\t}\n\tif (!line) return [point]\n\tconst count = Math.max(1, Math.round(line.count))\n\tif (count === 1) return [point]\n\tlet from: Vec2\n\tlet to: Vec2\n\tif (line.length === undefined) {\n\t\tfrom = effectOrigin(context)\n\t\tto = point\n\t} else {\n\t\tconst way = heading + (line.across ? Math.PI / 2 : 0)\n\t\tconst half = line.length / 2\n\t\tfrom = { x: point.x - sin(way) * half, z: point.z - cos(way) * half }\n\t\tto = { x: point.x + sin(way) * half, z: point.z + cos(way) * half }\n\t}\n\treturn Array.from({ length: count }, (_, i) => ({ x: from.x + ((to.x - from.x) * i) / (count - 1), z: from.z + ((to.z - from.z) * i) / (count - 1) }))\n}\n\n/** A `spawn` that lays its units along a `line` or round a `ring`, each knowing who put it down (`madeBy`) */\nconst spawnHere = /* @__PURE__ */ defineEffect({\n\ttype: 'spawn',\n\trun: (context, effect) => {\n\t\tconst { world, caster, ability, level } = context\n\t\tif (!effect.unit) return\n\t\tconst def = world.registry.unit(effect.unit)\n\t\tconst lifetime = effect.duration === undefined ? undefined : valueOf(context, effect.duration)\n\t\tconst looksLike = effect.looksLike === 'target' ? context.target : effect.looksLike === 'caster' ? caster : undefined\n\t\t// the form a save keeps a component in: what its `load` reads\n\t\tconst data =\n\t\t\teffect.data &&\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries(effect.data).map(([id, value]) => {\n\t\t\t\t\tconst component = world.registry.component(id)\n\t\t\t\t\treturn [id, component?.load ? component.load(value, world.registry) : value]\n\t\t\t\t})\n\t\t\t)\n\t\tconst owner = effect.owner === 'neutral' ? world.neutral : caster.owner\n\t\tconst made: Entity[] = []\n\t\tconst taken = new Set<number>()\n\t\tfor (const spot of spots(context, effect.line, effect.ring)) {\n\t\t\tif (def.kind !== 'unit') {\n\t\t\t\t// a building to a cell: where one stands already, none\n\t\t\t\tconst fp = footprintOf(def)\n\t\t\t\tconst cell = world.grid.cellFor(spot.x, spot.z, fp.w, fp.d)\n\t\t\t\tconst key = cell.z * world.terrain.width + cell.x\n\t\t\t\tif (taken.has(key) || !free(world, cell, fp)) continue\n\t\t\t\ttaken.add(key)\n\t\t\t}\n\t\t\tmade.push(world.spawn(effect.unit, owner, spot, { facing: caster.facing, lifetime, looksLike, data }))\n\t\t}\n\t\tconst group = made.length > 1 ? made.map((entity) => entity.id) : undefined\n\t\tfor (const entity of made) entity.set(madeBy, { by: caster.id, ability: ability.id, level, ...(group && { group }) })\n\t},\n\tfields: [\n\t\t'unit',\n\t\t'duration',\n\t\t'owner',\n\t\t'looksLike',\n\t\t{ path: 'line.count', kind: 'integer', min: 1, hint: 'So many along a line, ends included' },\n\t\t{ path: 'line.length', kind: 'number', min: 0, hint: 'How long the line is, around where it landed: from the caster to there when left out' },\n\t\t{ path: 'line.across', kind: 'boolean', hint: 'The line lies across the way it was aimed (a wall in front), not along it' },\n\t\t{ path: 'ring.count', kind: 'integer', min: 1, hint: 'So many round a circle about where it landed' },\n\t\t{ path: 'ring.radius', kind: 'number', min: 0, hint: 'How far out the circle is' }\n\t]\n})\n\n/** Whether the cells of a footprint are free to stand a building on */\nfunction free(world: World, cell: { x: number; z: number }, fp: { w: number; d: number }): boolean {\n\tfor (let z = cell.z; z < cell.z + fp.d; z++) for (let x = cell.x; x < cell.x + fp.w; x++) if (!world.grid.isFree(x, z)) return false\n\treturn true\n}\n\n/** Whether one is of those a ground object is for (`by`), as its owner and maker go */\nfunction isFor(world: World, object: Entity, other: Entity, by: 'enemies' | 'allies' | 'all' | 'maker'): boolean {\n\tif (by === 'all') return true\n\tif (by === 'maker') return object.get(madeBy)?.by === other.id\n\treturn by === 'enemies' ? world.areEnemies(object.owner, other.owner) : world.areAllies(object.owner, other.owner)\n}\n\n/**\n * What a ground object's ability does (a trap's, a thing used's, a barrel's): its effects in the name of its maker (its\n * own where there is none any more), from it, to `target`, at `point`\n */\nfunction goOff(world: World, object: Entity, id: string, target: Entity | undefined, point: Vec2): void {\n\tif (!world.registry.abilities.has(id)) return\n\tconst made = object.get(madeBy)\n\tconst maker = made && world.get(made.by)\n\tconst caster = maker?.alive ? maker : object\n\tconst ability = world.registry.ability(id)\n\tland({ world, caster, ability, level: made?.level ?? 1, target, point: { x: point.x, z: point.z }, origin: object }, ability.effects)\n}\n\nconst near: Entity[] = []\n\n/** Who has come within a trap's reach, and sets it off once each; gone after so many times */\nfunction watch(world: World, object: Entity, state: GroundObjectState, dt: number): void {\n\tconst trigger = object.def.trigger!\n\tif (state.arm !== undefined) {\n\t\tstate.arm -= dt\n\t\tif (state.arm > 0) return\n\t\tdelete state.arm\n\t}\n\tconst radius = trigger.radius ?? 1\n\tconst by = trigger.by ?? 'enemies'\n\tconst now: Entity[] = []\n\tfor (const other of world.spatial.query(object.pos.x, object.pos.z, radius + 2, near)) {\n\t\tif (other === object || !other.alive || other.hidden || !other.isUnit || isGroundObject(other)) continue\n\t\tif (distanceToEdge(object.pos, other) > radius || !isFor(world, object, other, by)) continue\n\t\tnow.push(other)\n\t}\n\tnow.sort((a, b) => a.id - b.id)\n\tconst before = new Set(state.inside ?? [])\n\tstate.inside = now.length ? now.map((entity) => entity.id) : undefined\n\tconst times = trigger.times ?? 1\n\tfor (const other of now) {\n\t\tif (before.has(other.id) || !object.alive) continue\n\t\tstate.went = (state.went ?? 0) + 1\n\t\tgoOff(world, object, trigger.ability, other, object.pos)\n\t\tif (times > 0 && state.went >= times) {\n\t\t\tif (object.alive) world.kill(object, undefined, false, 'depleted')\n\t\t\treturn\n\t\t}\n\t}\n}\n\n/** Missiles about to meet a wall of the pack (`blocksMissiles`): gone, nothing happening */\nfunction stopMissiles(world: World, walls: Entity[], dt: number): void {\n\tfor (const missile of [...world.missiles]) {\n\t\tif (missile.delay > 0 || missile.effect.arc) continue\n\t\tconst step = missile.speed * dt\n\t\tconst next = { x: missile.x + missile.dx * step, z: missile.z + missile.dz * step }\n\t\tfor (const wall of walls) {\n\t\t\tif (!wall.alive || wall.hidden) continue\n\t\t\tif (wall.def.blocksMissiles === 'enemies' && !world.areEnemies(wall.owner, missile.owner)) continue\n\t\t\tconst reach = wall.def.radius + missile.radius\n\t\t\tif (gap({ x: missile.prevX, z: missile.prevZ }, missile, wall.pos) > reach && gap(missile, next, wall.pos) > reach) continue\n\t\t\tremoveMissile(world, missile)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n/** How near a step from `a` to `b` comes to `p` */\nfunction gap(a: Vec2, b: Vec2, p: Vec2): number {\n\tconst dx = b.x - a.x\n\tconst dz = b.z - a.z\n\tconst length = dx * dx + dz * dz\n\tconst t = length > 0 ? Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.z - a.z) * dz) / length)) : 0\n\treturn hypot(a.x + dx * t - p.x, a.z + dz * t - p.z)\n}\n\n/** Traps watched, walls of wind standing in missiles' way: before the missiles move */\nconst groundObjectsSystem: System = {\n\tname: 'groundObjects',\n\tphase: 'decide',\n\tbefore: ['abilities'],\n\tupdate(world, dt) {\n\t\tconst walls: Entity[] = []\n\t\tfor (const object of [...world.index.with(groundObject)]) {\n\t\t\tconst state = object.get(groundObject)\n\t\t\tif (!state || !object.alive) continue\n\t\t\tif (object.def.blocksMissiles) walls.push(object)\n\t\t\tif (object.def.trigger) watch(world, object, state, dt)\n\t\t}\n\t\tif (walls.length && world.missiles.length) stopMissiles(world, walls, dt)\n\t}\n}\n\n/** How near a thing used one has to come */\nconst reachOf = (object: Entity): number => object.def.use?.range ?? 1\n\n/**\n * Uses a ground object (`UnitTypeDef.use`), as the `useObject` order does once there: its ability goes off, the user\n * its target, and it is gone after its `times`. False where it is no such thing, or not for this one\n *\n * @beta\n */\nexport function useObject(world: World, user: Entity, object: Entity): boolean {\n\tconst use = object.def.use\n\tif (!use || !object.alive || object.hidden || !user.alive || !isFor(world, object, user, use.by ?? 'allies')) return false\n\tconst state = object.get(groundObject)\n\tconst went = (state?.went ?? 0) + 1\n\tif (state) state.went = went\n\t// the next of those put down with it, where there is one: a portal's other end\n\tconst group = object.get(madeBy)?.group ?? []\n\tconst others = group.map((id) => world.get(id)).filter((each): each is Entity => !!each?.alive && each !== object)\n\tconst index = group.indexOf(object.id)\n\tconst next = others.find((each) => group.indexOf(each.id) > index) ?? others[0]\n\tgoOff(world, object, use.ability, user, (next ?? object).pos)\n\tif (use.times && went >= use.times && object.alive) world.kill(object, undefined, false, 'depleted')\n\treturn true\n}\n\n/** A thing others use standing on a point, as a right-click on one of an enemy's sends a unit onto it */\nfunction usableAt(world: World, point: Vec2): Entity | undefined {\n\tfor (const object of world.index.with(groundObject))\n\t\tif (object.def.use && object.alive && Math.abs(object.pos.x - point.x) < 0.01 && Math.abs(object.pos.z - point.z) < 0.01) return object\n\treturn undefined\n}\n\n/** Walking up to a thing others use, and using it */\nconst useOrder: OrderBehavior<{ tried?: number }, Pick<OrderParams, 'target'>> = {\n\ttype: 'useObject',\n\taccepts(world, entity, init) {\n\t\tconst object = world.get(init.target)\n\t\treturn !!entity.get(moving) && !!object?.def.use && isFor(world, object, entity, object.def.use.by ?? 'allies')\n\t},\n\tupdate(world, entity, order) {\n\t\tconst object = world.get(order.init.target)\n\t\tif (!object?.alive || object.hidden) return 'failed'\n\t\tif (distanceToEdge(entity.pos, object) - entity.def.radius <= reachOf(object)) return useObject(world, entity, object) ? 'done' : 'failed'\n\t\tconst m = entity.get(moving)!\n\t\tif (m.status === 'moving') return 'running'\n\t\tif (m.status === 'failed' && order.state.tried === world.tick - 1) return 'failed'\n\t\torder.state.tried = world.tick\n\t\tmoveToEntity(world, entity, object, reachOf(object) * 0.5)\n\t\treturn 'running'\n\t}\n}\n\n/**\n * Ground objects: what a game with it (`Rules.packs`) gets for what abilities put down. Its `spawn` lays units along a\n * `line` or round a `ring` (buildings one to a cell, standing in the way as any building does), each knowing who put it\n * down (`madeBy`); a unit type may be a trap or a pickup (`trigger`: its ability goes off as one it is for comes near,\n * armed after `arm`, gone after `times`), a thing others use (`use`: right-clicked, walked up to and used, the\n * `useObject` order; `useObject` in code), a wall that stops missiles (`blocksMissiles`) or a barrel that bursts as it\n * dies and sets off those of its kind near it (`burst`)\n *\n * @beta\n */\nexport function groundObjectsPack(): GamePack {\n\t// told to walk up to (or attack, where it cannot be hurt) a thing it may use: it uses it\n\tconst toUse = defineHook({\n\t\thook: 'beforeOrder',\n\t\tid: 'groundObjects',\n\t\trun(world, event) {\n\t\t\tconst { order, entity } = event\n\t\t\tif (order.type !== 'move' && order.type !== 'attack') return\n\t\t\t// right-clicked: told to it, or (as one of its enemies is: `smartOrder`) onto where it stands\n\t\t\tconst object = order.init.target !== undefined ? world.get(order.init.target) : order.init.point && usableAt(world, order.init.point)\n\t\t\tconst use = object?.def.use\n\t\t\tif (!object || !use || (order.type === 'attack' && !object.def.invulnerable)) return\n\t\t\tif (!entity.get(moving) || !isFor(world, object, entity, use.by ?? 'allies')) return\n\t\t\tevent.rejected = true\n\t\t\tgiveOrder(world, entity, createOrder(world, { type: 'useObject', target: object.id }, order.groupId), event.queued)\n\t\t}\n\t})\n\t// a barrel: its ability where it dies, and those of its kind near it go too\n\tconst bursts = defineHook({\n\t\thook: 'death',\n\t\tid: 'groundObjects',\n\t\trun(world, death) {\n\t\t\tconst { entity, killer } = death\n\t\t\tconst burst = entity.def.burst\n\t\t\tif (!burst) return\n\t\t\tgoOff(world, entity, burst.ability, killer, entity.pos)\n\t\t\tif (!burst.chain) return\n\t\t\tconst chained = world.spatial\n\t\t\t\t.query(entity.pos.x, entity.pos.z, burst.chain + 2)\n\t\t\t\t.filter((other) => other !== entity && other.alive && other.def.id === entity.def.id && other.owner === entity.owner)\n\t\t\t\t.filter((other) => hypot(other.pos.x - entity.pos.x, other.pos.z - entity.pos.z) <= burst.chain!)\n\t\t\t\t.sort((a, b) => a.id - b.id)\n\t\t\tfor (const other of chained) if (other.alive) world.kill(other, killer, false)\n\t\t}\n\t})\n\treturn {\n\t\tid: GROUND_OBJECTS,\n\t\tcomponents: [madeBy, groundObject],\n\t\teffects: [spawnHere],\n\t\torders: [useOrder],\n\t\tsystems: [groundObjectsSystem],\n\t\thooks: [toUse, b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Q,MAAM,SAAS,QAAQ,OAAO,GAAG;GACtD,IAAI,CAAC,MAAM,OAAO;GAClB,MAAM,UAAU,MAAM,QACpB,MAAM,OAAO,IAAI,GAAG,OAAO,IAAI,GAAG,MAAM,QAAQ,CAAC,CAAC,CAClD,QAAQ,UAAU,UAAU,UAAU,MAAM,SAAS,MAAM,IAAI,OAAO,OAAO,IAAI,MAAM,MAAM,UAAU,OAAO,KAAK,CAAC,CACpH,QAAQ,UAAU,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI,GAAG,MAAM,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,MAAM,KAAM,CAAC,CAChG,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;GAC5B,KAAK,MAAM,SAAS,SAAS,IAAI,MAAM,OAAO,MAAM,KAAK,OAAO,QAAQ,KAAK;EAC9E;CACD,CAAC;CACD,OAAO;EACN,IAAI;EACJ,YAAY,CAAC,QAAQ,YAAY;EACjC,SAAS,CAAC,SAAS;EACnB,QAAQ,CAAC,QAAQ;EACjB,SAAS,CAAC,mBAAmB;EAC7B,OAAO,CAAC,OAAO,MAAM;CACtB;AACD"}
|
package/dist/groundSpeed.d.ts
CHANGED
|
@@ -3,14 +3,20 @@ import type { Registry } from './registry';
|
|
|
3
3
|
import type { Terrain } from './terrain';
|
|
4
4
|
import type { World } from './world';
|
|
5
5
|
/**
|
|
6
|
-
* How fast one on foot goes over a cell of the map, as a multiplier: the tile's `speed` times the
|
|
7
|
-
* layer of cells that is not 0 there
|
|
6
|
+
* How fast one on foot goes over a cell of the map, as a multiplier: the tile's `speed` times the speed of every
|
|
7
|
+
* layer of cells that is not 0 there (its value's style's, `FoliageStyleDef.speed`, else the layer's `speed`); 1
|
|
8
|
+
* where nothing says. Off the map, 1
|
|
8
9
|
*
|
|
9
10
|
* @beta
|
|
10
11
|
*/
|
|
11
12
|
export declare function groundSpeedOfCell(world: World, x: number, z: number): number;
|
|
12
13
|
/** `groundSpeedOfCell` of a game's ground before there is a world of it: what its navigation is cut with */
|
|
13
14
|
export declare function groundSpeedOn(registry: Registry, terrain: Terrain, x: number, z: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* `groundSpeedOn` as the navigation is cut with it: -1 where a value of a layer stops one on foot
|
|
17
|
+
* (`FoliageStyleDef.walkable: false`, a thicket), which the ways go round as they go round a wall (`groundAreas.ts`)
|
|
18
|
+
*/
|
|
19
|
+
export declare function navigationSpeedOn(registry: Registry, terrain: Terrain, x: number, z: number): number;
|
|
14
20
|
/**
|
|
15
21
|
* How fast a unit goes where it stands, as a multiplier of its speed: the ground's for one on foot
|
|
16
22
|
* (`groundSpeedOfCell`), 1 for what flies or sails
|
|
@@ -18,5 +24,16 @@ export declare function groundSpeedOn(registry: Registry, terrain: Terrain, x: n
|
|
|
18
24
|
* @beta
|
|
19
25
|
*/
|
|
20
26
|
export declare function groundSpeedAt(world: World, entity: Entity): number;
|
|
21
|
-
/** Whether any of a game's ground slows or speeds one on foot: a tile, or a layer of cells, with a speed of its own */
|
|
27
|
+
/** Whether any of a game's ground slows or speeds one on foot: a tile, or a layer of cells or a value of one, with a speed of its own, or a value that stops one */
|
|
22
28
|
export declare function hasGroundSpeeds(registry: Registry): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a layer of cells of a game slows, speeds or stops one on foot somewhere: one whose changes in play the ways
|
|
31
|
+
* weigh again. Of the game's layers as they are now (a style changed while it plays, `debug.cellStyles`, counts). Not a
|
|
32
|
+
* state layer of grass (`foliageStateLayer`), which no game lists: what happens to grass does not cut the ways again
|
|
33
|
+
*/
|
|
34
|
+
export declare function slowsOnFoot(registry: Registry, layer: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a value of a layer of cells of a game stops one on foot (`FoliageStyleDef.walkable: false`, a thicket): a change
|
|
37
|
+
* of it may make cells walkable or not, which the ways keep their distance from beyond the cells' own tile
|
|
38
|
+
*/
|
|
39
|
+
export declare function stopsOnFoot(registry: Registry, layer: string): boolean;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { foliageStyle } from "./foliage.js";
|
|
2
|
+
//#region src/groundSpeed.ts
|
|
3
|
+
/** The speeds of a world's game's ground, worked out once a registry and again when its layers of cells are others */
|
|
4
|
+
var TILE_SPEEDS = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function speedsOf(registry) {
|
|
6
|
+
let speeds = TILE_SPEEDS.get(registry);
|
|
7
|
+
if (speeds && speeds.cellLayers === registry.cellLayers) return speeds;
|
|
8
|
+
const tiles = speeds?.tiles ?? new Float32Array(registry.tiles.length + 1).fill(1);
|
|
9
|
+
if (!speeds) registry.tiles.forEach((tile, index) => {
|
|
10
|
+
tiles[index + 1] = tile.speed !== void 0 && tile.speed >= 0 ? tile.speed : 1;
|
|
11
|
+
});
|
|
12
|
+
speeds = {
|
|
13
|
+
tiles,
|
|
14
|
+
layers: cellLayerSpeeds(registry),
|
|
15
|
+
cellLayers: registry.cellLayers
|
|
16
|
+
};
|
|
17
|
+
TILE_SPEEDS.set(registry, speeds);
|
|
18
|
+
return speeds;
|
|
19
|
+
}
|
|
20
|
+
/** The speed of each value of each layer of cells of a game that has one other than 1: the value's style's, else the layer's */
|
|
21
|
+
function cellLayerSpeeds(registry) {
|
|
22
|
+
const game = {
|
|
23
|
+
cellLayers: registry.cellLayers,
|
|
24
|
+
packs: registry.assembly?.rules.packs
|
|
25
|
+
};
|
|
26
|
+
const layers = [];
|
|
27
|
+
for (const def of registry.cellLayers) {
|
|
28
|
+
const ofLayer = def.speed !== void 0 && def.speed >= 0 ? def.speed : 1;
|
|
29
|
+
const speeds = (/* @__PURE__ */ new Float64Array(256)).fill(1);
|
|
30
|
+
let stops;
|
|
31
|
+
let any = false;
|
|
32
|
+
for (let value = 1; value < 256; value++) {
|
|
33
|
+
const style = foliageStyle(game, def.id, value);
|
|
34
|
+
const own = style?.speed;
|
|
35
|
+
speeds[value] = own !== void 0 && own >= 0 ? own : ofLayer;
|
|
36
|
+
if (speeds[value] !== 1) any = true;
|
|
37
|
+
if (style?.walkable === false) (stops ??= /* @__PURE__ */ new Uint8Array(256))[value] = 1;
|
|
38
|
+
}
|
|
39
|
+
if (any || stops) layers.push({
|
|
40
|
+
id: def.id,
|
|
41
|
+
speeds,
|
|
42
|
+
...stops && { stops }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return layers;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* How fast one on foot goes over a cell of the map, as a multiplier: the tile's `speed` times the speed of every
|
|
49
|
+
* layer of cells that is not 0 there (its value's style's, `FoliageStyleDef.speed`, else the layer's `speed`); 1
|
|
50
|
+
* where nothing says. Off the map, 1
|
|
51
|
+
*
|
|
52
|
+
* @beta
|
|
53
|
+
*/
|
|
54
|
+
function groundSpeedOfCell(world, x, z) {
|
|
55
|
+
return groundSpeedOn(world.registry, world.terrain, x, z);
|
|
56
|
+
}
|
|
57
|
+
/** `groundSpeedOfCell` of a game's ground before there is a world of it: what its navigation is cut with */
|
|
58
|
+
function groundSpeedOn(registry, terrain, x, z) {
|
|
59
|
+
const column = Math.floor(x);
|
|
60
|
+
const row = Math.floor(z);
|
|
61
|
+
if (column < 0 || row < 0 || column >= terrain.width || row >= terrain.depth) return 1;
|
|
62
|
+
const cell = row * terrain.width + column;
|
|
63
|
+
const { tiles, layers } = speedsOf(registry);
|
|
64
|
+
let speed = tiles[terrain.tiles[cell]] ?? 1;
|
|
65
|
+
for (const { id, speeds } of layers) {
|
|
66
|
+
const value = terrain.cells[id]?.[cell];
|
|
67
|
+
if (value) speed *= speeds[value];
|
|
68
|
+
}
|
|
69
|
+
return speed;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `groundSpeedOn` as the navigation is cut with it: -1 where a value of a layer stops one on foot
|
|
73
|
+
* (`FoliageStyleDef.walkable: false`, a thicket), which the ways go round as they go round a wall (`groundAreas.ts`)
|
|
74
|
+
*/
|
|
75
|
+
function navigationSpeedOn(registry, terrain, x, z) {
|
|
76
|
+
const column = Math.floor(x);
|
|
77
|
+
const row = Math.floor(z);
|
|
78
|
+
if (column < 0 || row < 0 || column >= terrain.width || row >= terrain.depth) return 1;
|
|
79
|
+
const cell = row * terrain.width + column;
|
|
80
|
+
for (const { id, stops } of speedsOf(registry).layers) if (stops?.[terrain.cells[id]?.[cell] ?? 0]) return -1;
|
|
81
|
+
return groundSpeedOn(registry, terrain, x, z);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* How fast a unit goes where it stands, as a multiplier of its speed: the ground's for one on foot
|
|
85
|
+
* (`groundSpeedOfCell`), 1 for what flies or sails
|
|
86
|
+
*
|
|
87
|
+
* @beta
|
|
88
|
+
*/
|
|
89
|
+
function groundSpeedAt(world, entity) {
|
|
90
|
+
if (entity.flying || entity.def.naval) return 1;
|
|
91
|
+
return groundSpeedOfCell(world, entity.pos.x, entity.pos.z);
|
|
92
|
+
}
|
|
93
|
+
/** Whether any of a game's ground slows or speeds one on foot: a tile, or a layer of cells or a value of one, with a speed of its own, or a value that stops one */
|
|
94
|
+
function hasGroundSpeeds(registry) {
|
|
95
|
+
return registry.tiles.some((tile) => tile.speed !== void 0 && tile.speed >= 0 && tile.speed !== 1) || speedsOf(registry).layers.length > 0;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether a layer of cells of a game slows, speeds or stops one on foot somewhere: one whose changes in play the ways
|
|
99
|
+
* weigh again. Of the game's layers as they are now (a style changed while it plays, `debug.cellStyles`, counts). Not a
|
|
100
|
+
* state layer of grass (`foliageStateLayer`), which no game lists: what happens to grass does not cut the ways again
|
|
101
|
+
*/
|
|
102
|
+
function slowsOnFoot(registry, layer) {
|
|
103
|
+
for (const each of speedsOf(registry).layers) if (each.id === layer) return true;
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether a value of a layer of cells of a game stops one on foot (`FoliageStyleDef.walkable: false`, a thicket): a change
|
|
108
|
+
* of it may make cells walkable or not, which the ways keep their distance from beyond the cells' own tile
|
|
109
|
+
*/
|
|
110
|
+
function stopsOnFoot(registry, layer) {
|
|
111
|
+
for (const each of speedsOf(registry).layers) if (each.id === layer) return !!each.stops;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { groundSpeedAt, groundSpeedOfCell, groundSpeedOn, hasGroundSpeeds, navigationSpeedOn, slowsOnFoot, stopsOnFoot };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=groundSpeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groundSpeed.js","names":[],"sources":["../src/groundSpeed.ts"],"sourcesContent":["import type { CellLayerDef } from './cellLayers'\nimport type { Entity } from './entity'\nimport { foliageStyle } from './foliage'\nimport type { Registry } from './registry'\nimport type { Terrain } from './terrain'\nimport type { World } from './world'\n\n/*\n * Ground that slows (master plan FI5): a tile's `speed` and a layer of cells' `speed` multiply how fast a unit on\n * foot goes over the cell it stands on, read each tick by the engine's `moveSpeed` rule (`RuleSettings.movement.moveSpeed`, which\n * a game's own replaces, keeping the last word). A layer's values may each have a speed of their own: a style of grass\n * (`FoliageStyleDef.speed`). What flies or sails is not slowed. Nothing is kept: the speed is the map's paint and the\n * game's definitions, the same on every machine\n */\n\n/** The speeds of a game's ground: of each tile, and of each value of the layers of cells that slow or speed */\ninterface GroundSpeeds {\n\t/** By the tile's index in the paint (0 is no tile) */\n\ttiles: Float32Array\n\t/**\n\t * The layers of cells with a speed other than 1 somewhere, or a value nobody on foot goes through, each with the\n\t * speed of its values (0 is none: 1), as the game says it (a double: a layer's `speed` multiplied as it is, as it\n\t * always was), and which values stop one on foot (`FoliageStyleDef.walkable`: none where none does)\n\t */\n\tlayers: { id: string; speeds: Float64Array; stops?: Uint8Array }[]\n\t/** The layers these were worked out of: others (a game's values changed while it plays) work them out again */\n\tcellLayers: readonly CellLayerDef[]\n}\n\n/** The speeds of a world's game's ground, worked out once a registry and again when its layers of cells are others */\nconst TILE_SPEEDS = new WeakMap<object, GroundSpeeds>()\n\nfunction speedsOf(registry: Registry): GroundSpeeds {\n\tlet speeds = TILE_SPEEDS.get(registry)\n\tif (speeds && speeds.cellLayers === registry.cellLayers) return speeds\n\tconst tiles = speeds?.tiles ?? new Float32Array(registry.tiles.length + 1).fill(1)\n\tif (!speeds)\n\t\tregistry.tiles.forEach((tile, index) => {\n\t\t\ttiles[index + 1] = tile.speed !== undefined && tile.speed >= 0 ? tile.speed : 1\n\t\t})\n\tspeeds = { tiles, layers: cellLayerSpeeds(registry), cellLayers: registry.cellLayers }\n\tTILE_SPEEDS.set(registry, speeds)\n\treturn speeds\n}\n\n/** The speed of each value of each layer of cells of a game that has one other than 1: the value's style's, else the layer's */\nfunction cellLayerSpeeds(registry: Registry): GroundSpeeds['layers'] {\n\tconst game = { cellLayers: registry.cellLayers, packs: registry.assembly?.rules.packs }\n\tconst layers: GroundSpeeds['layers'] = []\n\tfor (const def of registry.cellLayers) {\n\t\tconst ofLayer = def.speed !== undefined && def.speed >= 0 ? def.speed : 1\n\t\tconst speeds = new Float64Array(256).fill(1)\n\t\tlet stops: Uint8Array | undefined\n\t\tlet any = false\n\t\tfor (let value = 1; value < 256; value++) {\n\t\t\tconst style = foliageStyle(game, def.id, value)\n\t\t\tconst own = style?.speed\n\t\t\tspeeds[value] = own !== undefined && own >= 0 ? own : ofLayer\n\t\t\tif (speeds[value] !== 1) any = true\n\t\t\tif (style?.walkable === false) (stops ??= new Uint8Array(256))[value] = 1\n\t\t}\n\t\tif (any || stops) layers.push({ id: def.id, speeds, ...(stops && { stops }) })\n\t}\n\treturn layers\n}\n\n/**\n * How fast one on foot goes over a cell of the map, as a multiplier: the tile's `speed` times the speed of every\n * layer of cells that is not 0 there (its value's style's, `FoliageStyleDef.speed`, else the layer's `speed`); 1\n * where nothing says. Off the map, 1\n *\n * @beta\n */\nexport function groundSpeedOfCell(world: World, x: number, z: number): number {\n\treturn groundSpeedOn(world.registry, world.terrain, x, z)\n}\n\n/** `groundSpeedOfCell` of a game's ground before there is a world of it: what its navigation is cut with */\nexport function groundSpeedOn(registry: Registry, terrain: Terrain, x: number, z: number): number {\n\tconst column = Math.floor(x)\n\tconst row = Math.floor(z)\n\tif (column < 0 || row < 0 || column >= terrain.width || row >= terrain.depth) return 1\n\tconst cell = row * terrain.width + column\n\tconst { tiles, layers } = speedsOf(registry)\n\tlet speed = tiles[terrain.tiles[cell]] ?? 1\n\tfor (const { id, speeds } of layers) {\n\t\tconst value = terrain.cells[id]?.[cell]\n\t\tif (value) speed *= speeds[value]\n\t}\n\treturn speed\n}\n\n/**\n * `groundSpeedOn` as the navigation is cut with it: -1 where a value of a layer stops one on foot\n * (`FoliageStyleDef.walkable: false`, a thicket), which the ways go round as they go round a wall (`groundAreas.ts`)\n */\nexport function navigationSpeedOn(registry: Registry, terrain: Terrain, x: number, z: number): number {\n\tconst column = Math.floor(x)\n\tconst row = Math.floor(z)\n\tif (column < 0 || row < 0 || column >= terrain.width || row >= terrain.depth) return 1\n\tconst cell = row * terrain.width + column\n\tfor (const { id, stops } of speedsOf(registry).layers) if (stops?.[terrain.cells[id]?.[cell] ?? 0]) return -1\n\treturn groundSpeedOn(registry, terrain, x, z)\n}\n\n/**\n * How fast a unit goes where it stands, as a multiplier of its speed: the ground's for one on foot\n * (`groundSpeedOfCell`), 1 for what flies or sails\n *\n * @beta\n */\nexport function groundSpeedAt(world: World, entity: Entity): number {\n\tif (entity.flying || entity.def.naval) return 1\n\treturn groundSpeedOfCell(world, entity.pos.x, entity.pos.z)\n}\n\n/** Whether any of a game's ground slows or speeds one on foot: a tile, or a layer of cells or a value of one, with a speed of its own, or a value that stops one */\nexport function hasGroundSpeeds(registry: Registry): boolean {\n\treturn registry.tiles.some((tile) => tile.speed !== undefined && tile.speed >= 0 && tile.speed !== 1) || speedsOf(registry).layers.length > 0\n}\n\n/**\n * Whether a layer of cells of a game slows, speeds or stops one on foot somewhere: one whose changes in play the ways\n * weigh again. Of the game's layers as they are now (a style changed while it plays, `debug.cellStyles`, counts). Not a\n * state layer of grass (`foliageStateLayer`), which no game lists: what happens to grass does not cut the ways again\n */\nexport function slowsOnFoot(registry: Registry, layer: string): boolean {\n\tfor (const each of speedsOf(registry).layers) if (each.id === layer) return true\n\treturn false\n}\n\n/**\n * Whether a value of a layer of cells of a game stops one on foot (`FoliageStyleDef.walkable: false`, a thicket): a change\n * of it may make cells walkable or not, which the ways keep their distance from beyond the cells' own tile\n */\nexport function stopsOnFoot(registry: Registry, layer: string): boolean {\n\tfor (const each of speedsOf(registry).layers) if (each.id === layer) return !!each.stops\n\treturn false\n}\n"],"mappings":";;;AA8BA,IAAM,8BAAc,IAAI,QAA8B;AAEtD,SAAS,SAAS,UAAkC;CACnD,IAAI,SAAS,YAAY,IAAI,QAAQ;CACrC,IAAI,UAAU,OAAO,eAAe,SAAS,YAAY,OAAO;CAChE,MAAM,QAAQ,QAAQ,SAAS,IAAI,aAAa,SAAS,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;CACjF,IAAI,CAAC,QACJ,SAAS,MAAM,SAAS,MAAM,UAAU;EACvC,MAAM,QAAQ,KAAK,KAAK,UAAU,KAAA,KAAa,KAAK,SAAS,IAAI,KAAK,QAAQ;CAC/E,CAAC;CACF,SAAS;EAAE;EAAO,QAAQ,gBAAgB,QAAQ;EAAG,YAAY,SAAS;CAAW;CACrF,YAAY,IAAI,UAAU,MAAM;CAChC,OAAO;AACR;;AAGA,SAAS,gBAAgB,UAA4C;CACpE,MAAM,OAAO;EAAE,YAAY,SAAS;EAAY,OAAO,SAAS,UAAU,MAAM;CAAM;CACtF,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,OAAO,SAAS,YAAY;EACtC,MAAM,UAAU,IAAI,UAAU,KAAA,KAAa,IAAI,SAAS,IAAI,IAAI,QAAQ;EACxE,MAAM,0BAAS,IAAI,aAAa,GAAG,EAAA,CAAE,KAAK,CAAC;EAC3C,IAAI;EACJ,IAAI,MAAM;EACV,KAAK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