@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.
Files changed (951) hide show
  1. package/dist/abilities/amounts.d.ts +28 -0
  2. package/dist/abilities/amounts.js +74 -0
  3. package/dist/abilities/amounts.js.map +1 -0
  4. package/dist/abilities/buffs.d.ts +106 -6
  5. package/dist/abilities/buffs.js +443 -0
  6. package/dist/abilities/buffs.js.map +1 -0
  7. package/dist/abilities/castTold.d.ts +2 -0
  8. package/dist/abilities/castTold.js +66 -0
  9. package/dist/abilities/castTold.js.map +1 -0
  10. package/dist/abilities/chance.d.ts +38 -0
  11. package/dist/abilities/chance.js +77 -0
  12. package/dist/abilities/chance.js.map +1 -0
  13. package/dist/abilities/charges.d.ts +18 -0
  14. package/dist/abilities/charges.js +101 -0
  15. package/dist/abilities/charges.js.map +1 -0
  16. package/dist/abilities/control.d.ts +28 -0
  17. package/dist/abilities/control.js +113 -0
  18. package/dist/abilities/control.js.map +1 -0
  19. package/dist/abilities/dispel.js +51 -0
  20. package/dist/abilities/dispel.js.map +1 -0
  21. package/dist/abilities/effectFields.d.ts +1 -1
  22. package/dist/abilities/effectFields.js +676 -0
  23. package/dist/abilities/effectFields.js.map +1 -0
  24. package/dist/abilities/effectIndex.d.ts +27 -0
  25. package/dist/abilities/effectIndex.js +64 -0
  26. package/dist/abilities/effectIndex.js.map +1 -0
  27. package/dist/abilities/effects/buff.d.ts +9 -3
  28. package/dist/abilities/effects/buff.js +84 -0
  29. package/dist/abilities/effects/buff.js.map +1 -0
  30. package/dist/abilities/effects/conditions.d.ts +2 -0
  31. package/dist/abilities/effects/conditions.js +41 -0
  32. package/dist/abilities/effects/conditions.js.map +1 -0
  33. package/dist/abilities/effects/core.js +54 -0
  34. package/dist/abilities/effects/core.js.map +1 -0
  35. package/dist/abilities/effects/damage.d.ts +1 -1
  36. package/dist/abilities/effects/damage.js +43 -0
  37. package/dist/abilities/effects/damage.js.map +1 -0
  38. package/dist/abilities/effects/heal.d.ts +2 -2
  39. package/dist/abilities/effects/heal.js +51 -0
  40. package/dist/abilities/effects/heal.js.map +1 -0
  41. package/dist/abilities/effects/missile.d.ts +13 -1
  42. package/dist/abilities/effects/missile.js +104 -0
  43. package/dist/abilities/effects/missile.js.map +1 -0
  44. package/dist/abilities/effects/morph.d.ts +5 -0
  45. package/dist/abilities/effects/morph.js +43 -0
  46. package/dist/abilities/effects/morph.js.map +1 -0
  47. package/dist/abilities/effects/moves.d.ts +16 -4
  48. package/dist/abilities/effects/moves.js +212 -0
  49. package/dist/abilities/effects/moves.js.map +1 -0
  50. package/dist/abilities/effects/passives.d.ts +19 -9
  51. package/dist/abilities/effects/passives.js +131 -0
  52. package/dist/abilities/effects/passives.js.map +1 -0
  53. package/dist/abilities/effects/proxy.d.ts +5 -0
  54. package/dist/abilities/effects/proxy.js +60 -0
  55. package/dist/abilities/effects/proxy.js.map +1 -0
  56. package/dist/abilities/effects/sight.d.ts +2 -2
  57. package/dist/abilities/effects/sight.js +39 -0
  58. package/dist/abilities/effects/sight.js.map +1 -0
  59. package/dist/abilities/effects/spawn.d.ts +5 -2
  60. package/dist/abilities/effects/spawn.js +40 -0
  61. package/dist/abilities/effects/spawn.js.map +1 -0
  62. package/dist/abilities/effects/timed.d.ts +2 -2
  63. package/dist/abilities/effects/timed.js +96 -0
  64. package/dist/abilities/effects/timed.js.map +1 -0
  65. package/dist/abilities/effects/trade.d.ts +1 -1
  66. package/dist/abilities/effects/trade.js +25 -0
  67. package/dist/abilities/effects/trade.js.map +1 -0
  68. package/dist/abilities/effects.d.ts +97 -23
  69. package/dist/abilities/effects.js +860 -0
  70. package/dist/abilities/effects.js.map +1 -0
  71. package/dist/abilities/land.d.ts +38 -4
  72. package/dist/abilities/land.js +189 -0
  73. package/dist/abilities/land.js.map +1 -0
  74. package/dist/abilities/recast.d.ts +45 -0
  75. package/dist/abilities/recast.js +118 -0
  76. package/dist/abilities/recast.js.map +1 -0
  77. package/dist/abilities/scaled.js +40 -0
  78. package/dist/abilities/scaled.js.map +1 -0
  79. package/dist/abilities/screen.d.ts +6 -0
  80. package/dist/abilities/screen.js +83 -0
  81. package/dist/abilities/screen.js.map +1 -0
  82. package/dist/abilities/shapes.d.ts +66 -0
  83. package/dist/abilities/shapes.js +122 -0
  84. package/dist/abilities/shapes.js.map +1 -0
  85. package/dist/abilities/text.d.ts +14 -2
  86. package/dist/abilities/text.js +204 -0
  87. package/dist/abilities/text.js.map +1 -0
  88. package/dist/abilities/triggers.d.ts +98 -0
  89. package/dist/abilities/triggers.js +351 -0
  90. package/dist/abilities/triggers.js.map +1 -0
  91. package/dist/abilityChanges.d.ts +131 -0
  92. package/dist/abilityChanges.js +345 -0
  93. package/dist/abilityChanges.js.map +1 -0
  94. package/dist/ai/area.d.ts +4 -1
  95. package/dist/ai/brain.d.ts +4 -1
  96. package/dist/ai/brain.js +844 -0
  97. package/dist/ai/brain.js.map +1 -0
  98. package/dist/ai/budget.js +74 -0
  99. package/dist/ai/budget.js.map +1 -0
  100. package/dist/ai/checks.d.ts +9 -1
  101. package/dist/ai/checks.js +242 -0
  102. package/dist/ai/checks.js.map +1 -0
  103. package/dist/ai/computer.d.ts +11 -4
  104. package/dist/ai/computer.js +251 -0
  105. package/dist/ai/computer.js.map +1 -0
  106. package/dist/ai/defence.d.ts +4 -0
  107. package/dist/ai/defence.js +430 -0
  108. package/dist/ai/defence.js.map +1 -0
  109. package/dist/ai/define.d.ts +3 -2
  110. package/dist/ai/define.js +31 -0
  111. package/dist/ai/define.js.map +1 -0
  112. package/dist/ai/economy.d.ts +10 -7
  113. package/dist/ai/economy.js +780 -0
  114. package/dist/ai/economy.js.map +1 -0
  115. package/dist/ai/geometry.js +38 -0
  116. package/dist/ai/geometry.js.map +1 -0
  117. package/dist/ai/goals.d.ts +1 -0
  118. package/dist/ai/goals.js +560 -0
  119. package/dist/ai/goals.js.map +1 -0
  120. package/dist/ai/knowledge.d.ts +72 -7
  121. package/dist/ai/knowledge.js +804 -0
  122. package/dist/ai/knowledge.js.map +1 -0
  123. package/dist/ai/lanes.d.ts +10 -2
  124. package/dist/ai/lanes.js +715 -0
  125. package/dist/ai/lanes.js.map +1 -0
  126. package/dist/ai/melee/build.js +264 -0
  127. package/dist/ai/melee/build.js.map +1 -0
  128. package/dist/ai/melee/goals.d.ts +7 -0
  129. package/dist/ai/melee/goals.js +720 -0
  130. package/dist/ai/melee/goals.js.map +1 -0
  131. package/dist/ai/melee/heroes.js +68 -0
  132. package/dist/ai/melee/heroes.js.map +1 -0
  133. package/dist/ai/melee/index.d.ts +1 -1
  134. package/dist/ai/melee/index.js +51 -0
  135. package/dist/ai/melee/index.js.map +1 -0
  136. package/dist/ai/melee/production.js +29 -0
  137. package/dist/ai/melee/production.js.map +1 -0
  138. package/dist/ai/melee/surrender.js +64 -0
  139. package/dist/ai/melee/surrender.js.map +1 -0
  140. package/dist/ai/micro.d.ts +9 -0
  141. package/dist/ai/micro.js +1316 -0
  142. package/dist/ai/micro.js.map +1 -0
  143. package/dist/ai/mission.d.ts +9 -2
  144. package/dist/ai/mission.js +538 -0
  145. package/dist/ai/mission.js.map +1 -0
  146. package/dist/ai/missionRules.d.ts +1 -1
  147. package/dist/ai/missionRules.js +26 -0
  148. package/dist/ai/missionRules.js.map +1 -0
  149. package/dist/ai/module.d.ts +6 -2
  150. package/dist/ai/module.js +37 -0
  151. package/dist/ai/module.js.map +1 -0
  152. package/dist/ai/options.d.ts +3 -3
  153. package/dist/ai/plans/build.d.ts +20 -1
  154. package/dist/ai/plans/build.js +608 -0
  155. package/dist/ai/plans/build.js.map +1 -0
  156. package/dist/ai/plans/placement.d.ts +4 -1
  157. package/dist/ai/plans/placement.js +295 -0
  158. package/dist/ai/plans/placement.js.map +1 -0
  159. package/dist/ai/plans/plans.d.ts +9 -0
  160. package/dist/ai/plans/plans.js +110 -0
  161. package/dist/ai/plans/plans.js.map +1 -0
  162. package/dist/ai/plans/production.d.ts +14 -2
  163. package/dist/ai/plans/production.js +434 -0
  164. package/dist/ai/plans/production.js.map +1 -0
  165. package/dist/ai/plans/purse.d.ts +6 -3
  166. package/dist/ai/plans/purse.js +139 -0
  167. package/dist/ai/plans/purse.js.map +1 -0
  168. package/dist/ai/plans/tech.d.ts +6 -0
  169. package/dist/ai/plans/tech.js +122 -0
  170. package/dist/ai/plans/tech.js.map +1 -0
  171. package/dist/ai/profiles.d.ts +4 -4
  172. package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
  173. package/dist/ai/profiles.js.map +1 -0
  174. package/dist/ai/reach.js +54 -0
  175. package/dist/ai/reach.js.map +1 -0
  176. package/dist/ai/report.d.ts +8 -0
  177. package/dist/ai/report.js +87 -0
  178. package/dist/ai/report.js.map +1 -0
  179. package/dist/ai/roles.d.ts +4 -0
  180. package/dist/ai/roles.js +207 -0
  181. package/dist/ai/roles.js.map +1 -0
  182. package/dist/ai/rules.d.ts +8 -2
  183. package/dist/ai/rules.js +416 -0
  184. package/dist/ai/rules.js.map +1 -0
  185. package/dist/ai/scouting.d.ts +6 -0
  186. package/dist/ai/scouting.js +324 -0
  187. package/dist/ai/scouting.js.map +1 -0
  188. package/dist/ai/settings.js +99 -0
  189. package/dist/ai/settings.js.map +1 -0
  190. package/dist/ai/squads.d.ts +21 -2
  191. package/dist/ai/squads.js +916 -0
  192. package/dist/ai/squads.js.map +1 -0
  193. package/dist/ai/strength.js +320 -0
  194. package/dist/ai/strength.js.map +1 -0
  195. package/dist/ai/task.d.ts +3 -1
  196. package/dist/ai/task.js +17 -0
  197. package/dist/ai/task.js.map +1 -0
  198. package/dist/ai/tasks/attack.js +24 -0
  199. package/dist/ai/tasks/attack.js.map +1 -0
  200. package/dist/ai/tasks/capture.d.ts +3 -3
  201. package/dist/ai/tasks/capture.js +37 -0
  202. package/dist/ai/tasks/capture.js.map +1 -0
  203. package/dist/ai/tasks/creep.js +29 -0
  204. package/dist/ai/tasks/creep.js.map +1 -0
  205. package/dist/ai/tasks/defend.js +61 -0
  206. package/dist/ai/tasks/defend.js.map +1 -0
  207. package/dist/ai/tasks/drop.js +81 -0
  208. package/dist/ai/tasks/drop.js.map +1 -0
  209. package/dist/ai/tasks/escort.js +59 -0
  210. package/dist/ai/tasks/escort.js.map +1 -0
  211. package/dist/ai/tasks/gather.js +48 -0
  212. package/dist/ai/tasks/gather.js.map +1 -0
  213. package/dist/ai/tasks/harass.js +39 -0
  214. package/dist/ai/tasks/harass.js.map +1 -0
  215. package/dist/ai/tasks/hold.js +32 -0
  216. package/dist/ai/tasks/hold.js.map +1 -0
  217. package/dist/ai/tasks/index.js +34 -0
  218. package/dist/ai/tasks/index.js.map +1 -0
  219. package/dist/ai/tasks/move.js +26 -0
  220. package/dist/ai/tasks/move.js.map +1 -0
  221. package/dist/ai/tasks/patrol.js +59 -0
  222. package/dist/ai/tasks/patrol.js.map +1 -0
  223. package/dist/ai/tasks/retreat.js +28 -0
  224. package/dist/ai/tasks/retreat.js.map +1 -0
  225. package/dist/ai/tasks/scout.js +73 -0
  226. package/dist/ai/tasks/scout.js.map +1 -0
  227. package/dist/ai/tasks/shared.d.ts +1 -1
  228. package/dist/ai/tasks/shared.js +137 -0
  229. package/dist/ai/tasks/shared.js.map +1 -0
  230. package/dist/ai/team.d.ts +18 -1
  231. package/dist/ai/team.js +492 -0
  232. package/dist/ai/team.js.map +1 -0
  233. package/dist/ai/threat.d.ts +6 -0
  234. package/dist/ai/threat.js +206 -0
  235. package/dist/ai/threat.js.map +1 -0
  236. package/dist/ai/view.d.ts +21 -7
  237. package/dist/ai/view.js +677 -0
  238. package/dist/ai/view.js.map +1 -0
  239. package/dist/ai/waves.d.ts +6 -0
  240. package/dist/ai/waves.js +410 -0
  241. package/dist/ai/waves.js.map +1 -0
  242. package/dist/ai.js +54 -6239
  243. package/dist/aiTesting.d.ts +6 -3
  244. package/dist/aiTesting.js +229 -0
  245. package/dist/aiTesting.js.map +1 -0
  246. package/dist/areas.d.ts +4 -1
  247. package/dist/areas.js +295 -0
  248. package/dist/areas.js.map +1 -0
  249. package/dist/attacks.d.ts +3 -3
  250. package/dist/attacks.js +127 -0
  251. package/dist/attacks.js.map +1 -0
  252. package/dist/burning.d.ts +267 -0
  253. package/dist/burning.js +795 -0
  254. package/dist/burning.js.map +1 -0
  255. package/dist/bytes.js +21 -0
  256. package/dist/bytes.js.map +1 -0
  257. package/dist/callings.d.ts +71 -0
  258. package/dist/callings.js +157 -0
  259. package/dist/callings.js.map +1 -0
  260. package/dist/cameraOrders.d.ts +78 -0
  261. package/dist/cameraOrders.js +114 -0
  262. package/dist/cameraOrders.js.map +1 -0
  263. package/dist/camps.d.ts +70 -4
  264. package/dist/camps.js +501 -0
  265. package/dist/camps.js.map +1 -0
  266. package/dist/capture.d.ts +15 -3
  267. package/dist/capture.js +304 -0
  268. package/dist/capture.js.map +1 -0
  269. package/dist/cellLayers.d.ts +78 -13
  270. package/dist/cellLayers.js +275 -0
  271. package/dist/cellLayers.js.map +1 -0
  272. package/dist/cellPatches.d.ts +24 -0
  273. package/dist/cellPatches.js +73 -0
  274. package/dist/cellPatches.js.map +1 -0
  275. package/dist/cinematics.d.ts +10 -5
  276. package/dist/cinematics.js +161 -0
  277. package/dist/cinematics.js.map +1 -0
  278. package/dist/clock.d.ts +2 -2
  279. package/dist/clock.js +78 -0
  280. package/dist/clock.js.map +1 -0
  281. package/dist/commands.d.ts +36 -4
  282. package/dist/commands.js +636 -0
  283. package/dist/commands.js.map +1 -0
  284. package/dist/components.d.ts +31 -10
  285. package/dist/components.js +74 -0
  286. package/dist/components.js.map +1 -0
  287. package/dist/computers.d.ts +4 -4
  288. package/dist/computers.js +194 -0
  289. package/dist/computers.js.map +1 -0
  290. package/dist/concealment.d.ts +25 -2
  291. package/dist/concealment.js +409 -0
  292. package/dist/concealment.js.map +1 -0
  293. package/dist/coreComponents.js +130 -0
  294. package/dist/coreComponents.js.map +1 -0
  295. package/dist/createGame.d.ts +306 -0
  296. package/dist/createGame.js +405 -0
  297. package/dist/createGame.js.map +1 -0
  298. package/dist/dashing.d.ts +18 -2
  299. package/dist/dashing.js +41 -0
  300. package/dist/dashing.js.map +1 -0
  301. package/dist/debug.d.ts +8 -0
  302. package/dist/debug.js +5 -3
  303. package/dist/debug2.js +76 -0
  304. package/dist/debug2.js.map +1 -0
  305. package/dist/debugCommands.d.ts +6 -6
  306. package/dist/debugCommands.js +537 -0
  307. package/dist/debugCommands.js.map +1 -0
  308. package/dist/debugging.d.ts +1 -0
  309. package/dist/defaultSets.d.ts +183 -0
  310. package/dist/defaultSets.js +216 -0
  311. package/dist/defaultSets.js.map +1 -0
  312. package/dist/definitions.d.ts +6 -0
  313. package/dist/definitions.js +78 -0
  314. package/dist/definitions.js.map +1 -0
  315. package/dist/defs.d.ts +1895 -165
  316. package/dist/defs.js +380 -0
  317. package/dist/defs.js.map +1 -0
  318. package/dist/denying.d.ts +4 -4
  319. package/dist/denying.js +106 -0
  320. package/dist/denying.js.map +1 -0
  321. package/dist/destructibles.d.ts +2 -2
  322. package/dist/destructibles.js +36 -0
  323. package/dist/destructibles.js.map +1 -0
  324. package/dist/determinism.d.ts +4 -4
  325. package/dist/determinism.js +247 -0
  326. package/dist/determinism.js.map +1 -0
  327. package/dist/dialog.d.ts +17 -2
  328. package/dist/dialog.js +108 -0
  329. package/dist/dialog.js.map +1 -0
  330. package/dist/effectRefs.js +28 -0
  331. package/dist/effectRefs.js.map +1 -0
  332. package/dist/effects.d.ts +27 -11
  333. package/dist/effects.js +110 -0
  334. package/dist/effects.js.map +1 -0
  335. package/dist/endings.d.ts +1 -1
  336. package/dist/endings.js +78 -0
  337. package/dist/endings.js.map +1 -0
  338. package/dist/engagement.d.ts +40 -6
  339. package/dist/engagement.js +530 -0
  340. package/dist/engagement.js.map +1 -0
  341. package/dist/engineEvents.d.ts +72 -9
  342. package/dist/engineEvents.js +520 -0
  343. package/dist/engineEvents.js.map +1 -0
  344. package/dist/entity.d.ts +275 -26
  345. package/dist/entity.js +441 -0
  346. package/dist/entity.js.map +1 -0
  347. package/dist/entityIndex.d.ts +10 -3
  348. package/dist/entityIndex.js +149 -0
  349. package/dist/entityIndex.js.map +1 -0
  350. package/dist/errors.d.ts +6 -2
  351. package/dist/errors.js +59 -0
  352. package/dist/errors.js.map +1 -0
  353. package/dist/events.d.ts +11 -5
  354. package/dist/events.js +158 -0
  355. package/dist/events.js.map +1 -0
  356. package/dist/exactMath.js +273 -0
  357. package/dist/exactMath.js.map +1 -0
  358. package/dist/features.d.ts +1 -1
  359. package/dist/features.js +127 -0
  360. package/dist/features.js.map +1 -0
  361. package/dist/fields.d.ts +25 -5
  362. package/dist/fields.js +140 -0
  363. package/dist/fields.js.map +1 -0
  364. package/dist/fixture.d.ts +3 -3
  365. package/dist/fixture.js +512 -0
  366. package/dist/fixture.js.map +1 -0
  367. package/dist/fog.d.ts +26 -3
  368. package/dist/fog.js +333 -0
  369. package/dist/fog.js.map +1 -0
  370. package/dist/foliage.d.ts +476 -0
  371. package/dist/foliage.js +1478 -0
  372. package/dist/foliage.js.map +1 -0
  373. package/dist/foliageDebug.d.ts +57 -0
  374. package/dist/foliageDebug.js +172 -0
  375. package/dist/foliageDebug.js.map +1 -0
  376. package/dist/foliageRegrowth.d.ts +20 -0
  377. package/dist/foliageRegrowth.js +332 -0
  378. package/dist/foliageRegrowth.js.map +1 -0
  379. package/dist/formState.d.ts +67 -0
  380. package/dist/formState.js +65 -0
  381. package/dist/formState.js.map +1 -0
  382. package/dist/formation.d.ts +46 -8
  383. package/dist/formation.js +297 -0
  384. package/dist/formation.js.map +1 -0
  385. package/dist/forms.d.ts +58 -0
  386. package/dist/forms.js +146 -0
  387. package/dist/forms.js.map +1 -0
  388. package/dist/friendlyFire.d.ts +2 -2
  389. package/dist/friendlyFire.js +37 -0
  390. package/dist/friendlyFire.js.map +1 -0
  391. package/dist/game.d.ts +141 -48
  392. package/dist/game.js +834 -0
  393. package/dist/game.js.map +1 -0
  394. package/dist/gameData.d.ts +96 -22
  395. package/dist/gameData.js +1690 -0
  396. package/dist/gameData.js.map +1 -0
  397. package/dist/gameFiles.d.ts +3 -3
  398. package/dist/gameFiles.js +14 -0
  399. package/dist/gameFiles.js.map +1 -0
  400. package/dist/gates.js +92 -0
  401. package/dist/gates.js.map +1 -0
  402. package/dist/generate.d.ts +28 -1
  403. package/dist/generate.js +1062 -0
  404. package/dist/generate.js.map +1 -0
  405. package/dist/generateWorker.d.ts +7 -3
  406. package/dist/generateWorker.js +86 -0
  407. package/dist/generateWorker.js.map +1 -0
  408. package/dist/grid.d.ts +9 -0
  409. package/dist/grid.js +102 -0
  410. package/dist/grid.js.map +1 -0
  411. package/dist/ground.d.ts +17 -1
  412. package/dist/ground.js +375 -0
  413. package/dist/ground.js.map +1 -0
  414. package/dist/groundObjects.d.ts +70 -0
  415. package/dist/groundObjects.js +371 -0
  416. package/dist/groundObjects.js.map +1 -0
  417. package/dist/groundSpeed.d.ts +20 -3
  418. package/dist/groundSpeed.js +117 -0
  419. package/dist/groundSpeed.js.map +1 -0
  420. package/dist/hero.d.ts +126 -10
  421. package/dist/hero.js +432 -0
  422. package/dist/hero.js.map +1 -0
  423. package/dist/holds.d.ts +94 -0
  424. package/dist/holds.js +305 -0
  425. package/dist/holds.js.map +1 -0
  426. package/dist/home.d.ts +1 -1
  427. package/dist/home.js +30 -0
  428. package/dist/home.js.map +1 -0
  429. package/dist/hooks.d.ts +339 -57
  430. package/dist/hooks.js +105 -0
  431. package/dist/hooks.js.map +1 -0
  432. package/dist/hotReload.d.ts +6 -5
  433. package/dist/hotReload.js +145 -0
  434. package/dist/hotReload.js.map +1 -0
  435. package/dist/ids.d.ts +3 -3
  436. package/dist/ids.js +30 -0
  437. package/dist/ids.js.map +1 -0
  438. package/dist/idsFile.d.ts +36 -0
  439. package/dist/idsFile.js +134 -0
  440. package/dist/idsFile.js.map +1 -0
  441. package/dist/index.d.ts +105 -68
  442. package/dist/index.js +194 -4701
  443. package/dist/inspect.d.ts +29 -2
  444. package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
  445. package/dist/inspect.js.map +1 -0
  446. package/dist/inventory.d.ts +14 -1
  447. package/dist/inventory.js +84 -0
  448. package/dist/inventory.js.map +1 -0
  449. package/dist/items.d.ts +136 -8
  450. package/dist/items.js +585 -0
  451. package/dist/items.js.map +1 -0
  452. package/dist/lanes.d.ts +12 -3
  453. package/dist/lanes.js +496 -0
  454. package/dist/lanes.js.map +1 -0
  455. package/dist/life.d.ts +6 -2
  456. package/dist/life.js +287 -0
  457. package/dist/life.js.map +1 -0
  458. package/dist/log.d.ts +26 -3
  459. package/dist/log.js +192 -0
  460. package/dist/log.js.map +1 -0
  461. package/dist/manaBurn.d.ts +2 -2
  462. package/dist/manaBurn.js +75 -0
  463. package/dist/manaBurn.js.map +1 -0
  464. package/dist/map/file.d.ts +56 -3
  465. package/dist/map/file.js +264 -0
  466. package/dist/map/file.js.map +1 -0
  467. package/dist/map/images.js +61 -0
  468. package/dist/map/images.js.map +1 -0
  469. package/dist/map/look.d.ts +1 -1
  470. package/dist/map/look.js +30 -0
  471. package/dist/map/look.js.map +1 -0
  472. package/dist/map/pathProfile.js +183 -0
  473. package/dist/map/pathProfile.js.map +1 -0
  474. package/dist/map/resize.d.ts +4 -0
  475. package/dist/map/resize.js +136 -0
  476. package/dist/map/resize.js.map +1 -0
  477. package/dist/map/schema.js +257 -0
  478. package/dist/map/schema.js.map +1 -0
  479. package/dist/map/terrain.js +214 -0
  480. package/dist/map/terrain.js.map +1 -0
  481. package/dist/map/types.d.ts +92 -13
  482. package/dist/map/types.js +251 -0
  483. package/dist/map/types.js.map +1 -0
  484. package/dist/mapCheck/cells.js +94 -0
  485. package/dist/mapCheck/cells.js.map +1 -0
  486. package/dist/mapCheck/rules/foliage.d.ts +9 -0
  487. package/dist/mapCheck/rules/foliage.js +83 -0
  488. package/dist/mapCheck/rules/foliage.js.map +1 -0
  489. package/dist/mapCheck/rules/names.js +39 -0
  490. package/dist/mapCheck/rules/names.js.map +1 -0
  491. package/dist/mapCheck/rules/objects.d.ts +1 -1
  492. package/dist/mapCheck/rules/objects.js +56 -0
  493. package/dist/mapCheck/rules/objects.js.map +1 -0
  494. package/dist/mapCheck/rules/paths.js +32 -0
  495. package/dist/mapCheck/rules/paths.js.map +1 -0
  496. package/dist/mapCheck/rules/players.js +20 -0
  497. package/dist/mapCheck/rules/players.js.map +1 -0
  498. package/dist/mapCheck/rules/races.js +56 -0
  499. package/dist/mapCheck/rules/races.js.map +1 -0
  500. package/dist/mapCheck/rules/random.js +47 -0
  501. package/dist/mapCheck/rules/random.js.map +1 -0
  502. package/dist/mapCheck/rules/regions.js +30 -0
  503. package/dist/mapCheck/rules/regions.js.map +1 -0
  504. package/dist/mapCheck/rules/targets.js +31 -0
  505. package/dist/mapCheck/rules/targets.js.map +1 -0
  506. package/dist/mapCheck/rules/walking.js +45 -0
  507. package/dist/mapCheck/rules/walking.js.map +1 -0
  508. package/dist/mapCheck.d.ts +2 -2
  509. package/dist/mapCheck.js +63 -0
  510. package/dist/mapCheck.js.map +1 -0
  511. package/dist/mapFields.d.ts +25 -2
  512. package/dist/mapFields.js +134 -0
  513. package/dist/mapFields.js.map +1 -0
  514. package/dist/mapFile.js +176 -0
  515. package/dist/mapFile.js.map +1 -0
  516. package/dist/mapMeasure.d.ts +8 -0
  517. package/dist/mapMeasure.js +283 -0
  518. package/dist/mapMeasure.js.map +1 -0
  519. package/dist/mapMerge.d.ts +1 -0
  520. package/dist/mapMerge.js +172 -0
  521. package/dist/mapMerge.js.map +1 -0
  522. package/dist/mapObjectives.js +138 -0
  523. package/dist/mapObjectives.js.map +1 -0
  524. package/dist/mapObjects.js +80 -0
  525. package/dist/mapObjects.js.map +1 -0
  526. package/dist/math.d.ts +37 -7
  527. package/dist/math.js +155 -0
  528. package/dist/math.js.map +1 -0
  529. package/dist/messages.d.ts +71 -4
  530. package/dist/messages.js +29 -0
  531. package/dist/messages.js.map +1 -0
  532. package/dist/missionRules.d.ts +10 -2
  533. package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
  534. package/dist/missionRules.js.map +1 -0
  535. package/dist/mods.d.ts +39 -20
  536. package/dist/mods.js +271 -0
  537. package/dist/mods.js.map +1 -0
  538. package/dist/moves.d.ts +87 -0
  539. package/dist/moves.js +539 -0
  540. package/dist/moves.js.map +1 -0
  541. package/dist/names.d.ts +7 -0
  542. package/dist/names.js +122 -0
  543. package/dist/names.js.map +1 -0
  544. package/dist/navigation/agentParams.js +14 -0
  545. package/dist/navigation/agentParams.js.map +1 -0
  546. package/dist/navigation/air.d.ts +7 -3
  547. package/dist/navigation/air.js +401 -0
  548. package/dist/navigation/air.js.map +1 -0
  549. package/dist/navigation/builds.d.ts +34 -2
  550. package/dist/navigation/builds.js +287 -0
  551. package/dist/navigation/builds.js.map +1 -0
  552. package/dist/navigation/groundAreas.d.ts +59 -1
  553. package/dist/navigation/groundAreas.js +407 -0
  554. package/dist/navigation/groundAreas.js.map +1 -0
  555. package/dist/navigation/navigation.d.ts +98 -9
  556. package/dist/navigation/recast.d.ts +194 -18
  557. package/dist/navigation/recast.js +1379 -0
  558. package/dist/navigation/recast.js.map +1 -0
  559. package/dist/navigation/sidePaths.d.ts +8 -3
  560. package/dist/navigation/sidePaths.js +241 -0
  561. package/dist/navigation/sidePaths.js.map +1 -0
  562. package/dist/navigation/sized.js +243 -0
  563. package/dist/navigation/sized.js.map +1 -0
  564. package/dist/nearest.js +32 -0
  565. package/dist/nearest.js.map +1 -0
  566. package/dist/noise.js +59 -0
  567. package/dist/noise.js.map +1 -0
  568. package/dist/objectives.d.ts +12 -3
  569. package/dist/objectives.js +144 -0
  570. package/dist/objectives.js.map +1 -0
  571. package/dist/orders/basic.d.ts +5 -5
  572. package/dist/orders/basic.js +417 -0
  573. package/dist/orders/basic.js.map +1 -0
  574. package/dist/orders/build.js +278 -0
  575. package/dist/orders/build.js.map +1 -0
  576. package/dist/orders/cast.d.ts +13 -3
  577. package/dist/orders/cast.js +558 -0
  578. package/dist/orders/cast.js.map +1 -0
  579. package/dist/orders/facts.js +16 -0
  580. package/dist/orders/facts.js.map +1 -0
  581. package/dist/orders/harvest.d.ts +21 -5
  582. package/dist/orders/harvest.js +540 -0
  583. package/dist/orders/harvest.js.map +1 -0
  584. package/dist/orders/idle.d.ts +3 -1
  585. package/dist/orders/idle.js +234 -0
  586. package/dist/orders/idle.js.map +1 -0
  587. package/dist/orders/items.js +92 -0
  588. package/dist/orders/items.js.map +1 -0
  589. package/dist/orders/queue.js +108 -0
  590. package/dist/orders/queue.js.map +1 -0
  591. package/dist/orders/waiting.d.ts +39 -0
  592. package/dist/orders/waiting.js +149 -0
  593. package/dist/orders/waiting.js.map +1 -0
  594. package/dist/pack.schema.js +13 -0
  595. package/dist/pack.schema.js.map +1 -0
  596. package/dist/pack.schema.json +7622 -841
  597. package/dist/packs/director/index.d.ts +13 -5
  598. package/dist/packs/director/index.js +204 -0
  599. package/dist/packs/director/index.js.map +1 -0
  600. package/dist/packs/heroes/campaign.d.ts +3 -2
  601. package/dist/packs/heroes/campaign.js +241 -0
  602. package/dist/packs/heroes/campaign.js.map +1 -0
  603. package/dist/packs/heroes/carry.d.ts +6 -0
  604. package/dist/packs/heroes/carry.js +112 -0
  605. package/dist/packs/heroes/carry.js.map +1 -0
  606. package/dist/packs/heroes/commands.js +115 -0
  607. package/dist/packs/heroes/commands.js.map +1 -0
  608. package/dist/packs/heroes/fallen.d.ts +43 -0
  609. package/dist/packs/heroes/fallen.js +61 -0
  610. package/dist/packs/heroes/fallen.js.map +1 -0
  611. package/dist/packs/heroes/hire.js +60 -0
  612. package/dist/packs/heroes/hire.js.map +1 -0
  613. package/dist/packs/heroes/index.d.ts +7 -6
  614. package/dist/packs/heroes/index.js +130 -0
  615. package/dist/packs/heroes/index.js.map +1 -0
  616. package/dist/packs/heroes/loop.d.ts +95 -0
  617. package/dist/packs/heroes/loop.js +250 -0
  618. package/dist/packs/heroes/loop.js.map +1 -0
  619. package/dist/packs/heroes/making.d.ts +6 -3
  620. package/dist/packs/heroes/making.js +55 -0
  621. package/dist/packs/heroes/making.js.map +1 -0
  622. package/dist/packs/heroes/respawn.d.ts +3 -3
  623. package/dist/packs/heroes/respawn.js +87 -0
  624. package/dist/packs/heroes/respawn.js.map +1 -0
  625. package/dist/packs/heroes/sets.d.ts +32 -0
  626. package/dist/packs/heroes/sets.js +51 -0
  627. package/dist/packs/heroes/sets.js.map +1 -0
  628. package/dist/packs/heroes/spells.d.ts +16 -0
  629. package/dist/packs/heroes/spells.js +269 -0
  630. package/dist/packs/heroes/spells.js.map +1 -0
  631. package/dist/packs/items/defaults.d.ts +43 -0
  632. package/dist/packs/items/defaults.js +1504 -0
  633. package/dist/packs/items/defaults.js.map +1 -0
  634. package/dist/packs/items/index.d.ts +27 -0
  635. package/dist/packs/items/index.js +214 -0
  636. package/dist/packs/items/index.js.map +1 -0
  637. package/dist/packs/moba/index.d.ts +3 -3
  638. package/dist/packs/moba/index.js +174 -0
  639. package/dist/packs/moba/index.js.map +1 -0
  640. package/dist/packs/pack.d.ts +15 -15
  641. package/dist/packs/pack.js +14 -0
  642. package/dist/packs/pack.js.map +1 -0
  643. package/dist/packs.d.ts +15 -7
  644. package/dist/packs.js +222 -0
  645. package/dist/packs.js.map +1 -0
  646. package/dist/paths.d.ts +2 -0
  647. package/dist/paths.js +109 -0
  648. package/dist/paths.js.map +1 -0
  649. package/dist/plain.js +57 -0
  650. package/dist/plain.js.map +1 -0
  651. package/dist/player.d.ts +33 -10
  652. package/dist/player.js +159 -0
  653. package/dist/player.js.map +1 -0
  654. package/dist/portals.d.ts +1 -1
  655. package/dist/portals.js +194 -0
  656. package/dist/portals.js.map +1 -0
  657. package/dist/prefabs.d.ts +25 -2
  658. package/dist/prefabs.js +239 -0
  659. package/dist/prefabs.js.map +1 -0
  660. package/dist/presetBuildings.js +58 -0
  661. package/dist/presetBuildings.js.map +1 -0
  662. package/dist/presetFoliage.d.ts +27 -0
  663. package/dist/presetFoliage.js +98 -0
  664. package/dist/presetFoliage.js.map +1 -0
  665. package/dist/presetGround.js +65 -0
  666. package/dist/presetGround.js.map +1 -0
  667. package/dist/proxies.d.ts +12 -0
  668. package/dist/proxies.js +79 -0
  669. package/dist/proxies.js.map +1 -0
  670. package/dist/query.d.ts +56 -0
  671. package/dist/query.js +88 -0
  672. package/dist/query.js.map +1 -0
  673. package/dist/races.d.ts +15 -14
  674. package/dist/races.js +172 -0
  675. package/dist/races.js.map +1 -0
  676. package/dist/randomGroups.js +91 -0
  677. package/dist/randomGroups.js.map +1 -0
  678. package/dist/registry.d.ts +117 -53
  679. package/dist/registry.js +323 -0
  680. package/dist/registry.js.map +1 -0
  681. package/dist/remains.d.ts +11 -9
  682. package/dist/remains.js +188 -0
  683. package/dist/remains.js.map +1 -0
  684. package/dist/replication.d.ts +12 -7
  685. package/dist/replication.js +100 -0
  686. package/dist/replication.js.map +1 -0
  687. package/dist/rng.d.ts +2 -0
  688. package/dist/rng.js +40 -0
  689. package/dist/rng.js.map +1 -0
  690. package/dist/rules.d.ts +186 -99
  691. package/dist/rules.js +179 -0
  692. package/dist/rules.js.map +1 -0
  693. package/dist/rulesCheck.d.ts +5 -4
  694. package/dist/rulesCheck.js +693 -0
  695. package/dist/rulesCheck.js.map +1 -0
  696. package/dist/runes.d.ts +2 -2
  697. package/dist/runes.js +80 -0
  698. package/dist/runes.js.map +1 -0
  699. package/dist/save.d.ts +37 -12
  700. package/dist/save.js +532 -0
  701. package/dist/save.js.map +1 -0
  702. package/dist/scenario.d.ts +2 -2
  703. package/dist/scenario.js +99 -0
  704. package/dist/scenario.js.map +1 -0
  705. package/dist/scheduler.d.ts +3 -0
  706. package/dist/scheduler.js +156 -0
  707. package/dist/scheduler.js.map +1 -0
  708. package/dist/score.d.ts +19 -19
  709. package/dist/score.js +709 -0
  710. package/dist/score.js.map +1 -0
  711. package/dist/sequences.d.ts +10 -6
  712. package/dist/sequences.js +206 -0
  713. package/dist/sequences.js.map +1 -0
  714. package/dist/server/doorman.js +154 -0
  715. package/dist/server/doorman.js.map +1 -0
  716. package/dist/server/gameServer.d.ts +16 -1
  717. package/dist/server/gameServer.js +643 -0
  718. package/dist/server/gameServer.js.map +1 -0
  719. package/dist/server/index.d.ts +1 -1
  720. package/dist/server/lobby.js +199 -0
  721. package/dist/server/lobby.js.map +1 -0
  722. package/dist/server/log.js +18 -0
  723. package/dist/server/log.js.map +1 -0
  724. package/dist/server/match.js +267 -0
  725. package/dist/server/match.js.map +1 -0
  726. package/dist/server/mode.d.ts +18 -9
  727. package/dist/server/mode.js +220 -0
  728. package/dist/server/mode.js.map +1 -0
  729. package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
  730. package/dist/server/navigation-worker.js.map +1 -0
  731. package/dist/server/navigation.js +39 -0
  732. package/dist/server/navigation.js.map +1 -0
  733. package/dist/server/ops.d.ts +4 -0
  734. package/dist/server/ops.js +137 -0
  735. package/dist/server/ops.js.map +1 -0
  736. package/dist/server/packs.d.ts +3 -3
  737. package/dist/server/packs.js +32 -0
  738. package/dist/server/packs.js.map +1 -0
  739. package/dist/server/ratings.d.ts +5 -0
  740. package/dist/server/ratings.js +104 -0
  741. package/dist/server/ratings.js.map +1 -0
  742. package/dist/server/relay.d.ts +12 -2
  743. package/dist/server/relay.js +144 -0
  744. package/dist/server/relay.js.map +1 -0
  745. package/dist/server/rooms.d.ts +9 -2
  746. package/dist/server/rooms.js +442 -0
  747. package/dist/server/rooms.js.map +1 -0
  748. package/dist/server/seat.js +116 -0
  749. package/dist/server/seat.js.map +1 -0
  750. package/dist/server/seatSettings.d.ts +3 -3
  751. package/dist/server/seatSettings.js +63 -0
  752. package/dist/server/seatSettings.js.map +1 -0
  753. package/dist/server/secret.js +13 -0
  754. package/dist/server/secret.js.map +1 -0
  755. package/dist/server/start.d.ts +13 -6
  756. package/dist/server/start.js +76 -0
  757. package/dist/server/start.js.map +1 -0
  758. package/dist/server/websocket.d.ts +9 -1
  759. package/dist/server/websocket.js +306 -0
  760. package/dist/server/websocket.js.map +1 -0
  761. package/dist/server.js +15 -2861
  762. package/dist/session/can.js +26 -0
  763. package/dist/session/can.js.map +1 -0
  764. package/dist/session/commandReplay.d.ts +8 -2
  765. package/dist/session/commandReplay.js +293 -0
  766. package/dist/session/commandReplay.js.map +1 -0
  767. package/dist/session/debug.js +151 -0
  768. package/dist/session/debug.js.map +1 -0
  769. package/dist/session/delay.js +62 -0
  770. package/dist/session/delay.js.map +1 -0
  771. package/dist/session/delta.d.ts +14 -1
  772. package/dist/session/delta.js +407 -0
  773. package/dist/session/delta.js.map +1 -0
  774. package/dist/session/entityState.js +415 -0
  775. package/dist/session/entityState.js.map +1 -0
  776. package/dist/session/local.d.ts +47 -5
  777. package/dist/session/local.js +670 -0
  778. package/dist/session/local.js.map +1 -0
  779. package/dist/session/memory.d.ts +20 -2
  780. package/dist/session/memory.js +131 -0
  781. package/dist/session/memory.js.map +1 -0
  782. package/dist/session/protocol.d.ts +325 -31
  783. package/dist/session/protocol.js +55 -0
  784. package/dist/session/protocol.js.map +1 -0
  785. package/dist/session/remote.d.ts +74 -12
  786. package/dist/session/remote.js +1394 -0
  787. package/dist/session/remote.js.map +1 -0
  788. package/dist/session/replay.d.ts +11 -2
  789. package/dist/session/replay.js +160 -0
  790. package/dist/session/replay.js.map +1 -0
  791. package/dist/session/seed.js +12 -0
  792. package/dist/session/seed.js.map +1 -0
  793. package/dist/session/share.d.ts +5 -1
  794. package/dist/session/share.js +94 -0
  795. package/dist/session/share.js.map +1 -0
  796. package/dist/session/socket.d.ts +1 -1
  797. package/dist/session/socket.js +29 -0
  798. package/dist/session/socket.js.map +1 -0
  799. package/dist/session/wire.d.ts +5 -0
  800. package/dist/session/wire.js +84 -0
  801. package/dist/session/wire.js.map +1 -0
  802. package/dist/session/worker.d.ts +77 -12
  803. package/dist/session/worker.js +499 -0
  804. package/dist/session/worker.js.map +1 -0
  805. package/dist/shared.d.ts +31 -5
  806. package/dist/shared.js +166 -0
  807. package/dist/shared.js.map +1 -0
  808. package/dist/sides.d.ts +9 -3
  809. package/dist/sides.js +149 -0
  810. package/dist/sides.js.map +1 -0
  811. package/dist/sight.js +85 -0
  812. package/dist/sight.js.map +1 -0
  813. package/dist/simulate-worker.js +1 -1
  814. package/dist/simulate.d.ts +12 -8
  815. package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
  816. package/dist/simulate.js.map +1 -0
  817. package/dist/smart.js +77 -0
  818. package/dist/smart.js.map +1 -0
  819. package/dist/spatial.d.ts +32 -16
  820. package/dist/spatial.js +234 -0
  821. package/dist/spatial.js.map +1 -0
  822. package/dist/spawning.d.ts +1 -0
  823. package/dist/spawning.js +224 -0
  824. package/dist/spawning.js.map +1 -0
  825. package/dist/stances.d.ts +6 -3
  826. package/dist/stances.js +169 -0
  827. package/dist/stances.js.map +1 -0
  828. package/dist/start.d.ts +10 -10
  829. package/dist/start.js +75 -0
  830. package/dist/start.js.map +1 -0
  831. package/dist/stats.d.ts +42 -16
  832. package/dist/stats.js +290 -0
  833. package/dist/stats.js.map +1 -0
  834. package/dist/summoned.d.ts +52 -0
  835. package/dist/summoned.js +38 -0
  836. package/dist/summoned.js.map +1 -0
  837. package/dist/summons.d.ts +10 -13
  838. package/dist/summons.js +271 -0
  839. package/dist/summons.js.map +1 -0
  840. package/dist/systems/abilities.js +224 -0
  841. package/dist/systems/abilities.js.map +1 -0
  842. package/dist/systems/combat.d.ts +35 -1
  843. package/dist/systems/combat.js +677 -0
  844. package/dist/systems/combat.js.map +1 -0
  845. package/dist/systems/combatTold.d.ts +3 -1
  846. package/dist/systems/combatTold.js +85 -0
  847. package/dist/systems/combatTold.js.map +1 -0
  848. package/dist/systems/construction.js +80 -0
  849. package/dist/systems/construction.js.map +1 -0
  850. package/dist/systems/economy.d.ts +0 -6
  851. package/dist/systems/economy.js +128 -0
  852. package/dist/systems/economy.js.map +1 -0
  853. package/dist/systems/fog.d.ts +1 -1
  854. package/dist/systems/fog.js +120 -0
  855. package/dist/systems/fog.js.map +1 -0
  856. package/dist/systems/life.js +32 -0
  857. package/dist/systems/life.js.map +1 -0
  858. package/dist/systems/movement.d.ts +24 -12
  859. package/dist/systems/movement.js +1247 -0
  860. package/dist/systems/movement.js.map +1 -0
  861. package/dist/systems/orders.js +64 -0
  862. package/dist/systems/orders.js.map +1 -0
  863. package/dist/systems/production.js +322 -0
  864. package/dist/systems/production.js.map +1 -0
  865. package/dist/systems/productionQueue.js +120 -0
  866. package/dist/systems/productionQueue.js.map +1 -0
  867. package/dist/systems/victory.d.ts +1 -1
  868. package/dist/systems/victory.js +56 -0
  869. package/dist/systems/victory.js.map +1 -0
  870. package/dist/talk.d.ts +6 -6
  871. package/dist/talk.js +153 -0
  872. package/dist/talk.js.map +1 -0
  873. package/dist/targeting.d.ts +142 -0
  874. package/dist/targeting.js +49 -0
  875. package/dist/targeting.js.map +1 -0
  876. package/dist/tech.d.ts +20 -3
  877. package/dist/tech.js +239 -0
  878. package/dist/tech.js.map +1 -0
  879. package/dist/techTree.d.ts +7 -0
  880. package/dist/techTree.js +90 -0
  881. package/dist/techTree.js.map +1 -0
  882. package/dist/terrain.d.ts +59 -7
  883. package/dist/terrain.js +389 -0
  884. package/dist/terrain.js.map +1 -0
  885. package/dist/terrainSave.d.ts +6 -0
  886. package/dist/terrainSave.js +74 -0
  887. package/dist/terrainSave.js.map +1 -0
  888. package/dist/testing.d.ts +8 -7
  889. package/dist/testing.js +13 -739
  890. package/dist/testing.js.map +1 -1
  891. package/dist/tiles.d.ts +1 -1
  892. package/dist/tiles.js +43 -0
  893. package/dist/tiles.js.map +1 -0
  894. package/dist/timers.d.ts +29 -4
  895. package/dist/timers.js +242 -0
  896. package/dist/timers.js.map +1 -0
  897. package/dist/tomes.d.ts +4 -4
  898. package/dist/tomes.js +94 -0
  899. package/dist/tomes.js.map +1 -0
  900. package/dist/trade.js +103 -0
  901. package/dist/trade.js.map +1 -0
  902. package/dist/transport.d.ts +6 -1
  903. package/dist/transport.js +281 -0
  904. package/dist/transport.js.map +1 -0
  905. package/dist/tunables.d.ts +10 -3
  906. package/dist/tunables.js +56 -0
  907. package/dist/tunables.js.map +1 -0
  908. package/dist/unitResources.d.ts +67 -0
  909. package/dist/unitResources.js +266 -0
  910. package/dist/unitResources.js.map +1 -0
  911. package/dist/upkeep.d.ts +6 -1
  912. package/dist/upkeep.js +26 -0
  913. package/dist/upkeep.js.map +1 -0
  914. package/dist/veterancy.d.ts +8 -3
  915. package/dist/veterancy.js +131 -0
  916. package/dist/veterancy.js.map +1 -0
  917. package/dist/vision.d.ts +36 -0
  918. package/dist/vision.js +133 -0
  919. package/dist/vision.js.map +1 -0
  920. package/dist/walls.d.ts +1 -1
  921. package/dist/walls.js +278 -0
  922. package/dist/walls.js.map +1 -0
  923. package/dist/world.d.ts +606 -88
  924. package/dist/world.js +1263 -0
  925. package/dist/world.js.map +1 -0
  926. package/package.json +2 -2
  927. package/dist/ai.js.map +0 -1
  928. package/dist/attributes.d.ts +0 -66
  929. package/dist/brain-BvVdUhX8.js +0 -7659
  930. package/dist/brain-BvVdUhX8.js.map +0 -1
  931. package/dist/builds-C6LfgvEU.js +0 -460
  932. package/dist/builds-C6LfgvEU.js.map +0 -1
  933. package/dist/coreComponents-syuh2fPG.js +0 -5149
  934. package/dist/coreComponents-syuh2fPG.js.map +0 -1
  935. package/dist/debugCommands-CzjrSm66.js +0 -14739
  936. package/dist/debugCommands-CzjrSm66.js.map +0 -1
  937. package/dist/determinism-BCymQwiE.js +0 -518
  938. package/dist/determinism-BCymQwiE.js.map +0 -1
  939. package/dist/game-DiJEN-Ks.js +0 -5800
  940. package/dist/game-DiJEN-Ks.js.map +0 -1
  941. package/dist/index.js.map +0 -1
  942. package/dist/inspect-D9dWHmZ0.js.map +0 -1
  943. package/dist/local-Dkovq42k.js +0 -1379
  944. package/dist/local-Dkovq42k.js.map +0 -1
  945. package/dist/missionRules-C-bGxm0Q.js.map +0 -1
  946. package/dist/navigation-worker.js.map +0 -1
  947. package/dist/packs-g5thvmGn.js +0 -3199
  948. package/dist/packs-g5thvmGn.js.map +0 -1
  949. package/dist/profiles-B3NS9jwk.js.map +0 -1
  950. package/dist/server.js.map +0 -1
  951. package/dist/simulate-oXBiw1Ff.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"movement.js","names":[],"sources":["../../src/systems/movement.ts"],"sourcesContent":["import { distanceToEdge, edgeDistance, type Entity } from '#engine/entity'\nimport { closestPointOnRect, dist, rotateTowards, type Vec2 } from '#engine/math'\nimport type { AgentState, Navigation } from '#engine/navigation/navigation'\nimport type { System } from '#engine/registry'\nimport type { World } from '#engine/world'\nimport { spotFor } from '#engine/engagement'\nimport { atan2, hypot } from '#engine/exactMath'\nimport { type MovementState, moving, fighting } from '../entity'\nimport { isPhasing } from '#engine/abilities/buffs'\n\n/**\n * How close to a point counts as having reached it\n *\n * @internal\n */\nexport const ARRIVE_RANGE = 0.2\n\n/** How fast a unit turns, in radians a second: its type's `turnRate`, else the game's (`RuleSettings.movement.turnRate`) */\nconst turnRateOf = (world: World, entity: Entity): number => entity.def.turnRate ?? world.settings.movement.turnRate\n\n/**\n * Options for a move order given by code: arrival range, group, facing to end on and whether it is a step aside\n *\n * @beta\n */\nexport interface MoveOptions {\n\t/** Arrive once this close to the goal. `ARRIVE_RANGE` when left out */\n\trange?: number\n\t/**\n\t * The id of the group ordered to move together (0 for none): a unit bumping into a group mate that already arrived\n\t * on the point it goes to stops rather than push it, and those of a formation (`MovementState.formation`) keep\n\t * their places\n\t */\n\tgroupId?: number\n\t/** Direction to turn to after arriving */\n\tfacing?: number\n\t/**\n\t * A step aside for another (`stepAside`), or any short move that is nobody's business: the unit goes round nobody,\n\t * and asks those in its way aside only once held up, and only a few deep (`MovementState.asideDepth`), so that one\n\t * step does not set off the next through a whole crowd\n\t */\n\taside?: boolean\n}\n\n/**\n * Point a unit should walk to in order to reach the target: next to its edge for structures, its spot around it for\n * one fighting it (see `engagement.ts`)\n */\nexport function approachPoint(world: World, entity: Entity, target: Entity): Vec2 {\n\t// what flies goes right over it\n\tif (entity.flying) return target.pos\n\tif (target.def.footprint) return closestPointOnRect(entity.pos, target.rect, entity.def.radius + 0.15)\n\treturn entity.get(fighting)?.engaged === target.id ? spotFor(world, entity, target) : target.pos\n}\n\n/**\n * How far along its route a unit is sent at a time (`Rules.paths: 'seen'`): as far as it sees, between 4 and 12.\n * The navigation finds its way over that stretch with every building in it; one that changes the way is in sight, so\n * its side sees it, and the route is planned again with it\n */\nconst stretchOf = (entity: Entity): number => Math.min(Math.max(entity.def.sight ?? 8, 4), 12)\n\n/** The team whose knowledge a ground unit's route is planned with, or none where routes know everything */\n/** The movement of a unit this system runs for: it picks those that have one, so a unit without is a fault, said as such */\nfunction movementOf(entity: Entity): MovementState {\n\tconst m = entity.get(moving)\n\tif (!m) throw new Error(`${entity.def.id} ${entity.id} is moved but has no movement`)\n\treturn m\n}\n\nfunction sideOf(world: World, entity: Entity): number | undefined {\n\tconst paths = world.sidePaths\n\tif (!paths || entity.flying || entity.def.naval) return undefined\n\tconst team = world.player(entity.owner).team\n\treturn paths.has(team) ? team : undefined\n}\n\n/** Plans a unit's route to its goal with what its side knows: none where its side knows no way, or the goal is in sight */\nfunction planRoute(world: World, entity: Entity, team: number): void {\n\tconst m = movementOf(entity)\n\t// (planned only for a team `sideOf` found paths for)\n\tconst paths = world.sidePaths\n\tif (!paths) return\n\tm.routeVersion = paths.version(team)\n\tm.routeAt = 1\n\t// a goal within sight is walked to as it is: all of the way there is in sight (a melee spot, a step aside)\n\tif (dist(entity.pos, m.navGoal) <= stretchOf(entity)) {\n\t\tm.route = undefined\n\t\treturn\n\t}\n\tconst route = paths.route(team, entity.pos, m.navGoal)\n\tm.route = route && route.length > 1 ? route.map(({ x, z }) => ({ x, z })) : undefined\n}\n\n/** How far a point is from a segment */\nfunction distToSegment(p: Vec2, a: Vec2, b: 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.min(Math.max(((p.x - a.x) * dx + (p.z - a.z) * dz) / length, 0), 1) : 0\n\treturn hypot(p.x - (a.x + dx * t), p.z - (a.z + dz * t))\n}\n\n/** The point a stretch ahead of a unit along its route; its goal itself once that is within the stretch */\nfunction stretchPoint(entity: Entity): Vec2 {\n\tconst m = movementOf(entity)\n\tconst route = m.route\n\tif (!route) return m.navGoal\n\t// where along the route it is: the leg nearest it, from where it was on, and the corner that leg ends at next. A\n\t// unit pushed aside, or cutting a corner, is on the route where it is nearest it\n\tlet leg = Math.max((m.routeAt ?? 1) - 1, 0)\n\tlet nearest = Infinity\n\tfor (let i = leg; i < route.length - 1; i++) {\n\t\tconst d = distToSegment(entity.pos, route[i], route[i + 1])\n\t\tif (d < nearest - 1e-9) {\n\t\t\tnearest = d\n\t\t\tleg = i\n\t\t}\n\t}\n\tconst at = Math.min(leg + 1, route.length - 1)\n\tm.routeAt = at\n\tlet left = stretchOf(entity)\n\tlet from: Vec2 = entity.pos\n\tfor (let i = at; i < route.length; i++) {\n\t\tconst length = dist(from, route[i])\n\t\tif (length >= left) {\n\t\t\tconst t = left / length\n\t\t\treturn { x: from.x + (route[i].x - from.x) * t, z: from.z + (route[i].z - from.z) * t }\n\t\t}\n\t\tleft -= length\n\t\tfrom = route[i]\n\t}\n\treturn m.navGoal\n}\n\n/** Sends the navigation where the unit is to walk now: its goal, or a stretch along its route */\nfunction walk(world: World, entity: Entity): boolean {\n\tconst m = movementOf(entity)\n\tconst to = m.route ? stretchPoint(entity) : m.navGoal\n\tm.stretch = m.route ? { x: to.x, z: to.z } : undefined\n\treturn world.nav.setDestination(entity.id, to)\n}\n\n/** Sends a walking unit on as it was, after something held it (a builder waiting for room): its stretch, or its goal */\nexport function walkOn(world: World, entity: Entity): void {\n\tif (entity.get(moving)?.status === 'moving') walk(world, entity)\n}\n\nfunction beginMove(world: World, entity: Entity, navGoal: Vec2): void {\n\tconst m = movementOf(entity)\n\tm.bestDistance = Infinity\n\tm.finalFacing = null\n\tm.stalledTime = 0\n\tm.slowTime = 0\n\tm.detour = undefined\n\tdelete m.tries\n\tdelete m.triedAt\n\tm.navGoal.x = navGoal.x\n\tm.navGoal.z = navGoal.z\n\tm.navVersion = world.nav.version\n\tm.stuck = false\n\tif (m.anchored) {\n\t\tm.anchored = false\n\t\tworld.nav.setAnchored(entity.id, false)\n\t}\n\tconst team = sideOf(world, entity)\n\tif (team === undefined) m.route = undefined\n\telse planRoute(world, entity, team)\n\tm.status = walk(world, entity) ? 'moving' : 'failed'\n}\n\n/**\n * Sends a unit walking to a point, the way around what is in the way. How it goes is in `entity.movement.status`:\n * `moving` on the way, `arrived` once there, `failed` when there is no way there or it got stuck. Held up by others\n * it tries again a few times before it gives up (`MovementState.tries`). An order calls this once and then watches the\n * status; calling it again with the same goal starts the walk over\n *\n * @beta\n */\nexport function moveTo(world: World, entity: Entity, goal: Vec2, options: MoveOptions = {}): void {\n\tconst m = entity.get(moving)\n\tif (!m || entity.hidden) return\n\tm.goal.x = goal.x\n\tm.goal.z = goal.z\n\tm.goalEntity = 0\n\tm.range = options.range ?? ARRIVE_RANGE\n\tm.groupId = options.groupId ?? 0\n\tm.aside = options.aside || undefined\n\tdelete m.asideDepth\n\t// a move of its own: off its place in the formation it went to, for good (a step aside comes back to it)\n\tif (!options.aside) leavePlace(m)\n\tbeginMove(world, entity, goal)\n\tm.finalFacing = options.facing ?? null\n}\n\n/**\n * Walks towards an entity until within `range` of its edge. Safe to call every tick.\n *\n * @beta\n */\nexport function moveToEntity(world: World, entity: Entity, target: Entity, range: number): void {\n\tconst m = entity.get(moving)\n\tif (!m || entity.hidden) return\n\tif (m.status === 'moving' && m.goalEntity === target.id && m.range === range) return\n\tm.goalEntity = target.id\n\tm.range = range\n\tm.groupId = 0\n\tm.aside = undefined\n\tleavePlace(m)\n\tbeginMove(world, entity, approachPoint(world, entity, target))\n}\n\n/**\n * Whether the unit is on its way to this very point\n *\n * @internal\n */\nexport function isMovingTo(entity: Entity, goal: Vec2): boolean {\n\tconst m = entity.get(moving)\n\treturn !!m && m.status === 'moving' && m.goalEntity === 0 && m.goal.x === goal.x && m.goal.z === goal.z\n}\n\n/**\n * Stops a unit where it is. Its status is `idle` after\n *\n * @beta\n */\nexport function halt(world: World, entity: Entity): void {\n\tconst m = entity.get(moving)\n\tif (!m) return\n\tif (m.status === 'moving') world.nav.clearDestination(entity.id)\n\tm.status = 'idle'\n\tm.goalEntity = 0\n\tm.groupId = 0\n\tm.detour = undefined\n}\n\n/** A unit that walks off on a move of its own: it has no place to go back to (`MovementState.place`) */\nfunction leavePlace(m: MovementState): void {\n\tdelete m.place\n\tdelete m.backTries\n}\n\n/**\n * Marks a unit as one of a formation sent to its places (`orderCommand`, with the order's group): it keeps the place it\n * gets to (`MovementState.place`). Without a group, it is of none: given another order, it keeps no place\n *\n * @internal\n */\nexport function joinFormation(entity: Entity, groupId = 0): void {\n\tconst m = entity.get(moving)\n\tif (!m) return\n\tleavePlace(m)\n\tif (groupId) m.formation = groupId\n\telse delete m.formation\n}\n\n/**\n * Anchored units stand their ground instead of being pushed around by units walking past.\n *\n * @beta\n */\nexport function setAnchored(world: World, entity: Entity, anchored: boolean): void {\n\tconst m = entity.get(moving)\n\tif (!m || m.anchored === anchored) return\n\tif (anchored && m.status === 'moving') halt(world, entity)\n\tm.anchored = anchored\n\tworld.nav.setAnchored(entity.id, anchored)\n}\n\n/**\n * Ghosts walk through other units. Classic RTS games do this for workers hauling resources so mining never jams.\n *\n * @beta\n */\nexport function setGhost(world: World, entity: Entity, ghost: boolean): void {\n\tconst m = entity.get(moving)\n\tif (!m || m.ghost === ghost) return\n\tm.ghost = ghost\n\t// one that phases (`BuffDef.phasing`) on a navigation that cannot have it do so stays a ghost while it does\n\tworld.nav.setGhost(entity.id, ghost || (!world.nav.setPhasing && !!m.phased))\n}\n\n/**\n * Units that carry a buff that has them walk through others (`BuffDef.phasing`) phase on the navigation while they do\n * (`Navigation.setPhasing`: on a crowd of their own, nobody's neighbour), and are not gone round nor asked aside.\n * Walls, cliffs, buildings and trees are the navigation's ground, and stop them all the same\n */\nfunction seeToPhasing(world: World): void {\n\tfor (const entity of world.index.with(moving)) {\n\t\tconst m = entity.get(moving)\n\t\tif (!m) continue\n\t\tconst phasing = entity.buffs.length > 0 && entity.alive && !entity.hidden && isPhasing(world, entity)\n\t\tif (phasing === !!m.phased) continue\n\t\tif (phasing) m.phased = true\n\t\telse delete m.phased\n\t\tif (world.nav.setPhasing) world.nav.setPhasing(entity.id, phasing)\n\t\telse world.nav.setGhost(entity.id, phasing || m.ghost)\n\t}\n}\n\n/**\n * Turns a unit a little towards a point, as far as it turns in `dt` seconds (its type's `turnRate`, else the game's:\n * `RuleSettings.movement.turnRate`). For orders that aim at something\n *\n * @beta\n */\nexport function faceTowards(world: World, entity: Entity, point: Vec2, dt: number): void {\n\tconst m = entity.get(moving)\n\tif (m) m.finalFacing = null\n\tconst desired = atan2(point.x - entity.pos.x, point.z - entity.pos.z)\n\tentity.facing = rotateTowards(entity.facing, desired, turnRateOf(world, entity) * dt)\n}\n\nfunction arrive(world: World, entity: Entity): void {\n\tworld.nav.clearDestination(entity.id)\n\tconst m = movementOf(entity)\n\tm.status = 'arrived'\n\tm.stalledTime = 0\n\t// at its place in a formation: it goes back there once stepped aside, or pushed off it. Its place even where it\n\t// stopped short of it, another standing there: once that one is gone to its own, it goes there\n\tif (m.groupId && m.formation === m.groupId && !m.aside && !m.goalEntity) {\n\t\tm.place = { x: m.goal.x, z: m.goal.z }\n\t\t// there: it has its tries to go back again. Stopped short, a walk back (`backToPlace`) spent one\n\t\tif (dist(entity.pos, m.place) <= PLACE_OFF) delete m.backTries\n\t} else if (m.place && dist(entity.pos, m.place) <= PLACE_OFF) delete m.backTries\n}\n\n/** True when the unit is bumping into a member of its own group that already reached its spot. */\nfunction blockedByArrivedGroupMate(world: World, entity: Entity): boolean {\n\tconst m = movementOf(entity)\n\tif (!m.groupId) return false\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1, neighbours)\n\tfor (const other of neighbours) {\n\t\tconst om = other.get(moving)\n\t\tif (other === entity || !om || other.flying !== entity.flying) continue\n\t\tif (om.groupId !== m.groupId || om.status !== 'arrived') continue\n\t\tif (distanceToEdge(entity.pos, other) - entity.def.radius < 0.25) return true\n\t}\n\treturn false\n}\n\n/** Seconds a unit has to be held up before the ones in its way are asked to move */\nconst MAKE_WAY_AFTER = 0.2\n/** How many asked aside in turn, each by the one before held up on its step: the first by the mover, the next by it */\nconst ASIDE_DEPTH = 3\n/** Ticks between two requests by the same unit */\nconst MAKE_WAY_INTERVAL = 8\n/** Ticks between two looks ahead by the same unit, for units standing in its way */\nconst LOOK_AHEAD_INTERVAL = 4\n/** Room a unit keeps between itself and the units it goes round, past touching them */\nconst DETOUR_CLEARANCE = 0.3\n/**\n * How far past the point beside a knot a unit going round it is sent on, towards its corner, once it is nearly there\n * (`DETOUR_PAST_AT`): an agent slows down as it comes to where it was sent, and this way it is on its way again, at\n * speed, before that\n */\nconst DETOUR_PAST = 1.5\nconst DETOUR_PAST_AT = 1.2\n/** Under this part of its speed, a unit on its way counts as held up */\nconst SLOW_PART = 0.6\n/** How far round the point ahead a unit held up a while looks for those standing together in its way */\nconst HELD_REACH = 10\n/** Units standing in a knot past this many are not gone round: the way round them is for the path to find */\nconst KNOT_MOST = 24\n/**\n * As many as a unit held up a while takes in, as it looks again (`tryAgain`): then it goes round however many\n * stand together, however long the way round, where there is one\n */\nconst KNOT_HELD = 160\n/** The most a knot is grown to on this look: `KNOT_MOST`, or `KNOT_HELD` for a unit held up a while */\nlet knotMost = KNOT_MOST\n\n/**\n * Whether another unit stands in a mover's way: there, standing still, and on the same crowd, where each steers\n * round the other and neither walks through. What moves is steered round by the navigation; what is a ghost is walked\n * through; what flies or sails goes its own way. What the mover walks to, or stands where it is\n * going, is not in its way either: it stops by it, close enough (a follower by the one it follows, a unit sent where\n * another stands), rather than send it off\n *\n * @beta\n */\nexport function standsInWay(world: World, mover: Entity, other: Entity): boolean {\n\tconst om = other.get(moving)\n\tif (other === mover || !om || other.hidden || !other.alive) return false\n\tif (om.status === 'moving' || om.ghost || om.phased) return false\n\tconst m = mover.get(moving)\n\t// one that walks through others has nobody in its way\n\tif (m?.phased) return false\n\tif (m && (other.id === m.goalEntity || hypot(other.pos.x - m.navGoal.x, other.pos.z - m.navGoal.z) < m.range + mover.def.radius + other.def.radius))\n\t\treturn false\n\treturn world.nav.sameCrowd?.(mover.id, other.id) ?? true\n}\n\n/** How far a point is from a segment */\nfunction segmentDistance(px: number, pz: number, ax: number, az: number, bx: number, bz: number): number {\n\tconst dx = bx - ax\n\tconst dz = bz - az\n\tconst length = dx * dx + dz * dz\n\tconst t = length > 0 ? Math.min(Math.max(((px - ax) * dx + (pz - az) * dz) / length, 0), 1) : 0\n\treturn hypot(px - (ax + dx * t), pz - (az + dz * t))\n}\n\nconst probe: Vec2 = { x: 0, z: 0 }\n\n/** Whether the navigation has walkable ground at a point: its nearest such point is no further than a hair */\nfunction walkableAt(nav: Navigation, x: number, z: number): boolean {\n\tprobe.x = x\n\tprobe.z = z\n\tconst snapped = nav.closestPoint(probe, 1)\n\treturn !!snapped && hypot(snapped.x - x, snapped.z - z) <= 0.3\n}\n\n/**\n * Where an ally in a mover's way steps to: aside, off the mover's way, the shorter way out of it first. The way is the\n * leg the mover is on, to its corner, and the leg after (`agent.nx`): a step off the first onto the second, round a\n * building's corner, would be no step at all. Where a side is not to be stood on (a wall), the other; where neither,\n * nowhere\n */\nfunction asidePoint(world: World, mover: Entity, other: Entity, dx: number, dz: number, agent: AgentState): Vec2 | null {\n\tconst rx = other.pos.x - mover.pos.x\n\tconst rz = other.pos.z - mover.pos.z\n\tconst reach = mover.def.radius + other.def.radius\n\tconst clear = reach + 0.5\n\t// distance from the line the mover wants to walk\n\tconst offset = rx * dz - rz * dx\n\tconst first = Math.abs(offset) > 0.05 ? Math.sign(offset) : other.id % 2 ? 1 : -1\n\tconst nav = world.navFor(other)\n\tconst { pos } = mover\n\tlet taken: Vec2 | null = null\n\t// for one standing about with nothing to do; one waiting by a fight steps where it is told, to stay near it\n\tconst free = other.orders.length === 0\n\tfor (let pass = 0; pass < 2; pass++) {\n\t\tconst side = pass === 0 ? first : -first\n\t\t// as far as it takes to be off both legs, in steps, not past a few of them\n\t\tfor (let step = clear - Math.abs(offset); step <= clear * 3; step += 0.5) {\n\t\t\tconst x = other.pos.x + dz * side * step\n\t\t\tconst z = other.pos.z - dx * side * step\n\t\t\tif (segmentDistance(x, z, pos.x, pos.z, agent.cx, agent.cz) < clear - 0.05) continue\n\t\t\tif (segmentDistance(x, z, agent.cx, agent.cz, agent.nx, agent.nz) < clear - 0.05) continue\n\t\t\tif (!walkableAt(nav, x, z)) break\n\t\t\t// room there, rather than onto another standing about (a step onto one has it pushed, or asked on, in turn)\n\t\t\tif (free && !roomFor(world, other, mover, x, z)) {\n\t\t\t\ttaken ??= { x, z }\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn { x, z }\n\t\t}\n\t}\n\treturn taken\n}\n\nconst roomNear: Entity[] = []\n\n/** Whether a unit stepping aside has room at a point: nobody else stands there, nor steps aside onto it */\nfunction roomFor(world: World, entity: Entity, mover: Entity, x: number, z: number): boolean {\n\tworld.spatial.query(x, z, entity.def.radius + 1, roomNear)\n\tfor (const other of roomNear) {\n\t\tif (other === entity || other === mover || other.hidden || other.flying !== entity.flying) continue\n\t\tconst om = other.get(moving)\n\t\tif (!om || om.ghost || om.phased) continue\n\t\tconst room = entity.def.radius + other.def.radius - 0.05\n\t\tif (om.status !== 'moving' && hypot(other.pos.x - x, other.pos.z - z) < room) return false\n\t\tif (om.aside && om.status === 'moving' && hypot(om.goal.x - x, om.goal.z - z) < room) return false\n\t}\n\treturn true\n}\n\n/**\n * Asks an ally standing in a unit's way to step aside, as the rules allow (`RuleSettings.movement.makesWay`, the `makeWay` hook).\n * `direction` is the way the unit is heading, a unit long; `agent` where its path goes, for the step to be off it.\n * True when it goes\n *\n * @beta\n */\nexport function stepAside(world: World, mover: Entity, other: Entity, direction: Vec2, agent: AgentState): boolean {\n\tconst om = other.get(moving)\n\tif (!om || !world.areAllies(mover.owner, other.owner) || !world.settings.movement.makesWay(world, mover, other)) return false\n\tconst m = mover.get(moving)\n\t// nor for one of its group: those of a formation pass places on (`passOn`), and swap or trade them (`swapPlaces`,\n\t// `tradeGoals`), rather than step aside for each other\n\tif (m?.groupId && (om.groupId === m.groupId || om.formation === m.groupId)) return false\n\tlet point = asidePoint(world, mover, other, direction.x, direction.z, agent)\n\tif (world.hooks.has('makeWay')) point = world.hooks.run('makeWay', { mover, other, direction, point }).point\n\tif (!point) return false\n\tmoveTo(world, other, point, { facing: om.finalFacing ?? other.facing, aside: true })\n\t// asked by one stepping aside itself: a step further down the line, which ends (`ASIDE_DEPTH`)\n\tif (m?.aside) om.asideDepth = (m.asideDepth ?? 1) + 1\n\treturn true\n}\n\nconst neighbours: Entity[] = []\nconst inWay: Entity[] = []\nconst knot: Entity[] = []\n/**\n * What each of `neighbours` is to the unit looking ahead, by its index: not asked yet, clear, standing in its way, or in\n * the knot. In a blob every member of the knot looks over every neighbour: `standsInWay` asked once each, and a mark\n * rather than `knot.includes`, keep that from being a good part of the tick\n */\nlet standing = new Uint8Array(256)\n/**\n * Where each of `neighbours` stands and how wide it is, by its index, read off it once as a knot is grown: the knot\n * goes over the neighbours again for each of its members, and numbers side by side are read faster than each unit's\n * place and type are got at again (nobody moves while the knot is grown)\n */\nlet nearX = new Float64Array(256)\nlet nearZ = new Float64Array(256)\nlet nearRadius = new Float64Array(256)\n/** The index in `neighbours` of each member of the knot, as it is grown from them */\nlet knotAt = new Int32Array(256)\n/** Those a member of the knot takes in, by their index in `neighbours`, in order */\nlet joined = new Int32Array(256)\n/**\n * The neighbours filed by cells a metre wide (`fileNear`): the cell of each, and the indices of those in each cell, in\n * order, from `cellStart[cell]` to `cellStart[cell + 1]`; the corner the cells start from, how many there are across\n * and down, and the widest neighbour\n */\nlet cellItems = new Int32Array(256)\nlet cellStart = new Int32Array(257)\nlet cellFill = new Int32Array(257)\nlet nearCell = new Int32Array(256)\nlet nearMinX = 0\nlet nearMinZ = 0\nlet nearCols = 0\nlet nearRows = 0\nlet nearWidest = 0\n\n/**\n * Files the `count` neighbours (`nearX`, `nearZ`, `nearRadius`) by cells a metre wide, for the knot to find those\n * against each member among a few of them. False, and nothing filed, where it would take more cells than it is worth\n * (a few neighbours far apart), or a place or a radius is no number\n */\nfunction fileNear(count: number): boolean {\n\tlet minX = Infinity\n\tlet minZ = Infinity\n\tlet maxX = -Infinity\n\tlet maxZ = -Infinity\n\tlet widest = 0\n\t// NaN, should a place or a radius be none\n\tlet sum = 0\n\tfor (let j = 0; j < count; j++) {\n\t\tconst x = nearX[j]\n\t\tconst z = nearZ[j]\n\t\tsum += x + z + nearRadius[j]\n\t\tif (x < minX) minX = x\n\t\tif (x > maxX) maxX = x\n\t\tif (z < minZ) minZ = z\n\t\tif (z > maxZ) maxZ = z\n\t\tif (nearRadius[j] > widest) widest = nearRadius[j]\n\t}\n\tconst cols = Math.floor(maxX - minX) + 1\n\tconst rows = Math.floor(maxZ - minZ) + 1\n\tconst cells = cols * rows\n\tif (Number.isNaN(sum) || !(cells <= count * 4)) return false\n\tif (cellStart.length < cells + 1) {\n\t\tcellStart = new Int32Array((cells + 1) * 2)\n\t\tcellFill = new Int32Array((cells + 1) * 2)\n\t}\n\tcellStart.fill(0, 0, cells + 1)\n\tfor (let j = 0; j < count; j++) {\n\t\tconst cell = Math.floor(nearZ[j] - minZ) * cols + Math.floor(nearX[j] - minX)\n\t\tnearCell[j] = cell\n\t\tcellStart[cell + 1]++\n\t}\n\tfor (let cell = 0; cell < cells; cell++) cellStart[cell + 1] += cellStart[cell]\n\tcellFill.set(cellStart.subarray(0, cells))\n\tfor (let j = 0; j < count; j++) cellItems[cellFill[nearCell[j]]++] = j\n\tnearMinX = minX\n\tnearMinZ = minZ\n\tnearCols = cols\n\tnearRows = rows\n\tnearWidest = widest\n\treturn true\n}\n\n/**\n * Grows the knot of the unit looking ahead (`lookAhead`) from those in its way (`knot`, `knotAt`): each member in turn\n * takes in the neighbours that stand against it, in their order, until the knot is too big to go round. Those against\n * a member are looked for in the cells round it (`fileNear`), as far as it reaches the widest neighbour: one further\n * off touches it not. Where the neighbours are not filed, among them all\n */\nfunction growKnot(world: World, entity: Entity, count: number): void {\n\tfor (let i = 0; i < count; i++) {\n\t\tconst other = neighbours[i]\n\t\tnearX[i] = other.pos.x\n\t\tnearZ[i] = other.pos.z\n\t\tnearRadius[i] = other.def.radius\n\t}\n\tconst filed = fileNear(count)\n\tfor (let i = 0; i < knot.length && knot.length < knotMost; i++) {\n\t\tconst member = knotAt[i]\n\t\tconst memberX = nearX[member]\n\t\tconst memberZ = nearZ[member]\n\t\tconst memberRadius = nearRadius[member]\n\t\tlet added = 0\n\t\tconst take = (j: number): void => {\n\t\t\tconst mark = standing[j]\n\t\t\tif (mark === KNOTTED || mark === CLEAR) return\n\t\t\tif (hypot(nearX[j] - memberX, nearZ[j] - memberZ) >= memberRadius + nearRadius[j] + 0.3) return\n\t\t\tif (!standsThere(world, entity, j)) return\n\t\t\tstanding[j] = KNOTTED\n\t\t\t// in the order of the neighbours, as one look over them all finds them\n\t\t\tlet place = added++\n\t\t\tfor (; place > 0 && joined[place - 1] > j; place--) joined[place] = joined[place - 1]\n\t\t\tjoined[place] = j\n\t\t}\n\t\tif (filed) {\n\t\t\t// as far as it touches the widest, and a hair for what rounding takes off a distance\n\t\t\tconst touch = memberRadius + nearWidest + 0.3 + 0.01\n\t\t\tconst fromCol = Math.max(Math.floor(memberX - touch - nearMinX), 0)\n\t\t\tconst toCol = Math.min(Math.floor(memberX + touch - nearMinX), nearCols - 1)\n\t\t\tconst fromRow = Math.max(Math.floor(memberZ - touch - nearMinZ), 0)\n\t\t\tconst toRow = Math.min(Math.floor(memberZ + touch - nearMinZ), nearRows - 1)\n\t\t\t// the cells of a row, along it, are one stretch of `cellItems`\n\t\t\tfor (let row = fromRow; row <= toRow; row++)\n\t\t\t\tfor (let k = cellStart[row * nearCols + fromCol], end = cellStart[row * nearCols + toCol + 1]; k < end; k++) take(cellItems[k])\n\t\t} else for (let j = 0; j < count; j++) take(j)\n\t\tfor (let k = 0; k < added; k++) {\n\t\t\tknotAt[knot.length] = joined[k]\n\t\t\tknot.push(neighbours[joined[k]])\n\t\t}\n\t}\n}\nconst UNASKED = 0\nconst CLEAR = 1\nconst STANDING = 2\nconst KNOTTED = 3\nconst direction: Vec2 = { x: 0, z: 0 }\nconst agent: AgentState = { x: 0, z: 0, vx: 0, vz: 0, cx: 0, cz: 0, nx: 0, nz: 0 }\n\n/**\n * Asks friendly units that are standing around in front of a unit to step aside.\n * Avoidance alone cannot get a unit out of a tight group of idle ones: they would have to move, and nothing tells them to.\n *\n * @beta\n */\nexport function makeWay(world: World, entity: Entity): void {\n\tconst m = movementOf(entity)\n\tif (!world.nav.readAgent(entity.id, agent)) return\n\tconst to = m.detour ?? m.navGoal\n\tlet dx = to.x - entity.pos.x\n\tlet dz = to.z - entity.pos.z\n\tconst length = hypot(dx, dz)\n\tif (length < 0.01) return\n\tdx /= length\n\tdz /= length\n\tdirection.x = dx\n\tdirection.z = dz\n\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1.5, neighbours)\n\t// those against it, picked out before any is asked: moving others changes the list the query hands out. Mostly\n\t// there are none, and nothing is made\n\tlet against: Entity[] | undefined\n\tfor (const other of neighbours) {\n\t\tconst rx = other.pos.x - entity.pos.x\n\t\tconst rz = other.pos.z - entity.pos.z\n\t\tconst reach = entity.def.radius + other.def.radius\n\t\tconst ahead = rx * dx + rz * dz\n\t\tif (ahead < -0.1 || ahead > reach + 1) continue\n\t\t// against it, not beside it\n\t\tconst offset = rx * dz - rz * dx\n\t\tif (Math.abs(offset) > reach) continue\n\t\tagainst ??= []\n\t\tagainst.push(other)\n\t}\n\tif (!against) return\n\tfor (const other of against) if (standsInWay(world, entity, other)) stepAside(world, entity, other, direction, agent)\n}\n\n/** Whether a unit walking a segment would touch any of the knot */\nfunction segmentClear(radius: number, ax: number, az: number, bx: number, bz: number): boolean {\n\tfor (const other of knot) {\n\t\tif (segmentDistance(other.pos.x, other.pos.z, ax, az, bx, bz) < radius + other.def.radius + 0.05) return false\n\t}\n\treturn true\n}\n\nconst wayFrom: Vec2 = { x: 0, z: 0 }\nconst wayTo: Vec2 = { x: 0, z: 0 }\n\n/**\n * Whether the way from a point to another is straight, as far as the navigation is concerned: its path is no longer\n * than the line, give or take. A way round a knot that bends round a building is no way round the knot\n */\nfunction straightWay(nav: Navigation, fromX: number, fromZ: number, toX: number, toZ: number): boolean {\n\tconst from = wayFrom\n\tconst to = wayTo\n\tfrom.x = fromX\n\tfrom.z = fromZ\n\tto.x = toX\n\tto.z = toZ\n\tconst path = nav.findPath(from, to)\n\tif (!path || path.length === 0) return false\n\tlet length = dist(from, path[0])\n\tfor (let i = 1; i < path.length; i++) length += dist(path[i - 1], path[i])\n\tlength += dist(path[path.length - 1], to)\n\treturn length <= dist(from, to) * 1.05 + 0.3\n}\n\nconst standingThere: Entity[] = []\n\n/**\n * Whether a unit could stand at a point: walkable there, and nobody standing on it, or stepping aside onto it. Null\n * when it could; otherwise the unit in the way there, or the mover itself for ground it cannot walk\n */\nfunction standable(world: World, nav: Navigation, entity: Entity, x: number, z: number): Entity | null {\n\tif (!walkableAt(nav, x, z)) return entity\n\tworld.spatial.query(x, z, entity.def.radius + 1, standingThere)\n\tfor (const other of standingThere) {\n\t\tif (other === entity || !other.get(moving) || other.hidden) continue\n\t\tconst room = entity.def.radius + other.def.radius + 0.05\n\t\t// on it, first: most are not, and whether one stands in the way is the more to ask\n\t\tif (hypot(other.pos.x - x, other.pos.z - z) < room && standsInWay(world, entity, other)) return other\n\t\t// on its way to stand there: a step aside for someone\n\t\tconst om = other.get(moving)!\n\t\tif (om.aside && om.status === 'moving' && hypot(om.goal.x - x, om.goal.z - z) < room) return other\n\t}\n\treturn null\n}\n\n/** Whether the neighbour at `i` stands in the way of the unit looking ahead: asked of `standsInWay` the first time only */\nfunction standsThere(world: World, entity: Entity, i: number): boolean {\n\tif (standing[i] === UNASKED) standing[i] = standsInWay(world, entity, neighbours[i]) ? STANDING : CLEAR\n\treturn standing[i] !== CLEAR\n}\n\n/**\n * Looks ahead of a unit on its way for units standing in it (within `RuleSettings.movement.lookAhead`): a way round the knot\n * they make is taken where it is not much longer (`RuleSettings.movement.goesAround`, the `detour` hook); otherwise those of\n * them that make way (`RuleSettings.movement.makesWay`) are asked to step aside before the unit reaches them. The way round is\n * beside the knot, on the side it sticks out less, at the knot's middle; the unit heads there, and on to its path\n * from there. The number of units sent to this per tick is spread by their ids (`LOOK_AHEAD_INTERVAL`)\n *\n * @beta\n */\nexport function lookAhead(world: World, entity: Entity, agent: AgentState): void {\n\tlookFurther(world, entity, agent, false)\n}\n\n/**\n * The look ahead (`lookAhead`); `held` for a unit held up a while (`tryAgain`): it looks a few cells ahead, whatever the\n * rules say, takes in the whole knot, however big, and goes round it however long the way round, where there is one\n */\nfunction lookFurther(world: World, entity: Entity, agent: AgentState, held: boolean): void {\n\tconst m = movementOf(entity)\n\tconst look = held ? Math.max(world.settings.movement.lookAhead(world, entity), 3) : world.settings.movement.lookAhead(world, entity)\n\tif (look <= 0) return\n\tknotMost = held ? KNOT_HELD : KNOT_MOST\n\tconst { pos } = entity\n\tconst radius = entity.def.radius\n\tlet dx = agent.cx - pos.x\n\tlet dz = agent.cz - pos.z\n\tconst toCorner = hypot(dx, dz)\n\tif (toCorner < radius) return\n\tdx /= toCorner\n\tdz /= toCorner\n\tconst reach = Math.min(toCorner, look)\n\n\tworld.spatial.query(pos.x + (dx * reach) / 2, pos.z + (dz * reach) / 2, reach / 2 + (held ? HELD_REACH : 3), neighbours)\n\tconst count = neighbours.length\n\tif (standing.length < count) {\n\t\tstanding = new Uint8Array(count * 2)\n\t\tnearX = new Float64Array(count * 2)\n\t\tnearZ = new Float64Array(count * 2)\n\t\tnearRadius = new Float64Array(count * 2)\n\t\tknotAt = new Int32Array(count * 2)\n\t\tjoined = new Int32Array(count * 2)\n\t\tnearCell = new Int32Array(count * 2)\n\t\tcellItems = new Int32Array(count * 2)\n\t}\n\tstanding.fill(UNASKED, 0, count)\n\tinWay.length = 0\n\tknot.length = 0\n\tfor (let i = 0; i < count; i++) {\n\t\tconst other = neighbours[i]\n\t\tconst rx = other.pos.x - pos.x\n\t\tconst rz = other.pos.z - pos.z\n\t\tconst touch = radius + other.def.radius\n\t\tconst ahead = rx * dx + rz * dz\n\t\t// ahead of it, not beside it or behind, and not past where it looks\n\t\tif (ahead < radius || ahead > reach + touch) continue\n\t\t// in its way, not merely brushed past: the navigation steers round that much\n\t\tconst offset = rx * dz - rz * dx\n\t\tif (Math.abs(offset) > touch - 0.05) continue\n\t\tif (!standsThere(world, entity, i)) continue\n\t\tstanding[i] = KNOTTED\n\t\tknotAt[inWay.length] = i\n\t\tinWay.push(other)\n\t}\n\tif (inWay.length === 0) return\n\n\t// the knot: those in the way, and those standing against them, against those...: the way round goes round it all\n\tfor (const other of inWay) knot.push(other)\n\tif (knot.length < knotMost) growKnot(world, entity, count)\n\n\tlet detour: Vec2 | null = null\n\tif (knot.length < knotMost) {\n\t\tconst nav = world.navFor(entity)\n\t\t// from the point beside the knot, on to the corner; or to the corner after it, where the knot stands at the corner\n\t\t// (against a building's corner): round the knot onto the next leg\n\t\tlet aimX = agent.cx\n\t\tlet aimZ = agent.cz\n\t\t// the knot grows by whoever stands where the way round it would go, and the way round is looked for again\n\t\tfor (let grown = 0; grown < 4 && !detour; grown++) {\n\t\t\tlet left = -Infinity\n\t\t\tlet right = Infinity\n\t\t\tlet along = 0\n\t\t\tfor (const other of knot) {\n\t\t\t\tconst rx = other.pos.x - pos.x\n\t\t\t\tconst rz = other.pos.z - pos.z\n\t\t\t\tconst offset = rx * dz - rz * dx\n\t\t\t\tleft = Math.max(left, offset + other.def.radius)\n\t\t\t\tright = Math.min(right, offset - other.def.radius)\n\t\t\t\talong += rx * dx + rz * dz\n\t\t\t}\n\t\t\talong = Math.max(along / knot.length, radius)\n\t\t\t// the side it sticks out less on first, then the other, each pushed further out while the way there touches it\n\t\t\tconst leftFirst = Math.abs(left) <= Math.abs(right)\n\t\t\tlet blocker: Entity | null = null\n\t\t\tfor (let pass = 0; pass < 2; pass++) {\n\t\t\t\tconst side = leftFirst === (pass === 0) ? left : right\n\t\t\t\tconst out = side > 0 ? 1 : -1\n\t\t\t\tfor (let push = 0; push < 3 && !detour; push++) {\n\t\t\t\t\tconst offset = side + out * (radius + DETOUR_CLEARANCE + push * 0.5)\n\t\t\t\t\tconst x = pos.x + dx * along + dz * offset\n\t\t\t\t\tconst z = pos.z + dz * along - dx * offset\n\t\t\t\t\tconst there = standable(world, nav, entity, x, z)\n\t\t\t\t\tif (there) {\n\t\t\t\t\t\tif (there !== entity && !knot.includes(there)) blocker ??= there\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (!segmentClear(radius, pos.x, pos.z, x, z) || !straightWay(nav, pos.x, pos.z, x, z)) continue\n\t\t\t\t\tif (segmentClear(radius, x, z, agent.cx, agent.cz) && straightWay(nav, x, z, agent.cx, agent.cz)) {\n\t\t\t\t\t\taimX = agent.cx\n\t\t\t\t\t\taimZ = agent.cz\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t(agent.nx !== agent.cx || agent.nz !== agent.cz) &&\n\t\t\t\t\t\tsegmentClear(radius, x, z, agent.nx, agent.nz) &&\n\t\t\t\t\t\tstraightWay(nav, x, z, agent.nx, agent.nz)\n\t\t\t\t\t) {\n\t\t\t\t\t\taimX = agent.nx\n\t\t\t\t\t\taimZ = agent.nz\n\t\t\t\t\t} else continue\n\t\t\t\t\tdetour = { x, z }\n\t\t\t\t}\n\t\t\t\tif (detour) break\n\t\t\t}\n\t\t\tif (!detour && blocker && knot.length < knotMost) knot.push(blocker)\n\t\t\telse if (!detour) break\n\t\t}\n\t\tif (detour) {\n\t\t\tconst straight = aimX === agent.cx && aimZ === agent.cz ? toCorner : toCorner + hypot(agent.nx - agent.cx, agent.nz - agent.cz)\n\t\t\tconst longer = hypot(detour.x - pos.x, detour.z - pos.z) + hypot(aimX - detour.x, aimZ - detour.z) - straight\n\t\t\tconst around = [...knot]\n\t\t\tif (!held && !world.settings.movement.goesAround(world, entity, around, longer, straight)) detour = null\n\t\t\tif (world.hooks.has('detour')) detour = world.hooks.run('detour', { entity, around, straight, longer, point: detour }).point\n\t\t\tif (detour) {\n\t\t\t\tm.detour = detour\n\t\t\t\tm.detourAim = { x: aimX, z: aimZ }\n\t\t\t\tm.detourPast = false\n\t\t\t\tworld.nav.setDestination(entity.id, detour)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\t// no way round: those in the way that make way are asked to, before the unit reaches them\n\tdirection.x = dx\n\tdirection.z = dz\n\tfor (const other of [...inWay]) stepAside(world, entity, other, direction, agent)\n}\n\n/**\n * Over how many ticks the chasers look for new paths after the navigation changed: an eighth of them each tick\n *\n * @beta\n */\nexport const REPATH_SPREAD = 8\n\n/** Keeps chasers pointed at targets that moved, and lets go of the ones gone out of reach */\nfunction followTargets(world: World): void {\n\tconst { nav } = world\n\tfor (const entity of world.index.with(moving)) {\n\t\tconst m = entity.get(moving)\n\t\tif (!m || m.status !== 'moving' || !m.goalEntity) continue\n\t\tconst target = world.get(m.goalEntity)\n\t\tif (!target || target.hidden) {\n\t\t\tnav.clearDestination(entity.id)\n\t\t\tm.status = 'failed'\n\t\t\tcontinue\n\t\t}\n\t\tconst point = approachPoint(world, entity, target)\n\t\t// a change of the navigation has every chaser look again: a few each tick, by their ids, so that a building put\n\t\t// down does not have a thousand paths looked for in one tick. By the world's own count, so it stays the same\n\t\t// game everywhere\n\t\tconst stale = m.navVersion !== nav.version && (entity.id + world.tick) % REPATH_SPREAD === 0\n\t\tif (dist(point, m.navGoal) > 0.75 || stale) beginMove(world, entity, point)\n\t}\n}\n\n/** Where the navigation moved each unit to, read back into the world: and from there, how each is getting on */\nfunction readAgents(world: World, dt: number): void {\n\tfor (const entity of world.index.with(moving)) {\n\t\tconst m = entity.get(moving)\n\t\tif (!m || !entity.alive || entity.hidden) continue\n\t\tif (!world.nav.readAgent(entity.id, agent)) continue\n\t\tmoveAlong(world, entity, m, dt)\n\t}\n}\n\n/** A unit the navigation moved (`agent`, just read): where it is, which way it faces, and how it is getting on */\nfunction moveAlong(world: World, entity: Entity, m: MovementState, dt: number): void {\n\t// the navigation moved it: this is where the world learns where it went\n\tentity.moveTo(agent.x, agent.z)\n\tentity.velocity.x = agent.vx\n\tentity.velocity.z = agent.vz\n\tif (m.status !== 'moving') {\n\t\tif (m.place) backToPlace(world, entity, m, dt)\n\t\treturn lineUp(world, entity, m, dt)\n\t}\n\n\tif (agent.vx * agent.vx + agent.vz * agent.vz > 0.2) {\n\t\tconst desired = atan2(agent.vx, agent.vz)\n\t\tentity.facing = rotateTowards(entity.facing, desired, turnRateOf(world, entity) * dt)\n\t}\n\tconst distance = distanceLeft(world, entity, m)\n\tif (distance === undefined) return\n\tif (distance <= m.range) return arrive(world, entity)\n\tsteerAround(world, entity, m)\n\tfollowRoute(world, entity, m)\n\twatchProgress(world, entity, m, distance, dt)\n}\n\n/** How far off its place in a formation a unit that stands there goes back to it */\nconst PLACE_OFF = 0.35\n/** Seconds it stands off its place before it goes back: the one it stepped aside for gone by */\nconst PLACE_WAIT = 0.75\n/** How many times it goes back to its place without getting there before it lets it go: jostling for ever is no good */\nconst BACK_TRIES = 5\n\n/**\n * A unit of a formation standing off its place (stepped aside for another, or pushed off it) walks back to it once it\n * has stood off it a while (`PLACE_WAIT`), as one of the formation: it swaps, passes on and trades places on the way,\n * and makes its own room by it (`nudge`), but does not try again: held up `HELD_UP` near it, it stops, its place kept.\n * Where another of the formation stands there, off its own, that one keeps this place and this one goes to the\n * other's; where one stands at its own there it waits. After a few walks back (`BACK_TRIES`) without getting there\n * it lets the place go, and stays where it is\n */\nfunction backToPlace(world: World, entity: Entity, m: MovementState, dt: number): void {\n\tconst place = m.place!\n\tif (m.anchored || entity.orders.length > 0 || dist(entity.pos, place) <= PLACE_OFF) return\n\tm.stalledTime += dt\n\tif (m.stalledTime < PLACE_WAIT || (world.tick + entity.id) % LOOK_AHEAD_INTERVAL !== 0) return\n\tm.stalledTime = 0\n\tconst tries = (m.backTries ?? 0) + 1\n\tif (tries > BACK_TRIES) return leavePlace(m)\n\t// another of the formation standing there off its own (each stood aside onto the other's, or a ring of them): it\n\t// keeps this one where it stands, and this one goes to its own instead, as `swapPlaces`\n\tconst theirs = m.formation !== undefined ? takeOver(world, entity, place, m.formation) : undefined\n\tif (theirs) m.place = theirs\n\tconst to = m.place!\n\tif (theirs || !standingOn(world, entity, to)) {\n\t\t// its place kept on the way, should it not get there (`toPlace` lets it go)\n\t\tif (m.formation !== undefined) toPlace(world, entity, to, m.formation, m.finalFacing ?? entity.facing)\n\t\telse moveTo(world, entity, to, { facing: m.finalFacing ?? entity.facing, aside: true })\n\t\tm.place = to\n\t}\n\t// a swap settles the other: no try spent\n\tif (theirs) delete m.backTries\n\telse m.backTries = tries\n\tif (m.status === 'moving') m.asideDepth = ASIDE_DEPTH\n}\n\n/** Groups bump into each other on arrival and end up looking anywhere: a unit that stopped turns to face the way it was told */\nfunction lineUp(world: World, entity: Entity, m: MovementState, dt: number): void {\n\tif (m.finalFacing === null) return\n\tentity.facing = rotateTowards(entity.facing, m.finalFacing, turnRateOf(world, entity) * dt)\n\tif (entity.facing === m.finalFacing) m.finalFacing = null\n}\n\n/** How far a unit on its way has still to go: to the edge of what it goes to, or to its point. None for a target gone */\nfunction distanceLeft(world: World, entity: Entity, m: MovementState): number | undefined {\n\tif (!m.goalEntity) return dist(entity.pos, m.goal)\n\tconst target = world.get(m.goalEntity)\n\treturn target ? edgeDistance(entity, target) : undefined\n}\n\n/**\n * Round a knot of standing units: sent on past the point beside them as it nears it, and back on its way once it is\n * past that point, or held up there\n */\nfunction steerAround(world: World, entity: Entity, m: MovementState): void {\n\tif (!m.detour) return\n\tconst near = dist(entity.pos, m.detour)\n\tconst aim = m.detourAim ?? m.navGoal\n\tconst passed = (entity.pos.x - m.detour.x) * (aim.x - m.detour.x) + (entity.pos.z - m.detour.z) * (aim.z - m.detour.z) > 0\n\tif ((m.detourPast && passed) || near <= 0.5 || m.stalledTime > 0.5 || (m.slowTime ?? 0) > 0.3) {\n\t\tm.detour = undefined\n\t\twalk(world, entity)\n\t} else if (!m.detourPast && near <= DETOUR_PAST_AT) {\n\t\tm.detourPast = true\n\t\tconst to = m.detourAim ?? m.stretch ?? m.navGoal\n\t\tlet px = to.x - m.detour.x\n\t\tlet pz = to.z - m.detour.z\n\t\tconst past = hypot(px, pz)\n\t\tif (past > DETOUR_PAST) {\n\t\t\tpx *= DETOUR_PAST / past\n\t\t\tpz *= DETOUR_PAST / past\n\t\t}\n\t\tworld.nav.setDestination(entity.id, { x: m.detour.x + px, z: m.detour.z + pz })\n\t}\n}\n\n/**\n * On a route its side planned: planned again once the side knows more (a few units a tick, by their ids), and sent on\n * a stretch further once halfway along the one it is on\n */\nfunction followRoute(world: World, entity: Entity, m: MovementState): void {\n\tif (m.detour || !(m.route || m.routeVersion !== undefined)) return\n\tconst team = sideOf(world, entity)\n\tlet again = false\n\tif (team !== undefined && m.routeVersion !== world.sidePaths!.version(team) && (entity.id + world.tick) % REPATH_SPREAD === 0) {\n\t\tplanRoute(world, entity, team)\n\t\tagain = true\n\t}\n\tif (again || (m.stretch && dist(entity.pos, m.stretch) < stretchOf(entity) / 2)) {\n\t\tconst next = m.route ? stretchPoint(entity) : m.navGoal\n\t\tif (again || !m.stretch || dist(next, m.stretch) > 0.5) walk(world, entity)\n\t}\n}\n\n/**\n * Whether a unit on its way gets anywhere: held up by others (asked aside, gone round), stalled (arrived where close is\n * good enough, or given up after a while)\n */\nfunction watchProgress(world: World, entity: Entity, m: MovementState, distance: number, dt: number): void {\n\t// a new corner to head for is not progress in itself, getting closer to it is\n\tconst progress = hypot(entity.pos.x - agent.cx, entity.pos.z - agent.cz)\n\tif (agent.cx !== m.corner.x || agent.cz !== m.corner.z) {\n\t\tm.corner.x = agent.cx\n\t\tm.corner.z = agent.cz\n\t\tm.bestDistance = progress\n\t}\n\t// held up by others: going well under its speed, once it got going and while it is not slowing to arrive\n\tconst slow = m.speed > 0 && hypot(agent.vx, agent.vz) < m.speed * SLOW_PART && distance > m.range + entity.def.radius * 2 + 0.3\n\tm.slowTime = slow && m.bestDistance < Infinity ? (m.slowTime ?? 0) + dt : 0\n\n\t// what stands in its way further on: gone round, or asked aside, before it gets there. Not while it goes round a\n\t// knot: the way it was sent was clear when it took it, and it would ask the knot aside as it passes. Nor on a\n\t// step aside, which is nobody's business\n\tif (!m.detour && !m.aside && (world.tick + entity.id) % LOOK_AHEAD_INTERVAL === 0) lookAhead(world, entity, agent)\n\n\tif (progress < m.bestDistance - 0.1) {\n\t\tm.bestDistance = progress\n\t\tm.stalledTime = 0\n\t\t// well on its way again since it last tried: it has its tries again\n\t\tif (m.tries && distance < (m.triedAt ?? Infinity) - TRIED_FAR) {\n\t\t\tdelete m.tries\n\t\t\tdelete m.triedAt\n\t\t}\n\t\tif (!m.aside && (m.slowTime ?? 0) > MAKE_WAY_AFTER && (world.tick + entity.id) % MAKE_WAY_INTERVAL === 0) makeWay(world, entity)\n\t\treturn\n\t}\n\tm.stalledTime += dt\n\tif ((!m.aside || (m.asideDepth ?? 1) < ASIDE_DEPTH) && m.stalledTime > MAKE_WAY_AFTER && (world.tick + entity.id) % MAKE_WAY_INTERVAL === 0)\n\t\tmakeWay(world, entity)\n\n\tif (!m.goalEntity) {\n\t\t// one of a formation held up by others of it: they swap places, or pass them on, rather than push through\n\t\tconst formed = m.groupId && m.formation === m.groupId && !m.aside\n\t\tif (formed && m.stalledTime > 0.25 && distance < m.range + 4 && swapPlaces(world, entity, m)) return\n\t\tif (formed && m.stalledTime > 0.25 && (world.tick + entity.id) % LOOK_AHEAD_INTERVAL === 0 && passOn(world, entity, m)) return\n\t\tif (formed && m.stalledTime > 0.25 && (world.tick + entity.id) % LOOK_AHEAD_INTERVAL === 0 && tradeGoals(world, entity, m)) return\n\t\tif (formed && m.stalledTime > MAKE_WAY_AFTER && distance < NUDGE_NEAR && (world.tick + entity.id) % MAKE_WAY_INTERVAL === 0) {\n\t\t\tnudge(world, entity, m)\n\t\t\tclearPlace(world, entity, m)\n\t\t}\n\t\t// someone standing on the destination: close enough is good enough, otherwise groups jostle forever. Not short\n\t\t// of a point nobody stands on: those in the way go aside, or it tries again\n\t\tconst taken = m.aside || (m.stalledTime > 0.25 && distance < m.range + 4 && goalTaken(world, entity, m))\n\t\tif (taken && m.stalledTime > 0.25 && distance < m.range + 4 && blockedByArrivedGroupMate(world, entity)) arrive(world, entity)\n\t\telse if (taken && m.stalledTime > 0.6 && distance < 1.25) arrive(world, entity)\n\t}\n\tif (m.status === 'moving' && m.stalledTime > HELD_UP) {\n\t\t// a walk back to its place (it has one on the way): held up near it, it stops, and walks back again later\n\t\tif (!m.goalEntity && distance < 3 && (m.aside || m.place || goalTaken(world, entity, m))) arrive(world, entity)\n\t\telse if (!m.aside && (m.tries ?? 0) < TRIES && !wayEndsShort(entity, m) && heldByUnits(world, entity)) tryAgain(world, entity, m, distance)\n\t\t// out of tries: near enough, or given up\n\t\telse if (!m.goalEntity && distance < 3) arrive(world, entity)\n\t\telse {\n\t\t\tworld.nav.clearDestination(entity.id)\n\t\t\tm.status = 'failed'\n\t\t\tm.stuck = true\n\t\t}\n\t}\n}\n\n/** Seconds a unit on its way gets nowhere before it tries again (`tryAgain`), or, out of tries, gives up */\nconst HELD_UP = 3\n/** How many times a unit held up tries again before it gives up: 4, after 15 seconds held up in all */\nconst TRIES = 4\n/** How much nearer a unit that tried again has to get to have its tries again */\nconst TRIED_FAR = 2\n\n/**\n * Whether another unit stands where a unit on its way is going: then near is as good as there, rather than push it\n * off (a group sent to one point, a unit sent where another stands)\n */\nfunction goalTaken(world: World, entity: Entity, m: MovementState): boolean {\n\treturn !!standingOn(world, entity, m.goal, true)\n}\n\n/**\n * The unit standing on a point, where another would stand, the nearest it: none where nobody does. `sameGoal` counts\n * one on its way to that very point, there already, as standing there: several sent to one point\n */\nfunction standingOn(world: World, entity: Entity, point: Vec2, sameGoal = false): Entity | undefined {\n\tworld.spatial.query(point.x, point.z, entity.def.radius + 1, roomNear)\n\tlet nearest: Entity | undefined\n\tlet best = Infinity\n\tfor (const other of roomNear) {\n\t\tif (other === entity || other.hidden || other.flying !== entity.flying || !other.get(moving)) continue\n\t\tconst om = other.get(moving)!\n\t\tconst room = entity.def.radius + other.def.radius\n\t\tif (om.status === 'moving' && !(sameGoal && hypot(om.goal.x - point.x, om.goal.z - point.z) < room)) continue\n\t\tconst d = hypot(other.pos.x - point.x, other.pos.z - point.z)\n\t\tif (d < room && d < best) {\n\t\t\tbest = d\n\t\t\tnearest = other\n\t\t}\n\t}\n\treturn nearest\n}\n\n/**\n * A unit of a formation held up near its place, with another of the formation standing on it, off its own (it stopped\n * short of it, or stepped aside onto this one): they swap. The one standing there has its place where it stands, and\n * this one goes to the other's. The formation is whole all the same, and neither pushes the other. Only those of a\n * type: a formation that places each by who it is (`FormationDef.points`) keeps them so. True when they do\n */\nfunction swapPlaces(world: World, entity: Entity, m: MovementState): boolean {\n\tconst theirs = takeOver(world, entity, m.goal, m.groupId)\n\tif (!theirs) return false\n\ttoPlace(world, entity, theirs, m.groupId, m.finalFacing)\n\treturn true\n}\n\n/**\n * The one of formation `group` standing on a place, off its own, given that place where it stands, as `swapPlaces`\n * has it: its own place, which is the other one's now, or none where nobody such stands there\n */\nfunction takeOver(world: World, entity: Entity, place: Vec2, group: number): Vec2 | undefined {\n\tconst other = standingOn(world, entity, place)\n\tconst om = other?.get(moving)\n\tif (!other || !om?.place || om.formation !== group || other.def.id !== entity.def.id || other.orders.length > 0) return\n\tif (dist(other.pos, om.place) <= PLACE_OFF || dist(om.place, place) <= PLACE_OFF) return\n\tconst theirs = om.place\n\tom.place = { x: place.x, z: place.z }\n\tdelete om.backTries\n\treturn theirs\n}\n\n/** How near its place one of a formation is for those of it it touches, ahead, to make it room (`nudge`) */\nconst NUDGE_NEAR = 1.5\n/** How far they step to make room, from where they stand: back to their places after (`backToPlace`) */\nconst NUDGE = 0.4\n\n/**\n * One of a formation held up right by its place, those of it at theirs touching it on the way there: they step a\n * little away from it to make it room, as a crowd parts, and go back to their places once it is in its own. The last\n * of a ring to come finds the gap left for it narrowed by those either side, each stopped up to `ARRIVE_RANGE` short\n */\nfunction nudge(world: World, entity: Entity, m: MovementState): void {\n\tconst dx = m.goal.x - entity.pos.x\n\tconst dz = m.goal.z - entity.pos.z\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1.5, roomNear)\n\tconst near = [...roomNear]\n\tfor (const other of near) {\n\t\tconst om = other.get(moving)\n\t\tif (other === entity || !om?.place || om.formation !== m.groupId || om.status === 'moving' || other.orders.length > 0 || om.anchored) continue\n\t\tconst rx = other.pos.x - entity.pos.x\n\t\tconst rz = other.pos.z - entity.pos.z\n\t\tconst apart = hypot(rx, rz)\n\t\tif (rx * dx + rz * dz <= 0 || apart - entity.def.radius - other.def.radius > 0.25 || apart < 0.01) continue\n\t\tconst x = other.pos.x + (rx / apart) * NUDGE\n\t\tconst z = other.pos.z + (rz / apart) * NUDGE\n\t\tif (!walkableAt(world.navFor(other), x, z)) continue\n\t\tmoveTo(world, other, { x, z }, { facing: om.finalFacing ?? other.facing, aside: true })\n\t\tom.asideDepth = ASIDE_DEPTH\n\t}\n}\n\n/**\n * One of a formation held up by its place, an ally of none of it standing there: asked aside, as the rules have it\n * (`stepAside`). A formation is laid out where it is sent, whoever stood there\n */\nfunction clearPlace(world: World, entity: Entity, m: MovementState): void {\n\tconst other = standingOn(world, entity, m.goal)\n\tif (!other || other.get(moving)!.formation === m.groupId) return\n\tconst dx = m.goal.x - entity.pos.x\n\tconst dz = m.goal.z - entity.pos.z\n\tconst length = hypot(dx, dz)\n\tif (length < 0.01 || !world.nav.readAgent(entity.id, agent)) return\n\tdirection.x = dx / length\n\tdirection.z = dz / length\n\tstepAside(world, entity, other, direction, agent)\n}\n\n/** Sends one of a formation to a place in it, as its order did: it keeps the place once there */\nfunction toPlace(world: World, entity: Entity, place: Vec2, groupId: number, facing: number | null): void {\n\tmoveTo(world, entity, place, { groupId, facing: facing ?? undefined })\n\tmovementOf(entity).formation = groupId\n}\n\n/** How much nearer its place the one standing in the way is than the one held up, for it to be passed on (`passOn`) */\nconst PASS_NEARER = 0.25\n\n/**\n * A unit of a formation held up by another of it standing at its place, on the way to its own further in: the one\n * standing goes on to that place, nearer it, and this one takes the one it leaves, right by it. The places of a ring\n * deep in the formation are filled through those already standing, a step at a time, rather than each pushing through\n * those that came first. Each pass has the one going on to the place nearer it (`PASS_NEARER`), so that it comes to an\n * end. Only to one of its type, as `swapPlaces`. True when it is passed on\n */\nfunction passOn(world: World, entity: Entity, m: MovementState): boolean {\n\tconst left = dist(entity.pos, m.goal)\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1.5, roomNear)\n\tlet best: Entity | undefined\n\tlet nearest = left - PASS_NEARER\n\tfor (const other of roomNear) {\n\t\tconst om = other.get(moving)\n\t\tif (\n\t\t\tother === entity ||\n\t\t\t!om?.place ||\n\t\t\tom.formation !== m.groupId ||\n\t\t\tother.def.id !== entity.def.id ||\n\t\t\tom.status === 'moving' ||\n\t\t\tother.orders.length > 0 ||\n\t\t\tom.anchored\n\t\t)\n\t\t\tcontinue\n\t\tif (distanceToEdge(entity.pos, other) - entity.def.radius > 0.35 || dist(other.pos, om.place) > PLACE_OFF) continue\n\t\tif (dist(entity.pos, om.place) > entity.def.radius + other.def.radius + 0.6) continue\n\t\tconst d = dist(other.pos, m.goal)\n\t\tif (d < nearest) {\n\t\t\tnearest = d\n\t\t\tbest = other\n\t\t}\n\t}\n\tif (!best) return false\n\tconst theirs = best.get(moving)!.place!\n\ttoPlace(world, best, { x: m.goal.x, z: m.goal.z }, m.groupId, m.finalFacing)\n\ttoPlace(world, entity, theirs, m.groupId, m.finalFacing)\n\treturn true\n}\n\n/** How much shorter the two ways together are for two of a formation to trade places on the way (`tradeGoals`) */\nconst TRADE_SHORTER = 0.5\n\n/**\n * Two of a formation on their way, holding each other up, each nearer the other's place than its own (they meet head\n * on, or cross): they trade places, when the two ways together are shorter by `TRADE_SHORTER`, rather than each push\n * round the other. Only with one of its type that does nothing but walk to its place, as `swapPlaces`. True when they do\n */\nfunction tradeGoals(world: World, entity: Entity, m: MovementState): boolean {\n\tconst mine = dist(entity.pos, m.goal)\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1.5, roomNear)\n\tlet best: Entity | undefined\n\tlet most = TRADE_SHORTER\n\tfor (const other of roomNear) {\n\t\tconst om = other.get(moving)\n\t\tif (\n\t\t\tother === entity ||\n\t\t\t!om ||\n\t\t\tom.status !== 'moving' ||\n\t\t\tom.aside ||\n\t\t\tom.goalEntity ||\n\t\t\tom.groupId !== m.groupId ||\n\t\t\tom.formation !== m.groupId ||\n\t\t\tother.def.id !== entity.def.id ||\n\t\t\tother.orders.length > 1 ||\n\t\t\t(other.orders.length === 1 && other.orders[0].type !== 'move') ||\n\t\t\tdistanceToEdge(entity.pos, other) - entity.def.radius > 0.35\n\t\t)\n\t\t\tcontinue\n\t\tconst shorter = mine + dist(other.pos, om.goal) - dist(entity.pos, om.goal) - dist(other.pos, m.goal)\n\t\tif (shorter > most) {\n\t\t\tmost = shorter\n\t\t\tbest = other\n\t\t}\n\t}\n\tif (!best) return false\n\tconst goal = best.get(moving)!.goal\n\tconst theirs = { x: goal.x, z: goal.z }\n\ttoPlace(world, best, { x: m.goal.x, z: m.goal.z }, m.groupId, m.finalFacing)\n\ttoPlace(world, entity, theirs, m.groupId, m.finalFacing)\n\treturn true\n}\n\n/**\n * Whether the unit stands at the end of its path, and that end is short of where it goes: the navigation knows no way\n * further (across a wood, up a cliff). Then trying again is no good\n */\nfunction wayEndsShort(entity: Entity, m: MovementState): boolean {\n\tconst to = m.stretch ?? m.navGoal\n\treturn hypot(entity.pos.x - agent.cx, entity.pos.z - agent.cz) < entity.def.radius + 0.5 && hypot(agent.cx - to.x, agent.cz - to.z) > 0.5\n}\n\n/**\n * Whether others that may yet go are what hold a unit up: one against it that is not anchored (an ally that makes way,\n * one on its way, an enemy that moves on). Not the ground, a wood, nor those holding their ground: trying again is no\n * good against them\n */\nfunction heldByUnits(world: World, entity: Entity): boolean {\n\tworld.spatial.query(entity.pos.x, entity.pos.z, entity.def.radius + 1.5, roomNear)\n\tfor (const other of roomNear) {\n\t\tconst om = other.get(moving)\n\t\tif (other === entity || !om || om.anchored || om.ghost || om.phased || other.hidden || !other.alive || other.flying !== entity.flying) continue\n\t\tif (distanceToEdge(entity.pos, other) - entity.def.radius < 0.6) return true\n\t}\n\treturn false\n}\n\n/**\n * A unit held up on its way (`HELD_UP`), where its goal is not taken, tries again rather than give up: it is sent on\n * its way anew, looks round the whole knot it is held up by for a way round, however long, and asks those of it that\n * make way aside. Out of tries (`TRIES`) it gives up: a crowd of others, or enemies, that will not let it through\n */\nfunction tryAgain(world: World, entity: Entity, m: MovementState, distance: number): void {\n\tm.tries = (m.tries ?? 0) + 1\n\tm.triedAt = distance\n\tm.stalledTime = 0\n\tm.slowTime = 0\n\tm.detour = undefined\n\twalk(world, entity)\n\t// where its path heads now, for the look round\n\tif (!world.nav.readAgent(entity.id, agent)) return\n\tm.corner.x = agent.cx\n\tm.corner.z = agent.cz\n\tm.bestDistance = hypot(entity.pos.x - agent.cx, entity.pos.z - agent.cz)\n\tlookFurther(world, entity, agent, true)\n\tif (!m.detour) makeWay(world, entity)\n}\n\nexport const movementSystem: System = {\n\tname: 'movement',\n\tphase: 'move',\n\tupdate(world, dt) {\n\t\tseeToPhasing(world)\n\t\tfollowTargets(world)\n\t\tworld.nav.update(dt)\n\t\treadAgents(world, dt)\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAeA,IAAa,eAAe;;AAG5B,IAAM,cAAc,OAAc,WAA2B,OAAO,IAAI,YAAY,MAAM,SAAS,SAAS;;;;;AA8B5G,SAAgB,cAAc,OAAc,QAAgB,QAAsB;CAEjF,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,EAAE,SAAS,KAAK;CAC3B,EAAE,UAAU;CACZ,EAAE,cAAc;CAChB,EAAE,WAAW;CACb,EAAE,SAAS,KAAA;CACX,KAAK,OAAO,MAAM;CAElB,IAAI,CAAC,MAAM,IAAI,UAAU,OAAO,IAAI,KAAK,GAAG;CAC5C,EAAE,OAAO,IAAI,MAAM;CACnB,EAAE,OAAO,IAAI,MAAM;CACnB,EAAE,eAAe,MAAM,OAAO,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,IAAI,MAAM,EAAE;CACvE,YAAY,OAAO,QAAQ,OAAO,IAAI;CACtC,IAAI,CAAC,EAAE,QAAQ,QAAQ,OAAO,MAAM;AACrC;AAEA,IAAa,iBAAyB;CACrC,MAAM;CACN,OAAO;CACP,OAAO,OAAO,IAAI;EACjB,aAAa,KAAK;EAClB,cAAc,KAAK;EACnB,MAAM,IAAI,OAAO,EAAE;EACnB,WAAW,OAAO,EAAE;CACrB;AACD"}
@@ -0,0 +1,64 @@
1
+ import { orderSays } from "../orders/facts.js";
2
+ import { constructionSite } from "./construction.js";
3
+ import { fighting } from "../entity.js";
4
+ import { isStunned } from "../abilities/buffs.js";
5
+ import { halt } from "./movement.js";
6
+ import { cancelSwing } from "./combat.js";
7
+ import { dashing } from "../dashing.js";
8
+ import { clearOrders, completeOrder } from "../orders/queue.js";
9
+ import { idle } from "../orders/idle.js";
10
+ import { controlled, steerControlled } from "../abilities/control.js";
11
+ //#region src/systems/orders.ts
12
+ /** Runs the order at the front of every queue */
13
+ var orderSystem = {
14
+ name: "orders",
15
+ phase: "decide",
16
+ update(world, dt) {
17
+ for (const entity of world.units.values()) {
18
+ if (!entity.alive || entity.isStructure && entity.has(constructionSite)) continue;
19
+ if (isStunned(world, entity)) {
20
+ if (orderSays(world, entity, "channelling")) clearOrders(world, entity);
21
+ halt(world, entity);
22
+ cancelSwing(world, entity);
23
+ continue;
24
+ }
25
+ if ((entity.buffs.length || entity.has(controlled)) && steerControlled(world, entity, dt)) continue;
26
+ const dash = entity.get(dashing);
27
+ if (dash && (dash.height || dash.pulled)) continue;
28
+ if (entity.get(fighting)?.recovery !== void 0) continue;
29
+ const order = entity.orders[0];
30
+ if (!order) {
31
+ if (!entity.hidden) idle(world, entity, dt);
32
+ continue;
33
+ }
34
+ try {
35
+ runOrder(world, entity, order, dt);
36
+ } catch (error) {
37
+ world.caught(error, {
38
+ kind: "order",
39
+ id: order.type,
40
+ entity: entity.id
41
+ });
42
+ dropOrder(world, entity, order);
43
+ }
44
+ }
45
+ }
46
+ };
47
+ /** Takes an order that threw off its unit, without asking the order anything more: it stands where it is */
48
+ function dropOrder(world, entity, order) {
49
+ entity.removeOrder(order);
50
+ if (entity.alive) halt(world, entity);
51
+ }
52
+ /** One tick of an order: started when it has not been, and taken off the queue when it is over */
53
+ function runOrder(world, entity, order, dt) {
54
+ const behavior = world.registry.order(order.type);
55
+ if (!order.started) {
56
+ order.started = true;
57
+ behavior.start?.(world, entity, order);
58
+ }
59
+ if (behavior.update(world, entity, order, dt) !== "running" && entity.alive) completeOrder(world, entity, order);
60
+ }
61
+ //#endregion
62
+ export { orderSystem, runOrder };
63
+
64
+ //# sourceMappingURL=orders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.js","names":[],"sources":["../../src/systems/orders.ts"],"sourcesContent":["import { clearOrders } from '#engine/orders/queue'\nimport { orderSays } from '../orders/facts'\nimport { constructionSite } from './construction'\nimport { isStunned } from '#engine/abilities/buffs'\nimport { idle } from '#engine/orders/idle'\nimport { completeOrder } from '#engine/orders/queue'\nimport type { Entity, Order } from '#engine/entity'\nimport type { System } from '#engine/registry'\nimport type { World } from '#engine/world'\nimport { cancelSwing } from './combat'\nimport { fighting } from '#engine/entity'\nimport { halt } from './movement'\nimport { dashing } from '../dashing'\nimport { controlled, steerControlled } from '#engine/abilities/control'\n\n/** Runs the order at the front of every queue */\nexport const orderSystem: System = {\n\tname: 'orders',\n\tphase: 'decide',\n\tupdate(world, dt) {\n\t\tfor (const entity of world.units.values()) {\n\t\t\t// (a site is a structure's: what moves is never one, and is most of what there is)\n\t\t\tif (!entity.alive || (entity.isStructure && entity.has(constructionSite))) continue\n\t\t\tif (isStunned(world, entity)) {\n\t\t\t\t// out cold: whatever it was doing waits, but what it was keeping up is broken off\n\t\t\t\tif (orderSays(world, entity, 'channelling')) clearOrders(world, entity)\n\t\t\t\thalt(world, entity)\n\t\t\t\tcancelSwing(world, entity)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// a buff takes its orders (fear, charm, taunt): what it was told waits, and goes on once it lets go\n\t\t\tif ((entity.buffs.length || entity.has(controlled)) && steerControlled(world, entity, dt)) continue\n\t\t\t// in the air, on a leap or thrown, or dragged by a pull: what it was doing goes on when it is let go\n\t\t\tconst dash = entity.get(dashing)\n\t\t\tif (dash && (dash.height || dash.pulled)) continue\n\t\t\t// in the recovery after a blow (`AttackDef.recovery`): held, what it was told waits until it is over\n\t\t\tif (entity.get(fighting)?.recovery !== undefined) continue\n\t\t\tconst order = entity.orders[0]\n\t\t\tif (!order) {\n\t\t\t\tif (!entity.hidden) idle(world, entity, dt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ttry {\n\t\t\t\trunOrder(world, entity, order, dt)\n\t\t\t} catch (error) {\n\t\t\t\t// what the world says of errors (`World.caught`): it throws, or the order is taken off the unit\n\t\t\t\tworld.caught(error, { kind: 'order', id: order.type, entity: entity.id })\n\t\t\t\tdropOrder(world, entity, order)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Takes an order that threw off its unit, without asking the order anything more: it stands where it is */\nfunction dropOrder(world: World, entity: Entity, order: Order): void {\n\tentity.removeOrder(order)\n\tif (entity.alive) halt(world, entity)\n}\n\n/** One tick of an order: started when it has not been, and taken off the queue when it is over */\nexport function runOrder(world: World, entity: Entity, order: Order, dt: number): void {\n\tconst behavior = world.registry.order(order.type)\n\tif (!order.started) {\n\t\torder.started = true\n\t\tbehavior.start?.(world, entity, order)\n\t}\n\tconst status = behavior.update(world, entity,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AChB,SAAS,QAAQ,OAAO,QAAQ,KAAK;CACtC;CAEA,IADe,SAAS,OAAO,OAAO,QAAQ,OAAO,EACjD,MAAW,aAAa,OAAO,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC7E"}
@@ -0,0 +1,322 @@
1
+ import { atan2 } from "../exactMath.js";
2
+ import { closestPointOnRect } from "../math.js";
3
+ import { supplyPoolsOf, upgradesOf } from "../defs.js";
4
+ import { morphStarted, researchFinished, unitTrained } from "../engineEvents.js";
5
+ import { replicateEvent } from "../replication.js";
6
+ import { deposit } from "../entity.js";
7
+ import { shortOf, spend } from "../player.js";
8
+ import { engineMessage } from "../messages.js";
9
+ import { trainRefusal } from "../shared.js";
10
+ import { giveBack, productionOf, productionQueue } from "./productionQueue.js";
11
+ import { heroState, heroesOf, reviveCost, reviveHero } from "../hero.js";
12
+ import { createOrder, giveOrder } from "../orders/queue.js";
13
+ import { gathering } from "../orders/harvest.js";
14
+ import { morph, techOf, unlocked } from "../tech.js";
15
+ //#region src/systems/production.ts
16
+ function hasRoom(world, building) {
17
+ if (productionOf(building).queue.length < world.settings.production.queue) return true;
18
+ world.message(building.owner, engineMessage("queueFull"));
19
+ return false;
20
+ }
21
+ /**
22
+ * Lets the `beforeProduce` hook have its say about something about to be made, then has the player pay for it.
23
+ * What it ends up costing and how long it takes, or undefined when it is not made (and the player was told why).
24
+ * `producer` is the building it is made in, or the worker putting down a structure
25
+ */
26
+ function startProducing(world, producer, kind, id, cost, time) {
27
+ const player = world.player(producer.owner);
28
+ const event = world.hooks.run("beforeProduce", {
29
+ player: player.id,
30
+ producer,
31
+ kind,
32
+ id,
33
+ cost: { ...cost },
34
+ time,
35
+ cancelled: false
36
+ });
37
+ if (event.cancelled) {
38
+ if (event.reason) world.message(player.id, event.reason);
39
+ return;
40
+ }
41
+ const short = shortOf(player.resources, event.cost);
42
+ if (short) {
43
+ world.message(player.id, engineMessage("notEnough", { resource: short }));
44
+ return;
45
+ }
46
+ spend(world, player.id, event.cost, kind, id);
47
+ return event;
48
+ }
49
+ /** Queues a unit for training. Returns false (and tells the player why) when that is not possible. */
50
+ function enqueueProduction(world, building, unitType) {
51
+ const production = productionOf(building);
52
+ if (!production || !building.operational || !building.def.trains?.includes(unitType)) return false;
53
+ const def = world.registry.unit(unitType);
54
+ const player = world.player(building.owner);
55
+ if (!hasRoom(world, building)) return false;
56
+ if (!unlocked(world, player.id, "unit", unitType, def.requires)) return false;
57
+ const refusal = trainRefusal(world.registry, def, playerFacts(world, player.id), {
58
+ cost: false,
59
+ tech: false
60
+ });
61
+ if (refusal) {
62
+ world.message(player.id, refusal);
63
+ return false;
64
+ }
65
+ const supply = world.settings.supply.of(world, {
66
+ def,
67
+ owner: player.id,
68
+ queued: true
69
+ });
70
+ const made = startProducing(world, building, "unit", unitType, def.cost, def.buildTime ?? 1);
71
+ if (!made) return false;
72
+ player.supplyUsed += supply;
73
+ const pools = supplyPoolsOf(def);
74
+ for (const name in pools) if (player.supplies[name]) player.supplies[name].used += pools[name];
75
+ production.queue.push({
76
+ kind: "unit",
77
+ id: unitType,
78
+ paid: made.cost,
79
+ progress: 0,
80
+ duration: made.time
81
+ });
82
+ return true;
83
+ }
84
+ /**
85
+ * What there is to know about a player for whether they can make something, see `trainRefusal`
86
+ *
87
+ * @beta
88
+ */
89
+ function playerFacts(world, playerId) {
90
+ const player = world.player(playerId);
91
+ const heroes = heroesOf(world, playerId).map((hero) => hero.def.id);
92
+ for (const other of world.index.ownedBy(playerId)) {
93
+ const production = productionOf(other);
94
+ if (!production) continue;
95
+ for (const item of production.queue) if (item.kind === "unit" && world.registry.unit(item.id).hero) heroes.push(item.id);
96
+ }
97
+ return {
98
+ resources: player.resources,
99
+ supplyUsed: player.supplyUsed,
100
+ supplyCap: player.supplyCap,
101
+ ...Object.keys(player.supplies).length > 0 && { supplies: player.supplies },
102
+ tech: techOf(world, playerId),
103
+ heroes,
104
+ ...player.race !== void 0 && { race: player.race }
105
+ };
106
+ }
107
+ /**
108
+ * Levels of an upgrade a player has, counting the one being researched
109
+ *
110
+ * @beta
111
+ */
112
+ function upgradeLevel(world, playerId, upgrade) {
113
+ const player = world.player(playerId);
114
+ return {
115
+ level: player.upgrades.get(upgrade) ?? 0,
116
+ researching: player.researching.has(upgrade)
117
+ };
118
+ }
119
+ /** Queues an upgrade. One level at a time, and only in one building at once. */
120
+ function enqueueResearch(world, building, upgrade) {
121
+ const production = productionOf(building);
122
+ if (!production || !building.operational || !building.def.researches?.includes(upgrade)) return false;
123
+ const def = world.registry.upgrade(upgrade);
124
+ const player = world.player(building.owner);
125
+ const { level, researching } = upgradeLevel(world, player.id, upgrade);
126
+ if (researching) {
127
+ world.message(player.id, engineMessage("alreadyResearching"));
128
+ return false;
129
+ }
130
+ if (level >= (def.maxLevel ?? 1)) return false;
131
+ if (!unlocked(world, player.id, "upgrade", upgrade, def.requires?.[level], level + 1)) return false;
132
+ if (!hasRoom(world, building)) return false;
133
+ const made = startProducing(world, building, "upgrade", upgrade, def.cost, def.researchTime);
134
+ if (!made) return false;
135
+ player.researching.add(upgrade);
136
+ production.queue.push({
137
+ kind: "upgrade",
138
+ id: upgrade,
139
+ paid: made.cost,
140
+ progress: 0,
141
+ duration: made.time
142
+ });
143
+ return true;
144
+ }
145
+ /** Queues bringing a fallen hero back */
146
+ function enqueueRevive(world, building, heroId) {
147
+ const production = productionOf(building);
148
+ const hero = world.entities.get(heroId);
149
+ if (!production || !building.operational || !building.def.revives) return false;
150
+ if (!hero?.has(heroState) || hero.alive || hero.owner !== building.owner || hero.reviving) return false;
151
+ const { cost, time } = reviveCost(world, hero);
152
+ if (!hasRoom(world, building)) return false;
153
+ const made = startProducing(world, building, "revive", String(heroId), cost, time);
154
+ if (!made) return false;
155
+ hero.reviving = true;
156
+ production.queue.push({
157
+ kind: "revive",
158
+ id: String(heroId),
159
+ paid: made.cost,
160
+ progress: 0,
161
+ duration: made.time
162
+ });
163
+ return true;
164
+ }
165
+ /**
166
+ * Queues upgrading a building into a type it can become (`UnitTypeDef.upgradesTo`): `into`, one of them, or the first
167
+ * where none is named. One at a time
168
+ */
169
+ function enqueueMorph(world, building, into = upgradesOf(building.def)[0]) {
170
+ const production = productionOf(building);
171
+ if (!production || !building.operational || into === void 0 || !upgradesOf(building.def).includes(into)) return false;
172
+ if (production.queue.some((item) => item.kind === "morph")) return false;
173
+ const def = world.registry.unit(into);
174
+ if (!unlocked(world, building.owner, "unit", into, def.requires) || !hasRoom(world, building)) return false;
175
+ const made = startProducing(world, building, "morph", into, def.cost, def.buildTime ?? 1);
176
+ if (!made) return false;
177
+ production.queue.push({
178
+ kind: "morph",
179
+ id: into,
180
+ paid: made.cost,
181
+ progress: 0,
182
+ duration: made.time
183
+ });
184
+ world.events.emit(morphStarted, {
185
+ entity: building,
186
+ into,
187
+ time: made.time
188
+ });
189
+ return true;
190
+ }
191
+ function cancelProduction(world, building, index) {
192
+ const production = productionOf(building);
193
+ const item = production?.queue[index];
194
+ if (!production || !item) return false;
195
+ production.queue.splice(index, 1);
196
+ giveBack(world, building, item);
197
+ return true;
198
+ }
199
+ /** Where what a building produced comes out: on the side of its rally point */
200
+ function exitOf(world, building, radius) {
201
+ const rally = productionOf(building).rally;
202
+ const towards = world.get(rally?.target)?.pos ?? rally?.point ?? {
203
+ x: building.pos.x,
204
+ z: building.pos.z - 100
205
+ };
206
+ return {
207
+ exit: closestPointOnRect(towards, building.rect, radius + .3),
208
+ towards
209
+ };
210
+ }
211
+ function finishUnit(world, building, unitType) {
212
+ const def = world.registry.unit(unitType);
213
+ const rally = productionOf(building).rally;
214
+ const rallyTarget = world.get(rally?.target);
215
+ const { exit, towards } = exitOf(world, building, def.radius);
216
+ const unit = world.spawn(unitType, building.owner, exit, { facing: atan2(towards.x - exit.x, towards.z - exit.z) });
217
+ world.events.emit(unitTrained, {
218
+ building,
219
+ unit
220
+ });
221
+ world.hooks.run("produced", {
222
+ producer: building,
223
+ kind: "unit",
224
+ id: unitType,
225
+ unit
226
+ });
227
+ if (!rally) return;
228
+ if (rallyTarget?.get(deposit) && unit.has(gathering)) giveOrder(world, unit, createOrder(world, {
229
+ type: "harvest",
230
+ target: rallyTarget.id
231
+ }));
232
+ else if (rallyTarget && rallyTarget.isUnit) giveOrder(world, unit, createOrder(world, {
233
+ type: "move",
234
+ target: rallyTarget.id
235
+ }));
236
+ else giveOrder(world, unit, createOrder(world, {
237
+ type: "move",
238
+ point: rally.point
239
+ }));
240
+ }
241
+ function finishUpgrade(world, building, upgrade) {
242
+ const player = world.player(building.owner);
243
+ const level = (player.upgrades.get(upgrade) ?? 0) + 1;
244
+ player.setUpgrade(upgrade, level);
245
+ player.researching.delete(upgrade);
246
+ const { apply } = world.registry.upgrade(upgrade);
247
+ if (apply) {
248
+ for (const entity of [...world.index.ownedBy(player.id)]) if (entity.alive) apply(world, entity, level);
249
+ }
250
+ world.events.emit(researchFinished, {
251
+ building,
252
+ upgrade,
253
+ level
254
+ });
255
+ world.hooks.run("produced", {
256
+ producer: building,
257
+ kind: "upgrade",
258
+ id: upgrade,
259
+ level
260
+ });
261
+ world.message(player.id, engineMessage("researchDone", { upgrade }), "info");
262
+ }
263
+ var productionSystem = {
264
+ name: "production",
265
+ phase: "resolve",
266
+ over: productionQueue,
267
+ each(world, entity, dt) {
268
+ const production = productionOf(entity);
269
+ if (!production || !entity.operational || entity.scenery) return;
270
+ const item = production.queue[0];
271
+ if (!item) return;
272
+ item.progress += dt;
273
+ if (item.progress < item.duration) return;
274
+ production.queue.shift();
275
+ if (item.kind === "unit") finishUnit(world, entity, item.id);
276
+ else if (item.kind === "upgrade") finishUpgrade(world, entity, item.id);
277
+ else if (item.kind === "morph") {
278
+ morph(world, entity, item.id);
279
+ world.hooks.run("produced", {
280
+ producer: entity,
281
+ kind: "morph",
282
+ id: item.id,
283
+ unit: entity
284
+ });
285
+ } else {
286
+ const hero = world.entities.get(Number(item.id));
287
+ if (hero) {
288
+ reviveHero(world, hero, exitOf(world, entity, hero.def.radius).exit);
289
+ world.hooks.run("produced", {
290
+ producer: entity,
291
+ kind: "revive",
292
+ id: item.id,
293
+ unit: hero
294
+ });
295
+ }
296
+ }
297
+ }
298
+ };
299
+ /** A unit made, to those who see it */
300
+ var toldTrained = replicateEvent(unitTrained, "trained", ({ building, unit }, view) => view.knows(unit) ? {
301
+ type: "trained",
302
+ id: unit.id,
303
+ building: view.knows(building) ? building.id : void 0
304
+ } : void 0);
305
+ /** Research done: to its side */
306
+ var toldResearched = replicateEvent(researchFinished, "researched", ({ building, upgrade, level }, view) => view.isAlly(building.owner) ? {
307
+ type: "researched",
308
+ upgrade,
309
+ level,
310
+ building: building.id
311
+ } : void 0);
312
+ /** A building starting to become another, to those who see it */
313
+ var toldUpgradeStarted = replicateEvent(morphStarted, "upgradeStarted", ({ entity, into, time }, view) => view.knows(entity) ? {
314
+ type: "upgradeStarted",
315
+ id: entity.id,
316
+ to: into,
317
+ time
318
+ } : void 0);
319
+ //#endregion
320
+ export { cancelProduction, enqueueMorph, enqueueProduction, enqueueResearch, enqueueRevive, playerFacts, productionSystem, startProducing, toldResearched, toldTrained, toldUpgradeStarted, upgradeLevel };
321
+
322
+ //# sourceMappingURL=production.js.map