@v12-engine/engine 0.0.0-stage → 0.1.1

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 (341) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abilities/buffs.d.ts +83 -0
  3. package/dist/abilities/castTold.d.ts +12 -0
  4. package/dist/abilities/charges.d.ts +28 -0
  5. package/dist/abilities/dispel.d.ts +9 -0
  6. package/dist/abilities/effectFields.d.ts +10 -0
  7. package/dist/abilities/effects/buff.d.ts +8 -0
  8. package/dist/abilities/effects/core.d.ts +1 -0
  9. package/dist/abilities/effects/damage.d.ts +1 -0
  10. package/dist/abilities/effects/heal.d.ts +2 -0
  11. package/dist/abilities/effects/missile.d.ts +1 -0
  12. package/dist/abilities/effects/moves.d.ts +11 -0
  13. package/dist/abilities/effects/passives.d.ts +15 -0
  14. package/dist/abilities/effects/sight.d.ts +4 -0
  15. package/dist/abilities/effects/spawn.d.ts +2 -0
  16. package/dist/abilities/effects/timed.d.ts +4 -0
  17. package/dist/abilities/effects/trade.d.ts +1 -0
  18. package/dist/abilities/effects.d.ts +122 -0
  19. package/dist/abilities/land.d.ts +21 -0
  20. package/dist/abilities/scaled.d.ts +21 -0
  21. package/dist/abilities/text.d.ts +113 -0
  22. package/dist/ai/area.d.ts +53 -0
  23. package/dist/ai/brain.d.ts +528 -0
  24. package/dist/ai/budget.d.ts +67 -0
  25. package/dist/ai/checks.d.ts +115 -0
  26. package/dist/ai/computer.d.ts +166 -0
  27. package/dist/ai/defence.d.ts +108 -0
  28. package/dist/ai/define.d.ts +21 -0
  29. package/dist/ai/economy.d.ts +129 -0
  30. package/dist/ai/geometry.d.ts +35 -0
  31. package/dist/ai/goals.d.ts +360 -0
  32. package/dist/ai/index.d.ts +38 -0
  33. package/dist/ai/knowledge.d.ts +418 -0
  34. package/dist/ai/lanes.d.ts +232 -0
  35. package/dist/ai/melee/build.d.ts +61 -0
  36. package/dist/ai/melee/goals.d.ts +299 -0
  37. package/dist/ai/melee/heroes.d.ts +27 -0
  38. package/dist/ai/melee/index.d.ts +14 -0
  39. package/dist/ai/melee/production.d.ts +8 -0
  40. package/dist/ai/melee/surrender.d.ts +24 -0
  41. package/dist/ai/micro.d.ts +278 -0
  42. package/dist/ai/mission.d.ts +195 -0
  43. package/dist/ai/missionRules.d.ts +18 -0
  44. package/dist/ai/module.d.ts +116 -0
  45. package/dist/ai/options.d.ts +61 -0
  46. package/dist/ai/plans/build.d.ts +280 -0
  47. package/dist/ai/plans/placement.d.ts +82 -0
  48. package/dist/ai/plans/plans.d.ts +105 -0
  49. package/dist/ai/plans/production.d.ts +210 -0
  50. package/dist/ai/plans/purse.d.ts +73 -0
  51. package/dist/ai/plans/tech.d.ts +37 -0
  52. package/dist/ai/profiles.d.ts +204 -0
  53. package/dist/ai/reach.d.ts +4 -0
  54. package/dist/ai/report.d.ts +203 -0
  55. package/dist/ai/roles.d.ts +133 -0
  56. package/dist/ai/rules.d.ts +288 -0
  57. package/dist/ai/scouting.d.ts +98 -0
  58. package/dist/ai/settings.d.ts +73 -0
  59. package/dist/ai/squads.d.ts +429 -0
  60. package/dist/ai/strength.d.ts +167 -0
  61. package/dist/ai/task.d.ts +118 -0
  62. package/dist/ai/tasks/attack.d.ts +7 -0
  63. package/dist/ai/tasks/capture.d.ts +21 -0
  64. package/dist/ai/tasks/creep.d.ts +16 -0
  65. package/dist/ai/tasks/defend.d.ts +29 -0
  66. package/dist/ai/tasks/drop.d.ts +34 -0
  67. package/dist/ai/tasks/escort.d.ts +16 -0
  68. package/dist/ai/tasks/gather.d.ts +23 -0
  69. package/dist/ai/tasks/harass.d.ts +7 -0
  70. package/dist/ai/tasks/hold.d.ts +20 -0
  71. package/dist/ai/tasks/index.d.ts +32 -0
  72. package/dist/ai/tasks/move.d.ts +19 -0
  73. package/dist/ai/tasks/patrol.d.ts +8 -0
  74. package/dist/ai/tasks/retreat.d.ts +20 -0
  75. package/dist/ai/tasks/scout.d.ts +29 -0
  76. package/dist/ai/tasks/shared.d.ts +74 -0
  77. package/dist/ai/team.d.ts +155 -0
  78. package/dist/ai/threat.d.ts +91 -0
  79. package/dist/ai/view.d.ts +366 -0
  80. package/dist/ai/waves.d.ts +126 -0
  81. package/dist/ai.js +6239 -0
  82. package/dist/ai.js.map +1 -0
  83. package/dist/aiTesting.d.ts +179 -0
  84. package/dist/areas.d.ts +149 -0
  85. package/dist/attacks.d.ts +66 -0
  86. package/dist/attributes.d.ts +66 -0
  87. package/dist/brain-BvVdUhX8.js +7659 -0
  88. package/dist/brain-BvVdUhX8.js.map +1 -0
  89. package/dist/builds-C6LfgvEU.js +460 -0
  90. package/dist/builds-C6LfgvEU.js.map +1 -0
  91. package/dist/bytes.d.ts +6 -0
  92. package/dist/camps.d.ts +95 -0
  93. package/dist/capture.d.ts +131 -0
  94. package/dist/cellLayers.d.ts +75 -0
  95. package/dist/cinematics.d.ts +194 -0
  96. package/dist/clock.d.ts +32 -0
  97. package/dist/commands.d.ts +235 -0
  98. package/dist/components.d.ts +184 -0
  99. package/dist/computers.d.ts +108 -0
  100. package/dist/concealment.d.ts +61 -0
  101. package/dist/coreComponents-syuh2fPG.js +5149 -0
  102. package/dist/coreComponents-syuh2fPG.js.map +1 -0
  103. package/dist/coreComponents.d.ts +1 -0
  104. package/dist/dashing.d.ts +8 -0
  105. package/dist/debug.d.ts +36 -0
  106. package/dist/debug.js +3 -0
  107. package/dist/debugCommands-CzjrSm66.js +14739 -0
  108. package/dist/debugCommands-CzjrSm66.js.map +1 -0
  109. package/dist/debugCommands.d.ts +213 -0
  110. package/dist/debugging.d.ts +10 -0
  111. package/dist/definitions.d.ts +43 -0
  112. package/dist/defs.d.ts +1162 -0
  113. package/dist/denying.d.ts +81 -0
  114. package/dist/destructibles.d.ts +27 -0
  115. package/dist/determinism-BCymQwiE.js +518 -0
  116. package/dist/determinism-BCymQwiE.js.map +1 -0
  117. package/dist/determinism.d.ts +121 -0
  118. package/dist/dialog.d.ts +94 -0
  119. package/dist/effectRefs.d.ts +16 -0
  120. package/dist/effects.d.ts +80 -0
  121. package/dist/endings.d.ts +22 -0
  122. package/dist/engagement.d.ts +108 -0
  123. package/dist/engineEvents.d.ts +710 -0
  124. package/dist/entity.d.ts +409 -0
  125. package/dist/entityIndex.d.ts +50 -0
  126. package/dist/errors.d.ts +85 -0
  127. package/dist/events.d.ts +97 -0
  128. package/dist/exactMath.d.ts +63 -0
  129. package/dist/features.d.ts +10 -0
  130. package/dist/fields.d.ts +114 -0
  131. package/dist/fixture.d.ts +17 -0
  132. package/dist/fog.d.ts +110 -0
  133. package/dist/formation.d.ts +111 -0
  134. package/dist/friendlyFire.d.ts +26 -0
  135. package/dist/game-DiJEN-Ks.js +5800 -0
  136. package/dist/game-DiJEN-Ks.js.map +1 -0
  137. package/dist/game.d.ts +501 -0
  138. package/dist/gameData.d.ts +325 -0
  139. package/dist/gameFiles.d.ts +26 -0
  140. package/dist/gates.d.ts +28 -0
  141. package/dist/generate.d.ts +403 -0
  142. package/dist/generateWorker.d.ts +39 -0
  143. package/dist/grid.d.ts +53 -0
  144. package/dist/ground.d.ts +127 -0
  145. package/dist/groundSpeed.d.ts +22 -0
  146. package/dist/hero.d.ts +177 -0
  147. package/dist/home.d.ts +14 -0
  148. package/dist/hooks.d.ts +780 -0
  149. package/dist/hotReload.d.ts +76 -0
  150. package/dist/ids.d.ts +26 -0
  151. package/dist/index.d.ts +227 -0
  152. package/dist/index.js +4701 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/inspect-D9dWHmZ0.js +491 -0
  155. package/dist/inspect-D9dWHmZ0.js.map +1 -0
  156. package/dist/inspect.d.ts +176 -0
  157. package/dist/inventory.d.ts +18 -0
  158. package/dist/items.d.ts +91 -0
  159. package/dist/lanes.d.ts +213 -0
  160. package/dist/life.d.ts +53 -0
  161. package/dist/local-Dkovq42k.js +1379 -0
  162. package/dist/local-Dkovq42k.js.map +1 -0
  163. package/dist/log.d.ts +140 -0
  164. package/dist/manaBurn.d.ts +39 -0
  165. package/dist/map/file.d.ts +114 -0
  166. package/dist/map/images.d.ts +18 -0
  167. package/dist/map/look.d.ts +47 -0
  168. package/dist/map/pathProfile.d.ts +13 -0
  169. package/dist/map/resize.d.ts +54 -0
  170. package/dist/map/schema.d.ts +10 -0
  171. package/dist/map/terrain.d.ts +32 -0
  172. package/dist/map/types.d.ts +613 -0
  173. package/dist/map.d.ts +7 -0
  174. package/dist/mapCheck/cells.d.ts +19 -0
  175. package/dist/mapCheck/rule.d.ts +30 -0
  176. package/dist/mapCheck/rules/names.d.ts +3 -0
  177. package/dist/mapCheck/rules/objects.d.ts +3 -0
  178. package/dist/mapCheck/rules/paths.d.ts +3 -0
  179. package/dist/mapCheck/rules/players.d.ts +3 -0
  180. package/dist/mapCheck/rules/races.d.ts +3 -0
  181. package/dist/mapCheck/rules/random.d.ts +3 -0
  182. package/dist/mapCheck/rules/regions.d.ts +3 -0
  183. package/dist/mapCheck/rules/targets.d.ts +3 -0
  184. package/dist/mapCheck/rules/walking.d.ts +3 -0
  185. package/dist/mapCheck.d.ts +23 -0
  186. package/dist/mapFields.d.ts +364 -0
  187. package/dist/mapFile.d.ts +23 -0
  188. package/dist/mapMeasure.d.ts +95 -0
  189. package/dist/mapMerge.d.ts +19 -0
  190. package/dist/mapObjectives.d.ts +82 -0
  191. package/dist/mapObjects.d.ts +1 -0
  192. package/dist/math.d.ts +44 -0
  193. package/dist/messages.d.ts +150 -0
  194. package/dist/missionRules-C-bGxm0Q.js +523 -0
  195. package/dist/missionRules-C-bGxm0Q.js.map +1 -0
  196. package/dist/missionRules.d.ts +179 -0
  197. package/dist/mods.d.ts +146 -0
  198. package/dist/names.d.ts +93 -0
  199. package/dist/navigation/agentParams.d.ts +4 -0
  200. package/dist/navigation/air.d.ts +89 -0
  201. package/dist/navigation/builds.d.ts +140 -0
  202. package/dist/navigation/groundAreas.d.ts +23 -0
  203. package/dist/navigation/navigation.d.ts +127 -0
  204. package/dist/navigation/recast.d.ts +214 -0
  205. package/dist/navigation/sidePaths.d.ts +69 -0
  206. package/dist/navigation/sized.d.ts +1 -0
  207. package/dist/navigation-worker.js +11 -0
  208. package/dist/navigation-worker.js.map +1 -0
  209. package/dist/nearest.d.ts +8 -0
  210. package/dist/noise.d.ts +12 -0
  211. package/dist/objectives.d.ts +93 -0
  212. package/dist/orders/basic.d.ts +96 -0
  213. package/dist/orders/build.d.ts +91 -0
  214. package/dist/orders/cast.d.ts +105 -0
  215. package/dist/orders/facts.d.ts +14 -0
  216. package/dist/orders/harvest.d.ts +94 -0
  217. package/dist/orders/idle.d.ts +7 -0
  218. package/dist/orders/items.d.ts +14 -0
  219. package/dist/orders/queue.d.ts +24 -0
  220. package/dist/pack.schema.json +6621 -0
  221. package/dist/packs/director/index.d.ts +81 -0
  222. package/dist/packs/heroes/campaign.d.ts +137 -0
  223. package/dist/packs/heroes/carry.d.ts +59 -0
  224. package/dist/packs/heroes/commands.d.ts +6 -0
  225. package/dist/packs/heroes/hire.d.ts +9 -0
  226. package/dist/packs/heroes/index.d.ts +12 -0
  227. package/dist/packs/heroes/making.d.ts +16 -0
  228. package/dist/packs/heroes/respawn.d.ts +42 -0
  229. package/dist/packs/moba/index.d.ts +34 -0
  230. package/dist/packs/pack.d.ts +84 -0
  231. package/dist/packs-g5thvmGn.js +3199 -0
  232. package/dist/packs-g5thvmGn.js.map +1 -0
  233. package/dist/packs.d.ts +84 -0
  234. package/dist/paths.d.ts +51 -0
  235. package/dist/plain.d.ts +17 -0
  236. package/dist/player.d.ts +117 -0
  237. package/dist/portals.d.ts +66 -0
  238. package/dist/prefabs.d.ts +139 -0
  239. package/dist/presetBuildings.d.ts +52 -0
  240. package/dist/presetGround.d.ts +22 -0
  241. package/dist/profiles-B3NS9jwk.js +335 -0
  242. package/dist/profiles-B3NS9jwk.js.map +1 -0
  243. package/dist/races.d.ts +136 -0
  244. package/dist/randomGroups.d.ts +2 -0
  245. package/dist/registry.d.ts +464 -0
  246. package/dist/remains.d.ts +119 -0
  247. package/dist/replication.d.ts +103 -0
  248. package/dist/rng.d.ts +17 -0
  249. package/dist/rules.d.ts +395 -0
  250. package/dist/rulesCheck.d.ts +37 -0
  251. package/dist/runes.d.ts +41 -0
  252. package/dist/save.d.ts +277 -0
  253. package/dist/scenario.d.ts +56 -0
  254. package/dist/scheduler.d.ts +67 -0
  255. package/dist/score.d.ts +306 -0
  256. package/dist/sequences.d.ts +132 -0
  257. package/dist/server/doorman.d.ts +21 -0
  258. package/dist/server/gameServer.d.ts +346 -0
  259. package/dist/server/index.d.ts +24 -0
  260. package/dist/server/lobby.d.ts +1 -0
  261. package/dist/server/log.d.ts +13 -0
  262. package/dist/server/match.d.ts +24 -0
  263. package/dist/server/mode.d.ts +168 -0
  264. package/dist/server/navigation-worker.d.ts +1 -0
  265. package/dist/server/navigation.d.ts +11 -0
  266. package/dist/server/ops.d.ts +78 -0
  267. package/dist/server/packs.d.ts +15 -0
  268. package/dist/server/ratings.d.ts +62 -0
  269. package/dist/server/relay.d.ts +34 -0
  270. package/dist/server/rooms.d.ts +162 -0
  271. package/dist/server/seat.d.ts +2 -0
  272. package/dist/server/seatSettings.d.ts +15 -0
  273. package/dist/server/secret.d.ts +5 -0
  274. package/dist/server/start.d.ts +54 -0
  275. package/dist/server/websocket.d.ts +74 -0
  276. package/dist/server.js +2861 -0
  277. package/dist/server.js.map +1 -0
  278. package/dist/session/can.d.ts +20 -0
  279. package/dist/session/commandReplay.d.ts +92 -0
  280. package/dist/session/debug.d.ts +65 -0
  281. package/dist/session/delay.d.ts +15 -0
  282. package/dist/session/delta.d.ts +98 -0
  283. package/dist/session/entityState.d.ts +1 -0
  284. package/dist/session/local.d.ts +214 -0
  285. package/dist/session/memory.d.ts +27 -0
  286. package/dist/session/protocol.d.ts +1155 -0
  287. package/dist/session/remote.d.ts +530 -0
  288. package/dist/session/replay.d.ts +114 -0
  289. package/dist/session/seed.d.ts +7 -0
  290. package/dist/session/share.d.ts +78 -0
  291. package/dist/session/socket.d.ts +8 -0
  292. package/dist/session/wire.d.ts +153 -0
  293. package/dist/session/worker.d.ts +227 -0
  294. package/dist/shared.d.ts +171 -0
  295. package/dist/sides.d.ts +75 -0
  296. package/dist/sight.d.ts +27 -0
  297. package/dist/simulate-oXBiw1Ff.js +167 -0
  298. package/dist/simulate-oXBiw1Ff.js.map +1 -0
  299. package/dist/simulate-worker.d.ts +1 -0
  300. package/dist/simulate-worker.js +28 -0
  301. package/dist/simulate-worker.js.map +1 -0
  302. package/dist/simulate.d.ts +154 -0
  303. package/dist/smart.d.ts +9 -0
  304. package/dist/spatial.d.ts +62 -0
  305. package/dist/spawning.d.ts +33 -0
  306. package/dist/stances.d.ts +76 -0
  307. package/dist/start.d.ts +71 -0
  308. package/dist/stats.d.ts +122 -0
  309. package/dist/summons.d.ts +63 -0
  310. package/dist/systems/abilities.d.ts +3 -0
  311. package/dist/systems/combat.d.ts +71 -0
  312. package/dist/systems/combatTold.d.ts +14 -0
  313. package/dist/systems/construction.d.ts +34 -0
  314. package/dist/systems/economy.d.ts +21 -0
  315. package/dist/systems/fog.d.ts +19 -0
  316. package/dist/systems/life.d.ts +3 -0
  317. package/dist/systems/movement.d.ts +105 -0
  318. package/dist/systems/orders.d.ts +7 -0
  319. package/dist/systems/production.d.ts +49 -0
  320. package/dist/systems/productionQueue.d.ts +40 -0
  321. package/dist/systems/victory.d.ts +14 -0
  322. package/dist/talk.d.ts +65 -0
  323. package/dist/tech.d.ts +62 -0
  324. package/dist/techTree.d.ts +38 -0
  325. package/dist/terrain.d.ts +173 -0
  326. package/dist/terrainSave.d.ts +29 -0
  327. package/dist/testing.d.ts +58 -0
  328. package/dist/testing.js +822 -0
  329. package/dist/testing.js.map +1 -0
  330. package/dist/tiles.d.ts +34 -0
  331. package/dist/timers.d.ts +146 -0
  332. package/dist/tomes.d.ts +48 -0
  333. package/dist/trade.d.ts +28 -0
  334. package/dist/transport.d.ts +76 -0
  335. package/dist/tunables.d.ts +45 -0
  336. package/dist/upkeep.d.ts +16 -0
  337. package/dist/veterancy.d.ts +80 -0
  338. package/dist/walls.d.ts +86 -0
  339. package/dist/world.d.ts +1118 -0
  340. package/package.json +80 -5
  341. package/README.md +0 -3
@@ -0,0 +1,780 @@
1
+ import type { ChatAudience } from './talk';
2
+ import type { AbilityDef, BuffDef, Cost, DamageType, StatChange, Stats, UnitTypeDef } from './defs';
3
+ import type { Camp } from './camps';
4
+ import type { BuffInstance, Entity, EntityId, ItemInstance, Order, PlayerId } from './entity';
5
+ import type { FormationDef } from './formation';
6
+ import type { AreaDef } from './areas';
7
+ import type { GameMap, MapCamp, MapObject, MapRegion } from './map';
8
+ import type { Rect, Vec2 } from './math';
9
+ import type { MessageRef } from './messages';
10
+ import type { DeathCause, DeathReason, World } from './world';
11
+ /**
12
+ * Hooks are how game modules and mods take part in what the engine does, while it does it: make an attack
13
+ * hit harder, keep a unit from dying, pay for a kill, refuse an order. A hook is a list of handlers that run
14
+ * in order, each getting the same event object; handlers before damage or death can change it or call it off.
15
+ *
16
+ * Events (`World.events`) are different: they tell whoever watches (a player's session, a test) what has
17
+ * happened, once the tick is over, and cannot change anything. Code that is part of the rules uses hooks.
18
+ */
19
+ /**
20
+ * Damage about to be dealt, before armor and shields. Change `amount` or `type`, or set `cancelled`
21
+ *
22
+ * @beta
23
+ */
24
+ export interface BeforeDamage {
25
+ readonly target: Entity;
26
+ readonly source?: Entity;
27
+ amount: number;
28
+ type: DamageType;
29
+ /** A basic attack, not an ability */
30
+ readonly attack: boolean;
31
+ readonly crit: boolean;
32
+ /** The ability that deals it, by id. Left out for a basic attack */
33
+ readonly ability?: string;
34
+ /** Words of the game's own about it, see `DamageOptions.tags` */
35
+ readonly tags?: readonly string[];
36
+ cancelled: boolean;
37
+ }
38
+ /**
39
+ * What a hit is multiplied by for the attack's type against the target's armour type (`GameRules.combat.damageTable`),
40
+ * before armour and shields: change `multiplier` to say otherwise. Asked only when the game has a table, or a hook
41
+ * of its own for it
42
+ */
43
+ export interface DamageMultiplier {
44
+ readonly target: Entity;
45
+ readonly source?: Entity;
46
+ /** The attack's type, as the attack or the ability said it (`AttackDef.attackType`, `DamageOptions.attackType`) */
47
+ readonly attackType?: string;
48
+ /** The target's armour type (`UnitTypeDef.armourType`) */
49
+ readonly armourType?: string;
50
+ /** A basic attack, not an ability */
51
+ readonly attack: boolean;
52
+ multiplier: number;
53
+ }
54
+ /**
55
+ * Damage that was dealt. The target may have died of it
56
+ *
57
+ * @beta
58
+ */
59
+ export interface AfterDamage {
60
+ readonly target: Entity;
61
+ readonly source?: Entity;
62
+ /** What came off its health, after armor and shields */
63
+ readonly dealt: number;
64
+ /** The part of that it had health for: overkill left out */
65
+ readonly taken: number;
66
+ readonly type: DamageType;
67
+ readonly attack: boolean;
68
+ readonly crit: boolean;
69
+ readonly ability?: string;
70
+ readonly tags?: readonly string[];
71
+ }
72
+ /**
73
+ * Health about to be given back. Change `amount`, or set `cancelled`
74
+ *
75
+ * @beta
76
+ */
77
+ export interface BeforeHeal {
78
+ readonly target: Entity;
79
+ readonly source?: Entity;
80
+ amount: number;
81
+ cancelled: boolean;
82
+ }
83
+ /**
84
+ * Something is about to die. Set `prevented` to keep it alive: it is then up to the handler what health it has
85
+ *
86
+ * @beta
87
+ */
88
+ export interface BeforeDeath {
89
+ readonly entity: Entity;
90
+ readonly killer?: Entity;
91
+ /** An attack of the killer did it */
92
+ readonly attack: boolean;
93
+ /** It ran out of health, rather than being removed by the rules (felled, expired, cancelled) */
94
+ readonly fromDamage: boolean;
95
+ /** The blow that did it, when it ran out of health */
96
+ readonly cause?: DeathCause;
97
+ /** Why it dies (`DeathReason`): `damage`, or what the rules said (`cancelled`, `expired`, a game's own word) */
98
+ readonly reason: DeathReason;
99
+ prevented: boolean;
100
+ }
101
+ /**
102
+ * Something dies. In `death` it still stands where it was; in `afterDeath` it is gone from the world
103
+ *
104
+ * @beta
105
+ */
106
+ export interface Death {
107
+ readonly entity: Entity;
108
+ readonly killer?: Entity;
109
+ readonly attack: boolean;
110
+ /** The blow that did it, when it ran out of health: its damage type, the ability, how much too much */
111
+ readonly cause?: DeathCause;
112
+ /** Why it dies (`DeathReason`): `damage`, or what the rules said (`cancelled`, `expired`, a game's own word) */
113
+ readonly reason: DeathReason;
114
+ /**
115
+ * What the rules make of the death, for the screen (`'exploded'`, `'burned'`): what the blow says (`AttackDef.how`,
116
+ * `AbilityDef.how`) to start with, changed in the `death` hook as the game likes. The view gets it with the death
117
+ * (`SessionEvent` `death`) to show it its way (`UnitLook.death`). Nothing when left out
118
+ */
119
+ how?: string;
120
+ }
121
+ /**
122
+ * An order about to be given to a unit. Set `rejected` to refuse it
123
+ *
124
+ * @beta
125
+ */
126
+ export interface BeforeOrder {
127
+ readonly entity: Entity;
128
+ readonly order: Order;
129
+ /** Added to the end of what it does, rather than in place of it */
130
+ readonly queued: boolean;
131
+ rejected: boolean;
132
+ }
133
+ /**
134
+ * How much a unit wants to attack something, as it looks for a target by itself. Higher is picked first:
135
+ * raise or lower `score`, or make it `-Infinity` to pass the target over. Towers of a tower defense go for
136
+ * the creep furthest along its way like this; a taunt makes everyone go for one unit.
137
+ *
138
+ * Runs for every candidate of every search, which is often: the same object is handed out again and again,
139
+ * so keep nothing of it.
140
+ *
141
+ * @beta
142
+ */
143
+ export interface TargetScore {
144
+ attacker: Entity;
145
+ target: Entity;
146
+ /** Edge to edge */
147
+ distance: number;
148
+ /** Attackers like this one (its layer, its reach) the target has already, and how many it has room for (`GameRules.combat.engageRoom`) */
149
+ engaged: number;
150
+ room: number;
151
+ /** What the engine makes of it: things that fight back first, then the closest, and a full one only when nothing else is near */
152
+ score: number;
153
+ }
154
+ /**
155
+ * Where an attacker goes to fight a target from: its spot around it (see `engagement.ts`), or the target itself, in
156
+ * `point`, to change. A flank for cavalry, behind for assassins. Asked every time the target moves a little: keep it cheap
157
+ */
158
+ export interface Approach {
159
+ readonly attacker: Entity;
160
+ readonly target: Entity;
161
+ point: Vec2;
162
+ }
163
+ /**
164
+ * An ally standing in a unit's way is asked to step aside, to `point` (see `GameRules.movement.makesWay`, `lookAhead`): change
165
+ * where it goes, or make it null to leave it standing. `mover` is on its way, heading the way of `direction`
166
+ *
167
+ * @beta
168
+ */
169
+ export interface MakeWay {
170
+ readonly mover: Entity;
171
+ readonly other: Entity;
172
+ /** Where the mover is heading, a unit long */
173
+ readonly direction: Vec2;
174
+ point: Vec2 | null;
175
+ }
176
+ /**
177
+ * A unit is about to go round units standing in its way (`around`), by `point`, which is `longer` ground units more
178
+ * than the `straight` way to the next corner of its path (see `GameRules.movement.goesAround`): change the point, or make it
179
+ * null to have it go straight through, asking them aside. Asked as it comes up to them: keep it cheap
180
+ *
181
+ * @beta
182
+ */
183
+ export interface Detour {
184
+ readonly entity: Entity;
185
+ readonly around: readonly Entity[];
186
+ readonly straight: number;
187
+ readonly longer: number;
188
+ point: Vec2 | null;
189
+ }
190
+ /**
191
+ * Units ordered to a point together have their places in a formation worked out (`FormationDef`, `formationPoints`):
192
+ * change any in `points`, by the unit's id, or add or remove some. `units` are those that walk, or those that fly:
193
+ * each is laid out apart
194
+ *
195
+ * @beta
196
+ */
197
+ export interface Formation {
198
+ readonly units: readonly Entity[];
199
+ readonly target: Vec2;
200
+ readonly formation: FormationDef;
201
+ readonly points: Map<EntityId, Vec2>;
202
+ }
203
+ /**
204
+ * Whether a structure may be placed. Set `allowed` to false, with a `reason` the player is told
205
+ *
206
+ * @beta
207
+ */
208
+ export interface CanPlace {
209
+ readonly def: UnitTypeDef;
210
+ /** The ground it would cover */
211
+ readonly site: Rect;
212
+ /** Who would build it. Left out when the engine asks for itself */
213
+ readonly player?: PlayerId;
214
+ allowed: boolean;
215
+ reason?: MessageRef;
216
+ }
217
+ /**
218
+ * An ability about to go off, before it is paid for. Change what it costs, or call it off with a `reason`.
219
+ * Whether the caster has the mana was already checked against the ability's own cost before it wound up:
220
+ * a lower cost here does not let it cast with less than that
221
+ *
222
+ * @beta
223
+ */
224
+ export interface BeforeCast {
225
+ readonly caster: Entity;
226
+ readonly ability: AbilityDef;
227
+ readonly level: number;
228
+ readonly target?: Entity;
229
+ readonly point: Vec2;
230
+ /** What it is cast from, for an item's ability */
231
+ readonly item?: ItemInstance;
232
+ manaCost: number;
233
+ /** Seconds until it can be used again */
234
+ cooldown: number;
235
+ cancelled: boolean;
236
+ reason?: MessageRef;
237
+ }
238
+ /**
239
+ * An ability that went off
240
+ *
241
+ * @beta
242
+ */
243
+ export interface AfterCast {
244
+ readonly caster: Entity;
245
+ readonly ability: AbilityDef;
246
+ readonly level: number;
247
+ readonly target?: Entity;
248
+ readonly point: Vec2;
249
+ readonly item?: ItemInstance;
250
+ /** It went off charged, and spent the charge */
251
+ readonly charged: boolean;
252
+ }
253
+ /**
254
+ * A buff about to be put on, or put on again. Change how long it lasts or how strong it is, or call it off (immunity)
255
+ *
256
+ * @beta
257
+ */
258
+ export interface BeforeBuff {
259
+ readonly target: Entity;
260
+ readonly buff: BuffDef;
261
+ readonly source?: Entity;
262
+ level: number;
263
+ /** Seconds, after tenacity. Infinity for one that stays */
264
+ duration: number;
265
+ cancelled: boolean;
266
+ }
267
+ /**
268
+ * A buff that came off: it ran out (`expired`), or was taken off. Not called for the buffs of something that dies
269
+ *
270
+ * @beta
271
+ */
272
+ export interface BuffEnd {
273
+ readonly entity: Entity;
274
+ readonly buff: BuffInstance;
275
+ readonly expired: boolean;
276
+ }
277
+ /** @beta */
278
+ export type ProductionKind = 'unit' | 'upgrade' | 'morph' | 'revive' | 'structure';
279
+ /**
280
+ * Something about to be made: a unit trained, an upgrade researched, a building upgraded, a hero brought back,
281
+ * a structure put down by a worker. Change what it costs and how long it takes, or call it off with a `reason`
282
+ *
283
+ * @beta
284
+ */
285
+ export interface BeforeProduce {
286
+ readonly player: PlayerId;
287
+ /** The building it is made in, or the worker putting down a structure */
288
+ readonly producer: Entity;
289
+ readonly kind: ProductionKind;
290
+ /** Unit type, upgrade, the type a building becomes, the id of a hero, or a structure type */
291
+ readonly id: string;
292
+ cost: Cost;
293
+ /** Seconds it takes */
294
+ time: number;
295
+ cancelled: boolean;
296
+ reason?: MessageRef;
297
+ }
298
+ /** Every hook, and what its handlers get */
299
+ /**
300
+ * A unit with nothing to do, this tick: no orders. Set `handled` and do what it does instead of what idle units do
301
+ * (fight back, go for enemies that come close, which is only for those that fight): a healer that goes to the
302
+ * wounded, a worker that goes back to work. Asked often: keep it cheap
303
+ *
304
+ * @beta
305
+ */
306
+ export interface Idle {
307
+ readonly entity: Entity;
308
+ readonly dt: number;
309
+ /** Whether it fights by itself: it has an attack and is not told to stand down. The engine only does that */
310
+ readonly fights: boolean;
311
+ handled: boolean;
312
+ }
313
+ /**
314
+ * Whether an attacker may attack a target: what the engine makes of it (its attack's targets, whether they are
315
+ * enemies) is in `allowed`, to change. A buff that lets a unit hit what flies; a truce. Asked very often, the same
316
+ * object handed out again and again: keep nothing of it
317
+ */
318
+ export interface CanAttack {
319
+ attacker: Entity;
320
+ target: Entity;
321
+ allowed: boolean;
322
+ /**
323
+ * Whether a player told the attacker to attack this one (an attack order): what a game lets of its own side, as a
324
+ * deny (`denying`). Never when a unit picks a target by itself or fights back, so nothing turns on its own side
325
+ * unless told: a unit looking for a target by itself is not asked about its own side's at all (they are passed over
326
+ * before the hook, as most of what stands around a unit in a crowd is its own)
327
+ */
328
+ ordered: boolean;
329
+ }
330
+ /**
331
+ * An attack going off, as the engine has it: change what it does, or call it off. `target` is left out for an attack
332
+ * at the ground. `splash` is the radius of an attack that hits an area; `projectileSpeed` 0 is a blow, more a shot
333
+ * (`look` what the shot looks like, for the screen). Damage, the critical strike and the miss are already rolled
334
+ */
335
+ export interface BeforeAttack {
336
+ readonly attacker: Entity;
337
+ readonly target?: Entity;
338
+ readonly point: Vec2;
339
+ /** Which of the attacker's attacks goes off, by place (`UnitTypeDef.attacks`) */
340
+ readonly weapon: number;
341
+ damage: number;
342
+ type: DamageType;
343
+ crit: boolean;
344
+ miss: boolean;
345
+ splash?: number;
346
+ projectileSpeed: number;
347
+ look?: string;
348
+ /** Words of the game's own about it, which the damage carries, see `DamageOptions.tags` */
349
+ tags?: string[];
350
+ /** How what it kills dies, for the screen (`AttackDef.how`, worked out for this blow): changed as the game likes */
351
+ how?: string;
352
+ cancelled: boolean;
353
+ }
354
+ /**
355
+ * The stats of an entity being added up, once what the engine knows of (its type, levels, research, items, buffs) is
356
+ * in: `add` more, as a stat change (`{ stats: { armor: 2 } }`, `{ percent: { moveSpeed: 0.1 } }`). Asked only when
357
+ * something they come from changed: call `invalidateStats` when what a handler reads changes
358
+ */
359
+ export interface StatsHook {
360
+ readonly entity: Entity;
361
+ /** What its type starts with */
362
+ readonly base: Readonly<Stats>;
363
+ add(change: StatChange, times?: number): void;
364
+ }
365
+ /**
366
+ * Whether an ability can be used now: what the engine makes of it (level, cooldown, mana, silence) in `refusal`, to
367
+ * clear ("free while Clearcasting") or to set ("not while carrying the flag"). The cost itself is `beforeCast`'s: one
368
+ * that is let through for free sets its `manaCost` to 0 there too. The player's screen is told what this decided for
369
+ * the abilities of their own units
370
+ */
371
+ export interface CanCast {
372
+ readonly caster: Entity;
373
+ readonly ability: AbilityDef;
374
+ readonly level: number;
375
+ /** What it is used from, for an item's ability */
376
+ readonly item?: ItemInstance;
377
+ refusal?: MessageRef;
378
+ }
379
+ /**
380
+ * Whether an ability may be used on a target: what the engine makes of it (the ability's `targets`) in `refusal`, to
381
+ * clear ("can target allied buildings below half health") or to set. The screen only knows the declared targets: what
382
+ * this changes, the simulation says when the order comes
383
+ */
384
+ export interface CanTarget {
385
+ readonly caster: Entity;
386
+ readonly ability: AbilityDef;
387
+ readonly target: Entity;
388
+ refusal?: MessageRef;
389
+ }
390
+ /**
391
+ * Whether a team sees an entity of someone else's: what the fog and invisibility make of it in `visible`, to change.
392
+ * Units in brush seen only from up close; a watchtower. Asked very often: keep it cheap
393
+ */
394
+ export interface Visible {
395
+ readonly entity: Entity;
396
+ readonly team: number;
397
+ visible: boolean;
398
+ }
399
+ /**
400
+ * Whether a player may make something, as far as what it requires goes: a unit, a level of research (`level`), what a
401
+ * building upgrades to, a structure. What the engine makes of it (the finished buildings it requires: `missing`) is in
402
+ * `refusal`, to clear or set: "needs Blacksmith upgrade 2", "needs a level 5 hero", "locked until the objective". The
403
+ * player's screen is told what this decided, for what they could make
404
+ */
405
+ export interface Requirement {
406
+ readonly player: PlayerId;
407
+ readonly kind: 'unit' | 'upgrade';
408
+ readonly id: string;
409
+ /** The level being researched, for an upgrade */
410
+ readonly level?: number;
411
+ /** Required building types the player does not have */
412
+ readonly missing: readonly string[];
413
+ refusal?: MessageRef;
414
+ }
415
+ /**
416
+ * Whether a player may make a unit type or research an upgrade at all, before what it requires (see `isAvailable`):
417
+ * by default (`available`), what is of no race or of theirs (`race`). Set it otherwise for a game's own way: what a
418
+ * mode takes away, a roster that grows as a campaign goes, a unit only one player may have. What is not available is
419
+ * not on the player's buttons, and an order for it is refused; their screen is told where this decided otherwise
420
+ *
421
+ * @beta
422
+ */
423
+ export interface Available {
424
+ readonly player: PlayerId;
425
+ readonly kind: 'unit' | 'upgrade';
426
+ readonly id: string;
427
+ /** The race the player plays, if the game has races */
428
+ readonly race: string | undefined;
429
+ available: boolean;
430
+ }
431
+ /**
432
+ * A player about to ping the map or say a line (see `ping`, `chat`): change the words (`text`) or who hears them (`to`),
433
+ * or call it off: a muted player, a word filter, no talking in a cinematic. On the rules' side, for every screen alike
434
+ */
435
+ export interface BeforeTalk {
436
+ readonly player: PlayerId;
437
+ readonly kind: 'ping' | 'chat';
438
+ /** A line's words */
439
+ text?: string;
440
+ /** Who a line or a ping is for */
441
+ to?: ChatAudience;
442
+ /** Where a ping is, and of what kind */
443
+ readonly point?: Vec2;
444
+ readonly pingKind?: string;
445
+ cancelled: boolean;
446
+ }
447
+ /**
448
+ * Resources about to be given to an ally (see `give`): change how much arrives (`received`), or call it off with a
449
+ * `reason`: no trading in the first minutes, a cap on what goes to one player
450
+ */
451
+ export interface BeforeTrade {
452
+ readonly from: PlayerId;
453
+ readonly to: PlayerId;
454
+ readonly resource: string;
455
+ readonly sent: number;
456
+ received: number;
457
+ cancelled: boolean;
458
+ reason?: MessageRef;
459
+ }
460
+ /**
461
+ * A player is about to give up (see `surrender`): call it off with a `reason`, as a game that does not let them before a time
462
+ *
463
+ * @beta
464
+ */
465
+ export interface BeforeSurrender {
466
+ readonly player: PlayerId;
467
+ cancelled: boolean;
468
+ reason?: MessageRef;
469
+ }
470
+ /**
471
+ * A player asks for a pause (see `askPause`): how many they have left before this one (`left`), and how long it lasts
472
+ * at most (`seconds`, which can be changed); call it off with a `reason`
473
+ *
474
+ * @beta
475
+ */
476
+ export interface BeforePause {
477
+ readonly player: PlayerId;
478
+ readonly left: number;
479
+ seconds: number;
480
+ cancelled: boolean;
481
+ reason?: MessageRef;
482
+ }
483
+ /**
484
+ * A player's cap of a pool of supply, once what their buildings provide is added up (see the supply system): change
485
+ * `cap` (a starting amount, an upgrade, a rule of the game's own). The game's most (`GameRules.supply.max`, a pool's
486
+ * `max`) still holds after
487
+ *
488
+ * @beta
489
+ */
490
+ export interface SupplyCap {
491
+ readonly player: PlayerId;
492
+ /** `supply` for the one there always is, or the name of one of the game's own (`GameRules.supply.pools`) */
493
+ readonly pool: string;
494
+ cap: number;
495
+ }
496
+ /**
497
+ * Whether a worker may gather from a resource: by default, a resource of a kind it gathers (`harvester.kinds`). Refuse
498
+ * it for a game's own rule: a mine only its owner's cursed mine stands on, a tree of a sacred grove. Asked when it is
499
+ * told to, and of every resource it would go on to by itself
500
+ *
501
+ * @beta
502
+ */
503
+ export interface CanHarvest {
504
+ readonly worker: Entity;
505
+ readonly source: Entity;
506
+ allowed: boolean;
507
+ /** What the player is told when it is refused */
508
+ reason?: MessageRef;
509
+ }
510
+ /** Resources a worker hands in: change `amount` (more from mines near the keep), or call it off */
511
+ export interface BeforeDeposit {
512
+ readonly worker: Entity;
513
+ readonly player: PlayerId;
514
+ readonly kind: string;
515
+ amount: number;
516
+ cancelled: boolean;
517
+ }
518
+ /** An item about to be bought at a shop: change what it costs, or call it off with a `reason` */
519
+ export interface BeforeBuy {
520
+ readonly buyer: Entity;
521
+ readonly shop: Entity;
522
+ readonly item: string;
523
+ cost: Cost;
524
+ cancelled: boolean;
525
+ reason?: MessageRef;
526
+ }
527
+ /** An item about to be picked up off the ground (`ground` its id there): call it off with a `reason` */
528
+ export interface BeforePickUp {
529
+ readonly entity: Entity;
530
+ readonly item: string;
531
+ readonly ground: number;
532
+ cancelled: boolean;
533
+ reason?: MessageRef;
534
+ }
535
+ /** An item about to be put down: call it off with a `reason` (a cursed blade) */
536
+ export interface BeforeDrop {
537
+ readonly entity: Entity;
538
+ readonly item: ItemInstance;
539
+ cancelled: boolean;
540
+ reason?: MessageRef;
541
+ }
542
+ /** Experience about to go to a hero: change `amount` (the killer gets more), or make it 0. `from` is what was killed, when that is where it comes from */
543
+ export interface BeforeXp {
544
+ readonly hero: Entity;
545
+ readonly from?: Entity;
546
+ amount: number;
547
+ }
548
+ /** Whether a hero may put a point into an ability: what the engine makes of it in `allowed`, to change. The screen hears of it with what the hero can learn */
549
+ export interface CanLearn {
550
+ readonly hero: Entity;
551
+ readonly ability: string;
552
+ allowed: boolean;
553
+ }
554
+ /** Something was made: a unit trained (`unit`), research done (`level`), a building upgraded, a hero brought back */
555
+ export interface Produced {
556
+ readonly producer: Entity;
557
+ readonly kind: ProductionKind;
558
+ readonly id: string;
559
+ readonly unit?: Entity;
560
+ readonly level?: number;
561
+ }
562
+ /**
563
+ * Something that has just become another type where it stands (`morph`): a building upgraded, a unit transformed. Its
564
+ * new type's parts are set (stats, abilities, slots, and every `Component.onSpawn` of a part it did not have yet): what
565
+ * a pack gives it of its own for the type it is now, as the heroes pack makes a hero of what became a hero's type and
566
+ * stocks what became a shop. Run before the `entityMorphed` event
567
+ *
568
+ * @beta
569
+ */
570
+ export interface Morphed {
571
+ /** What changed type, as it is now */
572
+ readonly entity: Entity;
573
+ /** The type it was */
574
+ readonly from: string;
575
+ }
576
+ /**
577
+ * What was placed on a map, and the entity it has become
578
+ *
579
+ * @beta
580
+ */
581
+ export interface FromMapObject {
582
+ readonly entity: Entity;
583
+ /** As the map has it: where, whose, its name */
584
+ readonly object: Readonly<MapObject>;
585
+ /** The game's own fields for it (see `defineMapField`), with what was not set at its default */
586
+ readonly data: Readonly<Record<string, unknown>>;
587
+ }
588
+ /**
589
+ * A camp that was placed on a map, and the camp it has become
590
+ *
591
+ * @beta
592
+ */
593
+ export interface FromMapCamp {
594
+ readonly camp: Camp;
595
+ readonly from: Readonly<MapCamp>;
596
+ /** The game's own fields for camps, see `FromMapObject.data` */
597
+ readonly data: Readonly<Record<string, unknown>>;
598
+ }
599
+ /**
600
+ * Something that has died, before it leaves the world: whether it stays (`stays`), out of the world, in the world's
601
+ * entities, to be brought back. No when nothing says so; the heroes pack says yes for a hero (`withHeroes`), and a
602
+ * handler after it (a higher `priority`) can say no for a game where heroes fall for good
603
+ *
604
+ * @beta
605
+ */
606
+ export interface FallenHero {
607
+ /** What died */
608
+ readonly entity: Entity;
609
+ /** What killed it, when something did */
610
+ readonly killer?: Entity;
611
+ /** Whether it stays, out of the world, to be brought back: no, unless a handler says yes */
612
+ stays: boolean;
613
+ }
614
+ /**
615
+ * A region of a map, and the area it has become
616
+ *
617
+ * @beta
618
+ */
619
+ export interface FromMapRegion {
620
+ readonly area: AreaDef;
621
+ readonly region: Readonly<MapRegion>;
622
+ /** The game's own fields for regions, see `FromMapObject.data` */
623
+ readonly data: Readonly<Record<string, unknown>>;
624
+ }
625
+ /**
626
+ * A world made from a map, everything the map places in it there and every race's start done: what a pack or the game
627
+ * starts of its own from the map's data, as the map objectives pack gives the objectives a map gives at the start
628
+ * (`mapObjectives`). Not for a world loaded from a save, which has them already
629
+ *
630
+ * @beta
631
+ */
632
+ export interface FromMap {
633
+ /** The map it was made from */
634
+ readonly map: Readonly<GameMap>;
635
+ }
636
+ /** @beta */
637
+ export interface HookEvents {
638
+ beforeDamage: BeforeDamage;
639
+ damageMultiplier: DamageMultiplier;
640
+ afterDamage: AfterDamage;
641
+ beforeHeal: BeforeHeal;
642
+ beforeDeath: BeforeDeath;
643
+ death: Death;
644
+ afterDeath: Death;
645
+ /** Whether what died stays in the world's entities, out of the world, to be brought back (`FallenHero`). @beta */
646
+ fallenHero: FallenHero;
647
+ /**
648
+ * Something just made, its type's parts set (abilities, an inventory, an attack), not in the world yet: what a pack
649
+ * gives it of its own, as the heroes pack makes a hero of a hero's type (`makeHero`) and stocks a shop. @beta
650
+ */
651
+ made: Entity;
652
+ /** Something became another type where it stands (`morph`): what a pack gives it of its own for the new type (`Morphed`). @beta */
653
+ morphed: Morphed;
654
+ /** Something came into the world, and is in it now */
655
+ spawn: Entity;
656
+ /** Something left the world for good, at the end of the tick it died in */
657
+ remove: Entity;
658
+ beforeOrder: BeforeOrder;
659
+ targetScore: TargetScore;
660
+ approach: Approach;
661
+ makeWay: MakeWay;
662
+ detour: Detour;
663
+ formation: Formation;
664
+ canPlace: CanPlace;
665
+ beforeCast: BeforeCast;
666
+ afterCast: AfterCast;
667
+ beforeBuff: BeforeBuff;
668
+ buffEnd: BuffEnd;
669
+ beforeProduce: BeforeProduce;
670
+ idle: Idle;
671
+ canAttack: CanAttack;
672
+ beforeAttack: BeforeAttack;
673
+ stats: StatsHook;
674
+ canCast: CanCast;
675
+ canTarget: CanTarget;
676
+ visible: Visible;
677
+ requirement: Requirement;
678
+ available: Available;
679
+ beforeDeposit: BeforeDeposit;
680
+ canHarvest: CanHarvest;
681
+ beforeTalk: BeforeTalk;
682
+ beforeTrade: BeforeTrade;
683
+ beforeSurrender: BeforeSurrender;
684
+ supplyCap: SupplyCap;
685
+ beforePause: BeforePause;
686
+ beforeBuy: BeforeBuy;
687
+ beforePickUp: BeforePickUp;
688
+ beforeDrop: BeforeDrop;
689
+ beforeXp: BeforeXp;
690
+ canLearn: CanLearn;
691
+ produced: Produced;
692
+ /** Something placed on a map has become an entity, as the world is made from the map: what the game does with its own fields */
693
+ mapObject: FromMapObject;
694
+ /** A camp placed on a map is in the world, see `mapObject` */
695
+ mapCamp: FromMapCamp;
696
+ /** A region of a map is an area of the world, see `mapObject` */
697
+ mapRegion: FromMapRegion;
698
+ /** The world made from a map is all there, about to start (`FromMap`): what a pack starts from the map's own data. @beta */
699
+ mapStart: FromMap;
700
+ }
701
+ /** @beta */
702
+ export type HookName = keyof HookEvents;
703
+ /** @beta */
704
+ export type HookHandler<K extends HookName> = (world: World, event: HookEvents[K]) => void;
705
+ /**
706
+ * A hook of a game's own, made with `defineHookType`: a moment of its rules others can take part in, the way the
707
+ * engine's hooks are for its own
708
+ *
709
+ * @beta
710
+ */
711
+ export interface HookKey<T> {
712
+ readonly id: string;
713
+ /** Only there for the type of the event */
714
+ readonly event?: T;
715
+ }
716
+ /**
717
+ * A hook of a game's own: `const lifeLost = defineHookType<{ invader: Entity; lives: number; cancelled: boolean }>('td.lifeLost')`.
718
+ * The game runs it where the moment is (`world.hooks.run(lifeLost, { ... })`) and reads back what the handlers made
719
+ * of the event; handlers are written with `defineHook({ hook: lifeLost, ... })`, by the game or by a mod on it.
720
+ * Ids are shared by every game: give them a prefix of the game's
721
+ *
722
+ * @beta
723
+ */
724
+ export declare function defineHookType<T>(id: string): HookKey<T>;
725
+ /**
726
+ * A hook: one of the engine's by name, or a game's own
727
+ *
728
+ * @beta
729
+ */
730
+ export type AnyHook = HookName | HookKey<any>;
731
+ /**
732
+ * A handler and the hook it is for. Its `id` is how others take it out or put something in its place
733
+ *
734
+ * @beta
735
+ */
736
+ export type HookDef = {
737
+ hook: AnyHook;
738
+ id: string;
739
+ /** Lower runs first. 0 when left out; handlers with the same priority run in the order they were added */
740
+ priority?: number;
741
+ run: (world: World, event: any) => void;
742
+ };
743
+ /**
744
+ * Typed help for writing a hook: `defineHook({ hook: 'death', id: 'bounty', run(world, { entity }) { ... } })`
745
+ *
746
+ * @beta
747
+ */
748
+ export declare function defineHook<K extends HookName>(def: {
749
+ hook: K;
750
+ id: string;
751
+ priority?: number;
752
+ run: HookHandler<K>;
753
+ }): HookDef;
754
+ /** @beta */
755
+ export declare function defineHook<T>(def: {
756
+ hook: HookKey<T>;
757
+ id: string;
758
+ priority?: number;
759
+ run: (world: World, event: T) => void;
760
+ }): HookDef;
761
+ /**
762
+ * The handlers of every hook of one world
763
+ *
764
+ * @beta
765
+ */
766
+ export declare class Hooks {
767
+ private readonly world;
768
+ private readonly lists;
769
+ constructor(world: World);
770
+ /** Adds a handler. One with the same id on the same hook is replaced */
771
+ add(def: HookDef): void;
772
+ remove(hook: AnyHook, id: string): void;
773
+ /** Whether a hook has any handlers. For hooks run very often, to not even put the event together when nobody listens */
774
+ has(hook: AnyHook): boolean;
775
+ /** Ids of the handlers of a hook, in the order they run */
776
+ handlers(hook: AnyHook): string[];
777
+ /** Runs the handlers of a hook on the event, in order, and hands the event back for the caller to read */
778
+ run<K extends HookName>(hook: K, event: HookEvents[K]): HookEvents[K];
779
+ run<T>(hook: HookKey<T>, event: T): T;
780
+ }