@datamoc/mw_games 0.7.4 → 0.7.7

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 (288) hide show
  1. package/CHANGELOG.md +287 -2
  2. package/README.md +15 -2
  3. package/dist/actors/Inventory.d.ts +7 -1
  4. package/dist/actors/Inventory.d.ts.map +1 -1
  5. package/dist/actors/Inventory.js.map +1 -1
  6. package/dist/actors/craft.d.ts +35 -14
  7. package/dist/actors/craft.d.ts.map +1 -1
  8. package/dist/actors/craft.js +56 -24
  9. package/dist/actors/craft.js.map +1 -1
  10. package/dist/actors/index.d.ts +1 -1
  11. package/dist/actors/index.d.ts.map +1 -1
  12. package/dist/ai/Heuristics.d.ts +232 -0
  13. package/dist/ai/Heuristics.d.ts.map +1 -0
  14. package/dist/ai/Heuristics.js +298 -0
  15. package/dist/ai/Heuristics.js.map +1 -0
  16. package/dist/ai/index.d.ts +4 -0
  17. package/dist/ai/index.d.ts.map +1 -1
  18. package/dist/ai/index.js +2 -0
  19. package/dist/ai/index.js.map +1 -1
  20. package/dist/ai/score.d.ts +126 -0
  21. package/dist/ai/score.d.ts.map +1 -0
  22. package/dist/ai/score.js +121 -0
  23. package/dist/ai/score.js.map +1 -0
  24. package/dist/assets/loader.d.ts +18 -4
  25. package/dist/assets/loader.d.ts.map +1 -1
  26. package/dist/assets/loader.js +40 -11
  27. package/dist/assets/loader.js.map +1 -1
  28. package/dist/audio/Positional.d.ts +125 -0
  29. package/dist/audio/Positional.d.ts.map +1 -0
  30. package/dist/audio/Positional.js +135 -0
  31. package/dist/audio/Positional.js.map +1 -0
  32. package/dist/audio/Sound.d.ts +7 -1
  33. package/dist/audio/Sound.d.ts.map +1 -1
  34. package/dist/audio/Sound.js +8 -2
  35. package/dist/audio/Sound.js.map +1 -1
  36. package/dist/audio/index.d.ts +2 -0
  37. package/dist/audio/index.d.ts.map +1 -1
  38. package/dist/audio/index.js +1 -0
  39. package/dist/audio/index.js.map +1 -1
  40. package/dist/battle/AttackDialog.d.ts +75 -0
  41. package/dist/battle/AttackDialog.d.ts.map +1 -0
  42. package/dist/battle/AttackDialog.js +115 -0
  43. package/dist/battle/AttackDialog.js.map +1 -0
  44. package/dist/battle/AttackPreview.d.ts +70 -0
  45. package/dist/battle/AttackPreview.d.ts.map +1 -0
  46. package/dist/battle/AttackPreview.js +78 -0
  47. package/dist/battle/AttackPreview.js.map +1 -0
  48. package/dist/battle/BattleStats.d.ts +45 -0
  49. package/dist/battle/BattleStats.d.ts.map +1 -0
  50. package/dist/battle/BattleStats.js +63 -0
  51. package/dist/battle/BattleStats.js.map +1 -0
  52. package/dist/battle/UnitSelector.d.ts +72 -0
  53. package/dist/battle/UnitSelector.d.ts.map +1 -0
  54. package/dist/battle/UnitSelector.js +117 -0
  55. package/dist/battle/UnitSelector.js.map +1 -0
  56. package/dist/battle/Whiteboard.d.ts +50 -0
  57. package/dist/battle/Whiteboard.d.ts.map +1 -0
  58. package/dist/battle/Whiteboard.js +94 -0
  59. package/dist/battle/Whiteboard.js.map +1 -0
  60. package/dist/battle/index.d.ts +10 -0
  61. package/dist/battle/index.d.ts.map +1 -1
  62. package/dist/battle/index.js +5 -0
  63. package/dist/battle/index.js.map +1 -1
  64. package/dist/board/FogOfWar.d.ts +32 -2
  65. package/dist/board/FogOfWar.d.ts.map +1 -1
  66. package/dist/board/FogOfWar.js +70 -6
  67. package/dist/board/FogOfWar.js.map +1 -1
  68. package/dist/core/Achievements.d.ts +40 -7
  69. package/dist/core/Achievements.d.ts.map +1 -1
  70. package/dist/core/Achievements.js +51 -7
  71. package/dist/core/Achievements.js.map +1 -1
  72. package/dist/core/Blob.d.ts +13 -2
  73. package/dist/core/Blob.d.ts.map +1 -1
  74. package/dist/core/Blob.js +16 -2
  75. package/dist/core/Blob.js.map +1 -1
  76. package/dist/core/Hex.d.ts +26 -6
  77. package/dist/core/Hex.d.ts.map +1 -1
  78. package/dist/core/Hex.js +40 -13
  79. package/dist/core/Hex.js.map +1 -1
  80. package/dist/core/Input.d.ts +36 -0
  81. package/dist/core/Input.d.ts.map +1 -1
  82. package/dist/core/Input.js +63 -1
  83. package/dist/core/Input.js.map +1 -1
  84. package/dist/core/Random.d.ts +93 -0
  85. package/dist/core/Random.d.ts.map +1 -1
  86. package/dist/core/Random.js +177 -0
  87. package/dist/core/Random.js.map +1 -1
  88. package/dist/core/SyncGuard.d.ts +57 -0
  89. package/dist/core/SyncGuard.d.ts.map +1 -0
  90. package/dist/core/SyncGuard.js +116 -0
  91. package/dist/core/SyncGuard.js.map +1 -0
  92. package/dist/core/index.d.ts +3 -1
  93. package/dist/core/index.d.ts.map +1 -1
  94. package/dist/core/index.js +2 -1
  95. package/dist/core/index.js.map +1 -1
  96. package/dist/i18n/Po.d.ts +51 -0
  97. package/dist/i18n/Po.d.ts.map +1 -0
  98. package/dist/i18n/Po.js +176 -0
  99. package/dist/i18n/Po.js.map +1 -0
  100. package/dist/i18n/index.d.ts +2 -0
  101. package/dist/i18n/index.d.ts.map +1 -1
  102. package/dist/i18n/index.js +1 -0
  103. package/dist/i18n/index.js.map +1 -1
  104. package/dist/mw_games.global.js +104 -98
  105. package/dist/mwl/MapFile.d.ts +41 -0
  106. package/dist/mwl/MapFile.d.ts.map +1 -0
  107. package/dist/mwl/MapFile.js +43 -0
  108. package/dist/mwl/MapFile.js.map +1 -0
  109. package/dist/mwl/campaign.d.ts +51 -0
  110. package/dist/mwl/campaign.d.ts.map +1 -0
  111. package/dist/mwl/campaign.js +58 -0
  112. package/dist/mwl/campaign.js.map +1 -0
  113. package/dist/mwl/carryover.d.ts +79 -0
  114. package/dist/mwl/carryover.d.ts.map +1 -0
  115. package/dist/mwl/carryover.js +63 -0
  116. package/dist/mwl/carryover.js.map +1 -0
  117. package/dist/mwl/content.d.ts +10 -0
  118. package/dist/mwl/content.d.ts.map +1 -1
  119. package/dist/mwl/content.js +8 -0
  120. package/dist/mwl/content.js.map +1 -1
  121. package/dist/mwl/hooks.d.ts +6 -5
  122. package/dist/mwl/hooks.d.ts.map +1 -1
  123. package/dist/mwl/hooks.js.map +1 -1
  124. package/dist/mwl/index.d.ts +8 -2
  125. package/dist/mwl/index.d.ts.map +1 -1
  126. package/dist/mwl/index.js +4 -1
  127. package/dist/mwl/index.js.map +1 -1
  128. package/dist/mwl/runtime.d.ts +140 -7
  129. package/dist/mwl/runtime.d.ts.map +1 -1
  130. package/dist/mwl/runtime.js +427 -33
  131. package/dist/mwl/runtime.js.map +1 -1
  132. package/dist/mwl/schema.d.ts.map +1 -1
  133. package/dist/mwl/schema.js +97 -18
  134. package/dist/mwl/schema.js.map +1 -1
  135. package/dist/roguelike/MultiTurnBeam.d.ts +50 -12
  136. package/dist/roguelike/MultiTurnBeam.d.ts.map +1 -1
  137. package/dist/roguelike/MultiTurnBeam.js +100 -53
  138. package/dist/roguelike/MultiTurnBeam.js.map +1 -1
  139. package/dist/roguelike/Targeting.d.ts +94 -0
  140. package/dist/roguelike/Targeting.d.ts.map +1 -1
  141. package/dist/roguelike/Targeting.js +123 -0
  142. package/dist/roguelike/Targeting.js.map +1 -1
  143. package/dist/roguelike/index.d.ts +3 -1
  144. package/dist/roguelike/index.d.ts.map +1 -1
  145. package/dist/roguelike/index.js +1 -0
  146. package/dist/roguelike/index.js.map +1 -1
  147. package/dist/simulation/CampaignSave.d.ts +68 -0
  148. package/dist/simulation/CampaignSave.d.ts.map +1 -0
  149. package/dist/simulation/CampaignSave.js +54 -0
  150. package/dist/simulation/CampaignSave.js.map +1 -0
  151. package/dist/simulation/EventPresentation.d.ts +111 -0
  152. package/dist/simulation/EventPresentation.d.ts.map +1 -0
  153. package/dist/simulation/EventPresentation.js +120 -0
  154. package/dist/simulation/EventPresentation.js.map +1 -0
  155. package/dist/simulation/index.d.ts +4 -0
  156. package/dist/simulation/index.d.ts.map +1 -1
  157. package/dist/simulation/index.js +2 -0
  158. package/dist/simulation/index.js.map +1 -1
  159. package/dist/two-d/pixi-interop.d.ts +18 -6
  160. package/dist/two-d/pixi-interop.d.ts.map +1 -1
  161. package/dist/two-d/pixi-interop.js +18 -6
  162. package/dist/two-d/pixi-interop.js.map +1 -1
  163. package/dist/two-d/render/AnimatedSprite.d.ts +74 -7
  164. package/dist/two-d/render/AnimatedSprite.d.ts.map +1 -1
  165. package/dist/two-d/render/AnimatedSprite.js +88 -26
  166. package/dist/two-d/render/AnimatedSprite.js.map +1 -1
  167. package/dist/two-d/render/Camera.d.ts +64 -4
  168. package/dist/two-d/render/Camera.d.ts.map +1 -1
  169. package/dist/two-d/render/Camera.js +132 -11
  170. package/dist/two-d/render/Camera.js.map +1 -1
  171. package/dist/two-d/render/Halo.d.ts +58 -0
  172. package/dist/two-d/render/Halo.d.ts.map +1 -0
  173. package/dist/two-d/render/Halo.js +48 -0
  174. package/dist/two-d/render/Halo.js.map +1 -0
  175. package/dist/two-d/render/ImageModifiers.d.ts +174 -0
  176. package/dist/two-d/render/ImageModifiers.d.ts.map +1 -1
  177. package/dist/two-d/render/ImageModifiers.js +438 -1
  178. package/dist/two-d/render/ImageModifiers.js.map +1 -1
  179. package/dist/two-d/render/LightningArc.d.ts +57 -0
  180. package/dist/two-d/render/LightningArc.d.ts.map +1 -0
  181. package/dist/two-d/render/LightningArc.js +91 -0
  182. package/dist/two-d/render/LightningArc.js.map +1 -0
  183. package/dist/two-d/render/PaletteRemap.d.ts +135 -0
  184. package/dist/two-d/render/PaletteRemap.d.ts.map +1 -0
  185. package/dist/two-d/render/PaletteRemap.js +181 -0
  186. package/dist/two-d/render/PaletteRemap.js.map +1 -0
  187. package/dist/two-d/render/Particles.d.ts +26 -0
  188. package/dist/two-d/render/Particles.d.ts.map +1 -1
  189. package/dist/two-d/render/Particles.js +23 -2
  190. package/dist/two-d/render/Particles.js.map +1 -1
  191. package/dist/two-d/render/SpriteAttachment.d.ts +55 -0
  192. package/dist/two-d/render/SpriteAttachment.d.ts.map +1 -0
  193. package/dist/two-d/render/SpriteAttachment.js +60 -0
  194. package/dist/two-d/render/SpriteAttachment.js.map +1 -0
  195. package/dist/two-d/render/TerrainGraphics.d.ts +142 -0
  196. package/dist/two-d/render/TerrainGraphics.d.ts.map +1 -0
  197. package/dist/two-d/render/TerrainGraphics.js +161 -0
  198. package/dist/two-d/render/TerrainGraphics.js.map +1 -0
  199. package/dist/two-d/render/index.d.ts +13 -3
  200. package/dist/two-d/render/index.d.ts.map +1 -1
  201. package/dist/two-d/render/index.js +6 -1
  202. package/dist/two-d/render/index.js.map +1 -1
  203. package/dist/two-d/stage/StoryScreen.d.ts +110 -0
  204. package/dist/two-d/stage/StoryScreen.d.ts.map +1 -0
  205. package/dist/two-d/stage/StoryScreen.js +178 -0
  206. package/dist/two-d/stage/StoryScreen.js.map +1 -0
  207. package/dist/two-d/stage/index.d.ts +2 -0
  208. package/dist/two-d/stage/index.d.ts.map +1 -1
  209. package/dist/two-d/stage/index.js +1 -0
  210. package/dist/two-d/stage/index.js.map +1 -1
  211. package/dist/two-d/ui/Checkbox.d.ts +44 -0
  212. package/dist/two-d/ui/Checkbox.d.ts.map +1 -0
  213. package/dist/two-d/ui/Checkbox.js +89 -0
  214. package/dist/two-d/ui/Checkbox.js.map +1 -0
  215. package/dist/two-d/ui/DataTable.d.ts +79 -0
  216. package/dist/two-d/ui/DataTable.d.ts.map +1 -0
  217. package/dist/two-d/ui/DataTable.js +164 -0
  218. package/dist/two-d/ui/DataTable.js.map +1 -0
  219. package/dist/two-d/ui/Dropdown.d.ts +72 -0
  220. package/dist/two-d/ui/Dropdown.d.ts.map +1 -0
  221. package/dist/two-d/ui/Dropdown.js +126 -0
  222. package/dist/two-d/ui/Dropdown.js.map +1 -0
  223. package/dist/two-d/ui/FloatingText.d.ts +43 -4
  224. package/dist/two-d/ui/FloatingText.d.ts.map +1 -1
  225. package/dist/two-d/ui/FloatingText.js +52 -5
  226. package/dist/two-d/ui/FloatingText.js.map +1 -1
  227. package/dist/two-d/ui/FloatingTextStack.d.ts +86 -13
  228. package/dist/two-d/ui/FloatingTextStack.d.ts.map +1 -1
  229. package/dist/two-d/ui/FloatingTextStack.js +89 -18
  230. package/dist/two-d/ui/FloatingTextStack.js.map +1 -1
  231. package/dist/two-d/ui/Layout.d.ts +105 -0
  232. package/dist/two-d/ui/Layout.d.ts.map +1 -0
  233. package/dist/two-d/ui/Layout.js +174 -0
  234. package/dist/two-d/ui/Layout.js.map +1 -0
  235. package/dist/two-d/ui/ScrollBox.d.ts +67 -0
  236. package/dist/two-d/ui/ScrollBox.d.ts.map +1 -0
  237. package/dist/two-d/ui/ScrollBox.js +127 -0
  238. package/dist/two-d/ui/ScrollBox.js.map +1 -0
  239. package/dist/two-d/ui/Skins.d.ts +59 -0
  240. package/dist/two-d/ui/Skins.d.ts.map +1 -0
  241. package/dist/two-d/ui/Skins.js +77 -0
  242. package/dist/two-d/ui/Skins.js.map +1 -0
  243. package/dist/two-d/ui/Slider.d.ts +91 -0
  244. package/dist/two-d/ui/Slider.d.ts.map +1 -0
  245. package/dist/two-d/ui/Slider.js +170 -0
  246. package/dist/two-d/ui/Slider.js.map +1 -0
  247. package/dist/two-d/ui/Spinner.d.ts +67 -0
  248. package/dist/two-d/ui/Spinner.d.ts.map +1 -0
  249. package/dist/two-d/ui/Spinner.js +137 -0
  250. package/dist/two-d/ui/Spinner.js.map +1 -0
  251. package/dist/two-d/ui/TabbedList.d.ts +118 -0
  252. package/dist/two-d/ui/TabbedList.d.ts.map +1 -0
  253. package/dist/two-d/ui/TabbedList.js +221 -0
  254. package/dist/two-d/ui/TabbedList.js.map +1 -0
  255. package/dist/two-d/ui/TextModel.d.ts +65 -0
  256. package/dist/two-d/ui/TextModel.d.ts.map +1 -0
  257. package/dist/two-d/ui/TextModel.js +126 -0
  258. package/dist/two-d/ui/TextModel.js.map +1 -0
  259. package/dist/two-d/ui/TreeView.d.ts +68 -0
  260. package/dist/two-d/ui/TreeView.d.ts.map +1 -0
  261. package/dist/two-d/ui/TreeView.js +133 -0
  262. package/dist/two-d/ui/TreeView.js.map +1 -0
  263. package/dist/two-d/ui/Window.d.ts +13 -0
  264. package/dist/two-d/ui/Window.d.ts.map +1 -1
  265. package/dist/two-d/ui/Window.js +23 -0
  266. package/dist/two-d/ui/Window.js.map +1 -1
  267. package/dist/two-d/ui/WindowStack.d.ts.map +1 -1
  268. package/dist/two-d/ui/WindowStack.js +2 -0
  269. package/dist/two-d/ui/WindowStack.js.map +1 -1
  270. package/dist/two-d/ui/index.d.ts +27 -3
  271. package/dist/two-d/ui/index.d.ts.map +1 -1
  272. package/dist/two-d/ui/index.js +14 -2
  273. package/dist/two-d/ui/index.js.map +1 -1
  274. package/dist/two-d/ui/markup.d.ts +127 -0
  275. package/dist/two-d/ui/markup.d.ts.map +1 -0
  276. package/dist/two-d/ui/markup.js +322 -0
  277. package/dist/two-d/ui/markup.js.map +1 -0
  278. package/dist/version.d.ts +1 -1
  279. package/dist/version.js +1 -1
  280. package/dist/world/SideTurns.d.ts +115 -0
  281. package/dist/world/SideTurns.d.ts.map +1 -0
  282. package/dist/world/SideTurns.js +138 -0
  283. package/dist/world/SideTurns.js.map +1 -0
  284. package/dist/world/index.d.ts +2 -0
  285. package/dist/world/index.d.ts.map +1 -1
  286. package/dist/world/index.js +1 -0
  287. package/dist/world/index.js.map +1 -1
  288. package/package.json +8 -3
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Ties a second sprite's position to a first one's, with its own offset and its own optional
3
+ * lifetime - a shadow flat beneath a unit, a status icon floating above it, a shield glyph at a
4
+ * corner. `StatusVisuals` only tints a sprite that already exists; this is for a sprite that is
5
+ * its own thing, positioned relative to an owner rather than drawn as part of it.
6
+ *
7
+ * Renderer-neutral by the same design `Projectile` and `LightningArc` use: it takes any
8
+ * `{ x, y }` point (a real Pixi `Sprite`, a plain object, a test double) and only ever writes
9
+ * to it, so it needs no renderer to construct or test. Z-order and parenting stay the caller's,
10
+ * for the same reason `Halo` leaves them: whether a shadow is added before or after its unit is
11
+ * a per-game drawing decision, not something a framework should guess.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { SpriteAttachment } from '@datamoc/mw_games/two-d/render';
16
+ *
17
+ * declare const shadowSprite: { x: number; y: number };
18
+ * declare const statusIcon: { x: number; y: number };
19
+ *
20
+ * const shadow = new SpriteAttachment(shadowSprite, { offsetY: 4 });
21
+ * const poisoned = new SpriteAttachment(statusIcon, { offsetY: -20, duration: 3 });
22
+ *
23
+ * shadow.follow(100, 200);
24
+ * poisoned.follow(100, 200);
25
+ *
26
+ * const expired = poisoned.update(1 / 60);
27
+ * console.log(expired); // false - not yet 3 seconds in
28
+ * ```
29
+ */
30
+ export class SpriteAttachment {
31
+ constructor(child, options = {}) {
32
+ this.elapsed = 0;
33
+ this.expired = false;
34
+ this.child = child;
35
+ this.offsetX = options.offsetX ?? 0;
36
+ this.offsetY = options.offsetY ?? 0;
37
+ this.duration = options.duration;
38
+ }
39
+ get done() {
40
+ return this.expired;
41
+ }
42
+ /** puts the attachment where its owner stands, with whatever offset it was built with */
43
+ follow(ownerX, ownerY) {
44
+ this.child.x = ownerX + this.offsetX;
45
+ this.child.y = ownerY + this.offsetY;
46
+ return this;
47
+ }
48
+ /** @returns true the instant `duration` elapses, so a caller can remove it exactly once; always false with no `duration` */
49
+ update(dt) {
50
+ if (this.expired || this.duration === undefined)
51
+ return false;
52
+ this.elapsed += dt;
53
+ if (this.elapsed >= this.duration) {
54
+ this.expired = true;
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ }
60
+ //# sourceMappingURL=SpriteAttachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpriteAttachment.js","sourceRoot":"","sources":["../../../src/two-d/render/SpriteAttachment.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,gBAAgB;IAQ5B,YAAY,KAAsB,EAAE,OAAO,GAA4B,EAAE;QAHjE,YAAO,GAAG,CAAC,CAAC;QACZ,YAAO,GAAG,KAAK,CAAC;QAGvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,yFAAyF;IACzF,MAAM,CAAC,MAAc,EAAE,MAAc;QACpC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,4HAA4H;IAC5H,MAAM,CAAC,EAAU;QAChB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC9D,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD"}
@@ -0,0 +1,142 @@
1
+ import { Generator } from '../../core/Random.ts';
2
+ /**
3
+ * One condition a rule tests against a neighbouring cell (or its own cell, at `dx=0, dy=0`):
4
+ * which flags that cell must carry, must not carry, or carry at least one of. `dx`/`dy` are in
5
+ * whatever unit the caller's grid uses - a square or isometric grid's own cell steps, or an
6
+ * axial hex offset for `hexRotate` - `resolveTerrainGraphics` never interprets them itself.
7
+ */
8
+ export interface TerrainCondition {
9
+ readonly dx: number;
10
+ readonly dy: number;
11
+ readonly hasAll?: readonly string[];
12
+ readonly hasAny?: readonly string[];
13
+ readonly hasNone?: readonly string[];
14
+ }
15
+ /** One image a matched rule places, at an offset from the rule's own anchor cell. */
16
+ export interface TerrainImage {
17
+ readonly image: string;
18
+ /** offset from the anchor cell, in the same pixel/cell unit the caller draws with */
19
+ readonly dx?: number;
20
+ readonly dy?: number;
21
+ /** draw order among a rule's own images and other rules matching the same cell; higher draws later (on top) */
22
+ readonly layer?: number;
23
+ }
24
+ /**
25
+ * One `[terrain_graphics]`-style transition rule: a set of neighbour conditions that must all
26
+ * hold, and the image or images to draw when they do. A rule with more conditions is more
27
+ * specific and wins over a less specific one covering the same cell, the same precedence a
28
+ * hand-authored rule set expects (a "this exact corner" rule beats a "any edge" rule); among
29
+ * rules tied on specificity, `probability` weights which one is picked, so a terrain can vary
30
+ * its look without every variant needing a different neighbourhood to key off of.
31
+ */
32
+ export interface TerrainRule {
33
+ readonly id: string;
34
+ readonly conditions: readonly TerrainCondition[];
35
+ readonly images: readonly TerrainImage[];
36
+ /** relative weight among rules tied for most-specific at a cell; default 1 */
37
+ readonly probability?: number;
38
+ /**
39
+ * how many rotated copies of this rule to also try, each one `conditions`/`images` rotated
40
+ * by one more step of `rotate` (see `squareRotate`/`hexRotate`) - so one rule authored for
41
+ * one direction covers every direction a symmetric transition needs, instead of one rule
42
+ * per direction written out by hand. 0 or omitted tries only the rule as written.
43
+ */
44
+ readonly rotations?: number;
45
+ }
46
+ /** One resolved image placement: an absolute cell plus the rule's own image and offset. */
47
+ export interface TerrainPlacement {
48
+ readonly x: number;
49
+ readonly y: number;
50
+ readonly ruleId: string;
51
+ readonly image: string;
52
+ readonly dx: number;
53
+ readonly dy: number;
54
+ readonly layer: number;
55
+ }
56
+ /** The flags present at a cell, or `undefined` for a cell with no terrain at all (e.g. off the map). */
57
+ export type TerrainFlagsAt = (x: number, y: number) => ReadonlySet<string> | undefined;
58
+ /** Rotates one condition/image offset by `rotationIndex` of `rotations` total steps around the cell. */
59
+ export type TerrainRotate = (dx: number, dy: number, rotationIndex: number, rotations: number) => {
60
+ dx: number;
61
+ dy: number;
62
+ };
63
+ /**
64
+ * `TerrainRotate` for a square or isometric grid: exact 90-degree steps only (`rotations` must
65
+ * be a multiple of 4, or 0).
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { squareRotate } from '@datamoc/mw_games/two-d/render';
70
+ *
71
+ * console.log(squareRotate(1, 0, 1, 4)); // { dx: 0, dy: 1 } - one 90-degree step
72
+ * ```
73
+ */
74
+ export declare function squareRotate(dx: number, dy: number, rotationIndex: number, rotations: number): {
75
+ dx: number;
76
+ dy: number;
77
+ };
78
+ /**
79
+ * `TerrainRotate` for an axial hex grid: exact 60-degree steps (`rotations` must be a multiple
80
+ * of 6, or 0), via the standard cube-coordinate rotation (`q,r,s -> -r,-s,-q` per 60-degree step,
81
+ * `s = -q - r`).
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { hexRotate } from '@datamoc/mw_games/two-d/render';
86
+ *
87
+ * console.log(hexRotate(1, 0, 1, 6)); // one 60-degree step of the axial offset (1, 0)
88
+ * ```
89
+ */
90
+ export declare function hexRotate(dx: number, dy: number, rotationIndex: number, rotations: number): {
91
+ dx: number;
92
+ dy: number;
93
+ };
94
+ /**
95
+ * Whether `rule`, rotated by `rotationIndex` of `rotations` steps, matches the cell at `x, y`.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * import { matchTerrainRule } from '@datamoc/mw_games/two-d/render';
100
+ *
101
+ * const rule = { id: 'coast', conditions: [{ dx: 1, dy: 0, hasAll: ['water'] }], images: [] };
102
+ * const flagsAt = (x: number, y: number) => (x === 1 && y === 0 ? new Set(['water']) : new Set(['land']));
103
+ * console.log(matchTerrainRule(rule, 0, 0, flagsAt)); // true
104
+ * ```
105
+ */
106
+ export declare function matchTerrainRule(rule: TerrainRule, x: number, y: number, flagsAt: TerrainFlagsAt, rotate?: TerrainRotate, rotationIndex?: number): boolean;
107
+ export interface ResolveTerrainGraphicsOptions {
108
+ rotate?: TerrainRotate;
109
+ /** deterministic when given a seeded `Generator`; a fresh unseeded one otherwise */
110
+ random?: Generator;
111
+ }
112
+ /**
113
+ * Resolves a `[terrain_graphics]`-style rule set over a grid into the flat list of image
114
+ * placements a renderer draws, the generalisation `Autotile`'s 47-shape blob table cannot
115
+ * express: a rule can test flags rather than only "same terrain", key off any offset rather
116
+ * than only the 8 immediate neighbours, place more than one image (so a piece bigger than one
117
+ * cell, overlapping its neighbours, is one rule's `images` rather than something `TileMap`'s
118
+ * one-sprite-per-cell grid has to hold), and vary by rotation or probability.
119
+ *
120
+ * At each cell, every rule (at every rotation it declares) is tested; among the rules that
121
+ * match, the most specific (most conditions) wins, and `probability` breaks a tie among rules
122
+ * of equal specificity. A cell with no matching rule contributes nothing. The result is plain
123
+ * data - which cell, which rule, which image, at what offset and layer - a caller draws
124
+ * through `TileMap`, a custom `Sprite` pass, or anything else; this function never touches a
125
+ * renderer itself.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * import { resolveTerrainGraphics } from '@datamoc/mw_games/two-d/render';
130
+ *
131
+ * const water = new Set(['water']);
132
+ * const land = new Set(['land']);
133
+ * const flagsAt = (x: number, y: number) => (x === 0 ? water : land);
134
+ *
135
+ * const placements = resolveTerrainGraphics(2, 1, [
136
+ * { id: 'coast', conditions: [{ dx: 0, dy: 0, hasAll: ['land'] }, { dx: -1, dy: 0, hasAll: ['water'] }], images: [{ image: 'coast.png' }] },
137
+ * ], flagsAt);
138
+ * console.log(placements); // [{ x: 1, y: 0, ruleId: 'coast', image: 'coast.png', dx: 0, dy: 0, layer: 0 }]
139
+ * ```
140
+ */
141
+ export declare function resolveTerrainGraphics(width: number, height: number, rules: readonly TerrainRule[], flagsAt: TerrainFlagsAt, options?: ResolveTerrainGraphicsOptions): TerrainPlacement[];
142
+ //# sourceMappingURL=TerrainGraphics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerrainGraphics.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/TerrainGraphics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SA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ACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE,6BAAkC,GACzC,gBAAgB,EAAE,CAmDpB"}
@@ -0,0 +1,161 @@
1
+ import { Generator } from '../../core/Random.js';
2
+ /**
3
+ * `TerrainRotate` for a square or isometric grid: exact 90-degree steps only (`rotations` must
4
+ * be a multiple of 4, or 0).
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { squareRotate } from '@datamoc/mw_games/two-d/render';
9
+ *
10
+ * console.log(squareRotate(1, 0, 1, 4)); // { dx: 0, dy: 1 } - one 90-degree step
11
+ * ```
12
+ */
13
+ export function squareRotate(dx, dy, rotationIndex, rotations) {
14
+ const steps = (rotationIndex * 4) / rotations;
15
+ let x = dx;
16
+ let y = dy;
17
+ for (let i = 0; i < steps; i += 1)
18
+ [x, y] = [-y, x];
19
+ return { dx: x || 0, dy: y || 0 };
20
+ }
21
+ /**
22
+ * `TerrainRotate` for an axial hex grid: exact 60-degree steps (`rotations` must be a multiple
23
+ * of 6, or 0), via the standard cube-coordinate rotation (`q,r,s -> -r,-s,-q` per 60-degree step,
24
+ * `s = -q - r`).
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { hexRotate } from '@datamoc/mw_games/two-d/render';
29
+ *
30
+ * console.log(hexRotate(1, 0, 1, 6)); // one 60-degree step of the axial offset (1, 0)
31
+ * ```
32
+ */
33
+ export function hexRotate(dx, dy, rotationIndex, rotations) {
34
+ const steps = (rotationIndex * 6) / rotations;
35
+ let q = dx;
36
+ let r = dy;
37
+ for (let i = 0; i < steps; i += 1) {
38
+ const s = -q - r;
39
+ [q, r] = [-r, -s];
40
+ }
41
+ return { dx: q || 0, dy: r || 0 };
42
+ }
43
+ function conditionMatches(condition, flags) {
44
+ const present = flags ?? new Set();
45
+ if (condition.hasAll && !condition.hasAll.every((flag) => present.has(flag)))
46
+ return false;
47
+ if (condition.hasAny && !condition.hasAny.some((flag) => present.has(flag)))
48
+ return false;
49
+ if (condition.hasNone && condition.hasNone.some((flag) => present.has(flag)))
50
+ return false;
51
+ return true;
52
+ }
53
+ /**
54
+ * Whether `rule`, rotated by `rotationIndex` of `rotations` steps, matches the cell at `x, y`.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { matchTerrainRule } from '@datamoc/mw_games/two-d/render';
59
+ *
60
+ * const rule = { id: 'coast', conditions: [{ dx: 1, dy: 0, hasAll: ['water'] }], images: [] };
61
+ * const flagsAt = (x: number, y: number) => (x === 1 && y === 0 ? new Set(['water']) : new Set(['land']));
62
+ * console.log(matchTerrainRule(rule, 0, 0, flagsAt)); // true
63
+ * ```
64
+ */
65
+ export function matchTerrainRule(rule, x, y, flagsAt, rotate = squareRotate, rotationIndex = 0) {
66
+ const rotations = rule.rotations ?? 0;
67
+ return rule.conditions.every((condition) => {
68
+ const offset = rotations > 0 ? rotate(condition.dx, condition.dy, rotationIndex, rotations) : condition;
69
+ return conditionMatches(condition, flagsAt(x + offset.dx, y + offset.dy));
70
+ });
71
+ }
72
+ /**
73
+ * Resolves a `[terrain_graphics]`-style rule set over a grid into the flat list of image
74
+ * placements a renderer draws, the generalisation `Autotile`'s 47-shape blob table cannot
75
+ * express: a rule can test flags rather than only "same terrain", key off any offset rather
76
+ * than only the 8 immediate neighbours, place more than one image (so a piece bigger than one
77
+ * cell, overlapping its neighbours, is one rule's `images` rather than something `TileMap`'s
78
+ * one-sprite-per-cell grid has to hold), and vary by rotation or probability.
79
+ *
80
+ * At each cell, every rule (at every rotation it declares) is tested; among the rules that
81
+ * match, the most specific (most conditions) wins, and `probability` breaks a tie among rules
82
+ * of equal specificity. A cell with no matching rule contributes nothing. The result is plain
83
+ * data - which cell, which rule, which image, at what offset and layer - a caller draws
84
+ * through `TileMap`, a custom `Sprite` pass, or anything else; this function never touches a
85
+ * renderer itself.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { resolveTerrainGraphics } from '@datamoc/mw_games/two-d/render';
90
+ *
91
+ * const water = new Set(['water']);
92
+ * const land = new Set(['land']);
93
+ * const flagsAt = (x: number, y: number) => (x === 0 ? water : land);
94
+ *
95
+ * const placements = resolveTerrainGraphics(2, 1, [
96
+ * { id: 'coast', conditions: [{ dx: 0, dy: 0, hasAll: ['land'] }, { dx: -1, dy: 0, hasAll: ['water'] }], images: [{ image: 'coast.png' }] },
97
+ * ], flagsAt);
98
+ * console.log(placements); // [{ x: 1, y: 0, ruleId: 'coast', image: 'coast.png', dx: 0, dy: 0, layer: 0 }]
99
+ * ```
100
+ */
101
+ export function resolveTerrainGraphics(width, height, rules, flagsAt, options = {}) {
102
+ const rotate = options.rotate ?? squareRotate;
103
+ const random = options.random ?? new Generator();
104
+ const placements = [];
105
+ for (let y = 0; y < height; y += 1) {
106
+ for (let x = 0; x < width; x += 1) {
107
+ let bestSpecificity = -1;
108
+ let candidates = [];
109
+ for (const rule of rules) {
110
+ const rotations = rule.rotations ?? 0;
111
+ const steps = rotations > 0 ? rotations : 1;
112
+ for (let rotationIndex = 0; rotationIndex < steps; rotationIndex += 1) {
113
+ if (!matchTerrainRule(rule, x, y, flagsAt, rotate, rotationIndex))
114
+ continue;
115
+ const specificity = rule.conditions.length;
116
+ if (specificity > bestSpecificity) {
117
+ bestSpecificity = specificity;
118
+ candidates = [{ rule, rotationIndex }];
119
+ }
120
+ else if (specificity === bestSpecificity) {
121
+ candidates.push({ rule, rotationIndex });
122
+ }
123
+ }
124
+ }
125
+ if (candidates.length === 0)
126
+ continue;
127
+ const chosen = candidates.length === 1
128
+ ? candidates[0]
129
+ : candidates[weightedIndex(candidates.map((c) => c.rule.probability ?? 1), random)];
130
+ const rotations = chosen.rule.rotations ?? 0;
131
+ for (const image of chosen.rule.images) {
132
+ const offset = rotations > 0
133
+ ? rotate(image.dx ?? 0, image.dy ?? 0, chosen.rotationIndex, rotations)
134
+ : { dx: image.dx ?? 0, dy: image.dy ?? 0 };
135
+ placements.push({
136
+ x,
137
+ y,
138
+ ruleId: chosen.rule.id,
139
+ image: image.image,
140
+ dx: offset.dx,
141
+ dy: offset.dy,
142
+ layer: image.layer ?? 0,
143
+ });
144
+ }
145
+ }
146
+ }
147
+ return placements;
148
+ }
149
+ function weightedIndex(weights, random) {
150
+ const total = weights.reduce((sum, weight) => sum + Math.max(0, weight), 0);
151
+ if (total <= 0)
152
+ return 0;
153
+ let roll = random.float() * total;
154
+ for (let index = 0; index < weights.length; index += 1) {
155
+ roll -= Math.max(0, weights[index]);
156
+ if (roll < 0)
157
+ return index;
158
+ }
159
+ return weights.length - 1;
160
+ }
161
+ //# sourceMappingURL=TerrainGraphics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerrainGraphics.js","sourceRoot":"","sources":["../../../src/two-d/render/TerrainGraphics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAkEjD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,EAAU,EAAE,EAAU,EAAE,aAAqB,EAAE,SAAiB;IAC5F,MAAM,KAAK,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC;QAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU,EAAE,EAAU,EAAE,aAAqB,EAAE,SAAiB;IACzF,MAAM,KAAK,GAAG,CA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GAAG,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  export { ColorTransformBatcher, packColorAdd, packTintAdd, NO_COLOR_ADD } from './ColorTransformBatcher.ts';
2
2
  export type { HasColorAdd } from './ColorTransformBatcher.ts';
3
3
  export { TintedSprite, registerColorTransform } from './TintedSprite.ts';
4
- export { applyImageModifiers, colorShiftMatrix, croppedTexture, imageModifier, parseImagePath, } from './ImageModifiers.ts';
5
- export type { ImageModifier, ParsedImagePath } from './ImageModifiers.ts';
4
+ export { applyImageModifiers, applyTextureModifiers, blendMatrix, blendPixels, channelScaleMatrix, channelSwapMatrix, colorShiftMatrix, croppedTexture, imageModifier, maskPixels, parseColorPairs, parseImagePath, parsePaletteLists, rotatePixels, } from './ImageModifiers.ts';
5
+ export type { ChannelSource, ImageModifier, ImageTextureProbe, ParsedImagePath, RotatedPixels } from './ImageModifiers.ts';
6
6
  export { AnimatedSprite, Animation } from './AnimatedSprite.ts';
7
- export type { AnimationOptions } from './AnimatedSprite.ts';
7
+ export type { AnimationFrame, AnimationFrameInput, AnimationOptions } from './AnimatedSprite.ts';
8
8
  export { SpriteSheet } from './SpriteSheet.ts';
9
9
  export { Camera, createCamera, snapZoom } from './Camera.ts';
10
10
  export type { CameraOptions } from './Camera.ts';
@@ -19,6 +19,12 @@ export type { TileMapOptions } from './TileMap.ts';
19
19
  export { LayeredSprite } from './LayeredSprite.ts';
20
20
  export { Projectile } from './Projectile.ts';
21
21
  export type { ProjectilePoint, ProjectileOptions } from './Projectile.ts';
22
+ export { LightningArc } from './LightningArc.ts';
23
+ export type { LightningArcOptions, LightningArcPoint } from './LightningArc.ts';
24
+ export { SpriteAttachment } from './SpriteAttachment.ts';
25
+ export type { AttachmentPoint, SpriteAttachmentOptions } from './SpriteAttachment.ts';
26
+ export { Halo, HALO_ANIMATION } from './Halo.ts';
27
+ export type { HaloOptions } from './Halo.ts';
22
28
  export { ParticleEmitter } from './Particles.ts';
23
29
  export type { Particle, ParticleRange, ParticleEmitterOptions } from './Particles.ts';
24
30
  export { ScreenEffects } from './ScreenEffects.ts';
@@ -29,11 +35,15 @@ export { StatusVisuals } from './StatusVisuals.ts';
29
35
  export type { TintTarget, StatusVisualStyle, StatusVisualsOptions } from './StatusVisuals.ts';
30
36
  export { blobIndex, autotileFrames, BLOB_SHAPES } from './Autotile.ts';
31
37
  export type { NeighborMask } from './Autotile.ts';
38
+ export { hexRotate, matchTerrainRule, resolveTerrainGraphics, squareRotate } from './TerrainGraphics.ts';
39
+ export type { ResolveTerrainGraphicsOptions, TerrainCondition, TerrainFlagsAt, TerrainImage, TerrainPlacement, TerrainRotate, TerrainRule, } from './TerrainGraphics.ts';
32
40
  export { inspectGraphicsCapabilities, detectWebGpu, RENDERING_DECISIONS } from './Capabilities.ts';
33
41
  export type { GraphicsCapabilities, GraphicsProbe, GraphicsWorkload, RenderingDecision, WebGpuDetection, } from './Capabilities.ts';
34
42
  export { Container2D, Rectangle2D, Texture2D, rectOf } from './Types2D.ts';
35
43
  export type { Rect, TextureRegion } from './Types2D.ts';
36
44
  export { Node2D, Shape2D, Text2D, Sprite2D, TiledSprite, Gradient } from './Shape2D.ts';
45
+ export { paletteRangeMapping, recolorTexture, remapPixels, withTextureCanvas } from './PaletteRemap.ts';
46
+ export type { PaletteMapping, PaletteRange, PaletteRemapMode, RecolorProbe, RemapCanvas, RemapCanvasContext, } from './PaletteRemap.ts';
37
47
  export { loadTiledMap } from './TiledMap.ts';
38
48
  export type { TiledMapData, TiledTilesetData, TilesetSheet, LoadedTiledMap, TiledObject, TiledLayer, } from './TiledMap.ts';
39
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/two-d/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC5G,YAAY,EAAE,WAAW,EAAE,MAAM,4B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AM,eAAe,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzG,YAAY,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,GACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnG,YAAY,EACX,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxG,YAAY,EACX,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,GACV,MAAM,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { ColorTransformBatcher, packColorAdd, packTintAdd, NO_COLOR_ADD } from './ColorTransformBatcher.js';
2
2
  export { TintedSprite, registerColorTransform } from './TintedSprite.js';
3
- export { applyImageModifiers, colorShiftMatrix, croppedTexture, imageModifier, parseImagePath, } from './ImageModifiers.js';
3
+ export { applyImageModifiers, applyTextureModifiers, blendMatrix, blendPixels, channelScaleMatrix, channelSwapMatrix, colorShiftMatrix, croppedTexture, imageModifier, maskPixels, parseColorPairs, parseImagePath, parsePaletteLists, rotatePixels, } from './ImageModifiers.js';
4
4
  export { AnimatedSprite, Animation } from './AnimatedSprite.js';
5
5
  export { SpriteSheet } from './SpriteSheet.js';
6
6
  export { Camera, createCamera, snapZoom } from './Camera.js';
@@ -10,13 +10,18 @@ export { Minimap, newlyRevealed, minimapCellCenter } from './Minimap.js';
10
10
  export { TileMap, EMPTY, tileFrame, tileFrameSheet, tileFrameIndex } from './TileMap.js';
11
11
  export { LayeredSprite } from './LayeredSprite.js';
12
12
  export { Projectile } from './Projectile.js';
13
+ export { LightningArc } from './LightningArc.js';
14
+ export { SpriteAttachment } from './SpriteAttachment.js';
15
+ export { Halo, HALO_ANIMATION } from './Halo.js';
13
16
  export { ParticleEmitter } from './Particles.js';
14
17
  export { ScreenEffects } from './ScreenEffects.js';
15
18
  export { ActorAnimator } from './ActorAnimator.js';
16
19
  export { StatusVisuals } from './StatusVisuals.js';
17
20
  export { blobIndex, autotileFrames, BLOB_SHAPES } from './Autotile.js';
21
+ export { hexRotate, matchTerrainRule, resolveTerrainGraphics, squareRotate } from './TerrainGraphics.js';
18
22
  export { inspectGraphicsCapabilities, detectWebGpu, RENDERING_DECISIONS } from './Capabilities.js';
19
23
  export { Container2D, Rectangle2D, Texture2D, rectOf } from './Types2D.js';
20
24
  export { Node2D, Shape2D, Text2D, Sprite2D, TiledSprite, Gradient } from './Shape2D.js';
25
+ export { paletteRangeMapping, recolorTexture, remapPixels, withTextureCanvas } from './PaletteRemap.js';
21
26
  export { loadTiledMap } from './TiledMap.js';
22
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/two-d/render/index.ts"],"names":[],"mappings":"A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UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAWzG,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASnG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUxG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { Container, Texture } from 'pixi.js';
2
+ import { Signal } from '../../core/Signal.ts';
3
+ /** One full-screen story beat: a backdrop image, a title, the text, and the music under it. */
4
+ export interface StoryBeat {
5
+ text: string;
6
+ title?: string;
7
+ /** the backdrop image path, resolved by the screen's `textureFor` */
8
+ image?: string;
9
+ /** the music track to play while this beat is up */
10
+ music?: string;
11
+ }
12
+ /**
13
+ * The beats of a story screen and where the reader is in them, with no renderer attached - the
14
+ * same split `TabbedList` keeps, so the advance/back/skip rules are testable without a DOM.
15
+ *
16
+ * Music is reported as a signal rather than played: the sequence says *what* track a beat wants,
17
+ * and the game decides whether to crossfade, loop or ignore it. A beat with no `music` reports
18
+ * `null`, so a reader who turns the page to a silent beat gets the previous track stopped.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { StorySequence } from '@datamoc/mw_games/two-d/stage';
23
+ *
24
+ * const story = new StorySequence([
25
+ * { title: 'Prologue', text: 'The war begins.', music: 'intro.ogg' },
26
+ * { text: 'And so it went.' },
27
+ * ]);
28
+ * story.onMusic.add((track) => console.log(track)); // 'intro.ogg', then null
29
+ * story.advance();
30
+ * console.log(story.done); // true, only one page was left
31
+ * ```
32
+ */
33
+ export declare class StorySequence {
34
+ readonly onChange: Signal<StoryBeat>;
35
+ readonly onMusic: Signal<string | null>;
36
+ private readonly beats;
37
+ private index;
38
+ constructor(beats: readonly StoryBeat[]);
39
+ get length(): number;
40
+ /** the beat on screen, 0 when empty */
41
+ get position(): number;
42
+ /** the beat on screen; `null` for an empty story */
43
+ get current(): StoryBeat | null;
44
+ /** whether the last beat is the one on screen */
45
+ get done(): boolean;
46
+ /** the music the current beat wants, or `null` for silence */
47
+ get music(): string | null;
48
+ /** moves to a beat, clamped to the ends; reports the beat and its music either way */
49
+ goTo(index: number): void;
50
+ /** turns one page; false when there was no next page */
51
+ advance(): boolean;
52
+ /** turns back one page; false when already at the first */
53
+ back(): boolean;
54
+ /** jumps to the last beat, the "skip" a player who has read it before reaches for */
55
+ skip(): void;
56
+ restart(): void;
57
+ private report;
58
+ }
59
+ export interface StoryScreenOptions {
60
+ sequence: StorySequence;
61
+ width: number;
62
+ height: number;
63
+ /** how a beat's `image` path becomes a texture; `null` when the path cannot be resolved */
64
+ textureFor?: (path: string) => Texture | null;
65
+ /** called with the current beat's music, or `null` for a silent beat */
66
+ playMusic?: (track: string | null) => void;
67
+ }
68
+ /**
69
+ * A full-screen story beat: a backdrop image, a title and the text over it, advanced by a click -
70
+ * the campaign interlude a scenario shows between maps.
71
+ *
72
+ * `DialogueStage` is the visual-novel model: characters standing on a backdrop, a box under them
73
+ * doing the talking. This is the other shape an interlude needs and that one is not - one page of
74
+ * prose filling the screen, no cast, page forward on any input - so it reuses the same `Label`
75
+ * everything else lays words out with and leaves the sequencing to `StorySequence`, the part worth
76
+ * testing without a renderer. Feeding it `MwlWorld.story` from an `.mwl` scenario is the intended
77
+ * use: both carry the same `{ text, title, image, music }` shape.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { StoryScreen, StorySequence } from '@datamoc/mw_games/two-d/stage';
82
+ *
83
+ * const sequence = new StorySequence([{ title: 'Prologue', text: 'The war begins.' }]);
84
+ * const screen = new StoryScreen({ sequence, width: 960, height: 540 });
85
+ * console.log(screen.current?.title); // 'Prologue'
86
+ * ```
87
+ */
88
+ export declare class StoryScreen extends Container {
89
+ readonly sequence: StorySequence;
90
+ private readonly backdrop;
91
+ private readonly titleLabel;
92
+ private readonly textLabel;
93
+ private readonly textureFor;
94
+ private readonly playMusic;
95
+ private width_;
96
+ private height_;
97
+ constructor(options: StoryScreenOptions);
98
+ /** the beat on screen */
99
+ get current(): StoryBeat | null;
100
+ /** turns one page; false when the story is over, the caller's cue to change scene */
101
+ advance(): boolean;
102
+ /** jumps to the end, for a player who has already read it */
103
+ skip(): void;
104
+ resize(width: number, height: number): void;
105
+ private readonly handleAdvance;
106
+ private readonly handleBeat;
107
+ private applyBeat;
108
+ destroy(options?: Parameters<Container['destroy']>[0]): void;
109
+ }
110
+ //# sourceMappingURL=StoryScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryScreen.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/StoryScreen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,MA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