@zylem/behaviors 0.8.9 → 0.8.11

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 (168) hide show
  1. package/dist/acrobatics-2d.d.ts +25 -0
  2. package/dist/acrobatics-2d.js +37 -0
  3. package/dist/action-rpg.d.ts +21 -0
  4. package/dist/action-rpg.js +39 -0
  5. package/dist/adventure-tools.d.ts +22 -0
  6. package/dist/adventure-tools.js +39 -0
  7. package/dist/behavior-descriptor-NS_qnzzp.d.ts +4527 -0
  8. package/dist/behavior-metadata-Drm1zxI2.d.ts +13 -0
  9. package/dist/catalog.d.ts +2143 -0
  10. package/dist/catalog.js +9 -0
  11. package/dist/chunk-2BE5BW7D.js +130 -0
  12. package/dist/{chunk-CTSYM56P.js → chunk-2QCCLHJC.js} +10 -6
  13. package/dist/chunk-2UGT4MIF.js +94 -0
  14. package/dist/chunk-3J3ISPFQ.js +99 -0
  15. package/dist/chunk-3LBGEWT6.js +124 -0
  16. package/dist/{chunk-UUMH3DC3.js → chunk-3QBNWT7B.js} +5 -1
  17. package/dist/chunk-3T44EDXU.js +114 -0
  18. package/dist/chunk-5AJJ44QK.js +129 -0
  19. package/dist/{chunk-YDLO5M7S.js → chunk-5SMXQ6AU.js} +1 -0
  20. package/dist/chunk-5VJIP535.js +71 -0
  21. package/dist/chunk-6DTIJB7B.js +166 -0
  22. package/dist/chunk-73MHJY6R.js +78 -0
  23. package/dist/chunk-73YASAYS.js +137 -0
  24. package/dist/{chunk-LLDLVVG4.js → chunk-7HGDADLB.js} +25 -9
  25. package/dist/chunk-7IOQEXYR.js +92 -0
  26. package/dist/{chunk-OU2SW4U5.js → chunk-APAM55J3.js} +10 -6
  27. package/dist/chunk-BLTBZJPG.js +126 -0
  28. package/dist/chunk-BN6QZDR5.js +90 -0
  29. package/dist/chunk-BR33KT4Z.js +3186 -0
  30. package/dist/chunk-C5AYL42A.js +138 -0
  31. package/dist/{chunk-OBF6BIA2.js → chunk-CBQSC6W3.js} +2 -2
  32. package/dist/chunk-DDLZLJ7W.js +8 -0
  33. package/dist/chunk-DRIXFB4C.js +132 -0
  34. package/dist/{chunk-7CE6OHLW.js → chunk-DTLUKSX2.js} +6 -2
  35. package/dist/{chunk-TK3AXXXI.js → chunk-EMEA45JQ.js} +10 -6
  36. package/dist/chunk-EQFLPRF7.js +130 -0
  37. package/dist/{chunk-M25QJBDN.js → chunk-GNRMH7D3.js} +18 -6
  38. package/dist/chunk-GYEKT5AY.js +102 -0
  39. package/dist/{chunk-SHZZ2QRV.js → chunk-HCWLIPXP.js} +5 -1
  40. package/dist/{chunk-WHKPWIQO.js → chunk-HMVEQB2T.js} +1 -0
  41. package/dist/chunk-HQ2UFI3S.js +116 -0
  42. package/dist/chunk-I52PC5IU.js +128 -0
  43. package/dist/{chunk-CB3C7CRD.js → chunk-IAIJG2PB.js} +10 -6
  44. package/dist/{chunk-NDJO56BB.js → chunk-IJILTFEL.js} +5 -1
  45. package/dist/{chunk-7GGR26YA.js → chunk-IRNU4JGV.js} +10 -6
  46. package/dist/chunk-IRPBFVAK.js +141 -0
  47. package/dist/chunk-JFBR4FNX.js +140 -0
  48. package/dist/{chunk-ERS6SNA5.js → chunk-K34N2CBL.js} +5 -1
  49. package/dist/chunk-LMMF7KXF.js +178 -0
  50. package/dist/chunk-LWGJ3QQZ.js +107 -0
  51. package/dist/chunk-MPNGQLHZ.js +132 -0
  52. package/dist/chunk-OH5LJAEJ.js +135 -0
  53. package/dist/{chunk-57GLKGEX.js → chunk-P6TMZSWF.js} +32 -7
  54. package/dist/chunk-PDHHOVVQ.js +126 -0
  55. package/dist/{chunk-7TIIRJKF.js → chunk-RUBKGAPS.js} +5 -1
  56. package/dist/chunk-S44ZHYE6.js +1912 -0
  57. package/dist/chunk-SFMJNAW3.js +128 -0
  58. package/dist/{chunk-E2MOFIDH.js → chunk-SKKVOH6D.js} +13 -7
  59. package/dist/{chunk-RR3XNDKG.js → chunk-T2LAQQDS.js} +1 -1
  60. package/dist/chunk-TSYXRRS4.js +125 -0
  61. package/dist/chunk-TZHO6P22.js +150 -0
  62. package/dist/chunk-V26L6MY6.js +127 -0
  63. package/dist/chunk-V4M46BF6.js +105 -0
  64. package/dist/chunk-VSFWETXS.js +127 -0
  65. package/dist/chunk-VU4LTE2X.js +147 -0
  66. package/dist/chunk-WF6HC5U3.js +8 -0
  67. package/dist/chunk-WG5NCDS4.js +99 -0
  68. package/dist/{chunk-7LHXAEOZ.js → chunk-WUYHS6JZ.js} +6 -2
  69. package/dist/chunk-XNRY6NOC.js +120 -0
  70. package/dist/{chunk-55CFXXZH.js → chunk-XT47QZQ6.js} +32 -7
  71. package/dist/chunk-Y5CCNMJI.js +58 -0
  72. package/dist/chunk-YVVB6YMG.js +133 -0
  73. package/dist/chunk-ZZXTGVGN.js +131 -0
  74. package/dist/combat-ai.d.ts +21 -0
  75. package/dist/combat-ai.js +41 -0
  76. package/dist/{components--RTwuT4S.d.ts → components-ClmBORMP.d.ts} +1 -1
  77. package/dist/cooldown.d.ts +2 -8
  78. package/dist/cooldown.js +3 -2
  79. package/dist/coordinators/boundary-ricochet-3d.d.ts +3 -2
  80. package/dist/coordinators/boundary-ricochet-3d.js +2 -2
  81. package/dist/coordinators/boundary-ricochet.d.ts +3 -2
  82. package/dist/coordinators/boundary-ricochet.js +2 -2
  83. package/dist/coordinators/multidirectional-space-shooter.d.ts +3 -2
  84. package/dist/coordinators/multidirectional-space-shooter.js +2 -2
  85. package/dist/coordinators/top-down-shooter.d.ts +3 -2
  86. package/dist/coordinators/top-down-shooter.js +2 -2
  87. package/dist/core.d.ts +387 -26
  88. package/dist/core.js +1583 -6
  89. package/dist/destructible-3d.d.ts +3 -2
  90. package/dist/destructible-3d.js +3 -2
  91. package/dist/destructible-prebake.d.ts +1 -1
  92. package/dist/environmental-locomotion.d.ts +23 -0
  93. package/dist/environmental-locomotion.js +35 -0
  94. package/dist/first-person.d.ts +3 -2
  95. package/dist/first-person.js +25 -4
  96. package/dist/golf-racket.d.ts +21 -0
  97. package/dist/golf-racket.js +37 -0
  98. package/dist/index.d.ts +28 -6
  99. package/dist/index.js +766 -82
  100. package/dist/jumper-2d.d.ts +2 -1
  101. package/dist/jumper-2d.js +25 -4
  102. package/dist/jumper-3d.d.ts +2 -1
  103. package/dist/jumper-3d.js +25 -4
  104. package/dist/lane-defense.d.ts +21 -0
  105. package/dist/lane-defense.js +39 -0
  106. package/dist/life-simulation.d.ts +21 -0
  107. package/dist/life-simulation.js +39 -0
  108. package/dist/matching-pinball.d.ts +21 -0
  109. package/dist/matching-pinball.js +39 -0
  110. package/dist/melee-combat.d.ts +22 -0
  111. package/dist/melee-combat.js +45 -0
  112. package/dist/{moveable-CFOHmblC.d.ts → moveable-CXK2wEZL.d.ts} +2 -2
  113. package/dist/particle-emitter/presets.d.ts +1 -1
  114. package/dist/particle-emitter.d.ts +5 -4
  115. package/dist/particle-emitter.js +3 -2
  116. package/dist/{payload-BQzu-oY_.d.ts → payload-WEzfgjSL.d.ts} +1 -1
  117. package/dist/platformer-2d.d.ts +2 -1
  118. package/dist/platformer-2d.js +25 -4
  119. package/dist/platformer-3d.d.ts +2 -1
  120. package/dist/platformer-3d.js +25 -4
  121. package/dist/racing-vehicles.d.ts +21 -0
  122. package/dist/racing-vehicles.js +37 -0
  123. package/dist/rhythm-performance.d.ts +21 -0
  124. package/dist/rhythm-performance.js +39 -0
  125. package/dist/ricochet-2d.d.ts +2 -1
  126. package/dist/ricochet-2d.js +25 -4
  127. package/dist/ricochet-3d.d.ts +2 -1
  128. package/dist/ricochet-3d.js +25 -4
  129. package/dist/runtime-2d.d.ts +2 -1
  130. package/dist/runtime-2d.js +10 -1
  131. package/dist/screen-visibility.d.ts +2 -1
  132. package/dist/screen-visibility.js +3 -2
  133. package/dist/screen-wrap.d.ts +2 -7
  134. package/dist/screen-wrap.js +4 -3
  135. package/dist/shooter-2d.d.ts +3 -2
  136. package/dist/shooter-2d.js +3 -2
  137. package/dist/skate-snowboard.d.ts +21 -0
  138. package/dist/skate-snowboard.js +37 -0
  139. package/dist/{spark-C4Tp-52_.d.ts → spark-VoQoemz_.d.ts} +1 -1
  140. package/dist/spatial-puzzles.d.ts +21 -0
  141. package/dist/spatial-puzzles.js +35 -0
  142. package/dist/squad-rts.d.ts +21 -0
  143. package/dist/squad-rts.js +39 -0
  144. package/dist/stealth-city.d.ts +21 -0
  145. package/dist/stealth-city.js +41 -0
  146. package/dist/survival-resources.d.ts +21 -0
  147. package/dist/survival-resources.js +37 -0
  148. package/dist/tactical-grid.d.ts +21 -0
  149. package/dist/tactical-grid.js +39 -0
  150. package/dist/thruster.d.ts +2 -1
  151. package/dist/thruster.js +4 -3
  152. package/dist/top-down-movement.d.ts +2 -1
  153. package/dist/top-down-movement.js +24 -3
  154. package/dist/turn-based-rpg.d.ts +21 -0
  155. package/dist/turn-based-rpg.js +39 -0
  156. package/dist/{vector-DjhLUrak.d.ts → vector-s7GbCrVn.d.ts} +1 -1
  157. package/dist/weapon-systems.d.ts +22 -0
  158. package/dist/weapon-systems.js +45 -0
  159. package/dist/world-boundary-2d.d.ts +2 -1
  160. package/dist/world-boundary-2d.js +25 -4
  161. package/dist/world-boundary-3d.d.ts +2 -1
  162. package/dist/world-boundary-3d.js +26 -5
  163. package/package.json +90 -5
  164. package/dist/behavior-system-DkFAwLb_.d.ts +0 -914
  165. package/dist/chunk-GZ3DQIIZ.js +0 -888
  166. package/dist/{chunk-OSPQFWQF.js → chunk-4K37UL53.js} +3 -3
  167. package/dist/{chunk-DD4U42FG.js → chunk-AQB246W5.js} +3 -3
  168. package/dist/{chunk-UKGBQTHL.js → chunk-CXDNR4R4.js} +3 -3
@@ -0,0 +1,178 @@
1
+ // src/lib/behaviors/turn-based-rpg/types.ts
2
+ var BATTLE_ABILITIES = [
3
+ "priority-speed-turn-order",
4
+ "type-effectiveness-matrix",
5
+ "turn-duration-status",
6
+ "capture-attempt-resolution",
7
+ "conditional-evolution",
8
+ "timed-battle-action-command",
9
+ "active-partner-swap",
10
+ "budgeted-passive-loadout",
11
+ "field-first-strike",
12
+ "escape-attempt"
13
+ ];
14
+ var BATTLE_EVENTS = [
15
+ ...BATTLE_ABILITIES,
16
+ "action-command-timeout"
17
+ ];
18
+ function battleData(o) {
19
+ return [
20
+ o.swapCost ?? 1,
21
+ o.actionPoints ?? 3,
22
+ o.passiveBudget ?? 6,
23
+ o.captureItems ?? 3,
24
+ o.escapeCost ?? 1,
25
+ o.escapeBaseChance ?? 0.25,
26
+ o.escapeRetryBonus ?? 0.2,
27
+ 0,
28
+ 0,
29
+ 0,
30
+ 0,
31
+ 0,
32
+ 0,
33
+ 0,
34
+ 0,
35
+ 0
36
+ ];
37
+ }
38
+ function battleOperation(a) {
39
+ switch (a.type) {
40
+ case "queue-action":
41
+ return {
42
+ op: 0,
43
+ data: [a.row, a.actionId, a.priority, a.speed, a.tieKey]
44
+ };
45
+ case "freeze-order":
46
+ return { op: 1, data: [a.turn] };
47
+ case "next-action":
48
+ return { op: 2, data: [] };
49
+ case "clear-order":
50
+ return { op: 3, data: [] };
51
+ case "type-row":
52
+ return { op: 4, data: [a.attackType, a.defenderType, a.multiplier] };
53
+ case "resolve-type":
54
+ return {
55
+ op: 5,
56
+ data: [
57
+ a.attackType,
58
+ a.defenderType,
59
+ a.secondType ?? 4,
60
+ a.raw,
61
+ a.damageSerial
62
+ ]
63
+ };
64
+ case "status-apply":
65
+ return {
66
+ op: 8,
67
+ data: [a.id, a.turns, a.phaseMask, Number(a.restrict), a.amount]
68
+ };
69
+ case "status-phase":
70
+ return { op: 9, data: [a.turn, a.phase] };
71
+ case "status-remove":
72
+ return { op: 10, data: [a.id] };
73
+ case "capture":
74
+ return {
75
+ op: 12,
76
+ data: [
77
+ a.attemptSerial,
78
+ a.seed,
79
+ a.health,
80
+ a.maximumHealth,
81
+ a.catchRate,
82
+ a.itemBonus,
83
+ a.statusBonus,
84
+ Number(a.eligible),
85
+ a.itemId
86
+ ]
87
+ };
88
+ case "capture-stock":
89
+ return { op: 13, data: [a.count] };
90
+ case "creature":
91
+ return {
92
+ op: 16,
93
+ data: [a.species, a.level, a.friendship, ...a.stats, ...a.moves]
94
+ };
95
+ case "evolution-rule":
96
+ return {
97
+ op: 17,
98
+ data: [
99
+ a.row,
100
+ a.from,
101
+ a.to,
102
+ a.level,
103
+ a.item,
104
+ a.friendship,
105
+ a.context,
106
+ ...a.stats,
107
+ a.keepMovesMask
108
+ ]
109
+ };
110
+ case "evolve":
111
+ return { op: 18, data: [a.evolutionSerial, a.item, a.context] };
112
+ case "creature-progress":
113
+ return { op: 19, data: [a.level, a.friendship] };
114
+ case "timing-start":
115
+ return {
116
+ op: 20,
117
+ data: [
118
+ a.moveSerial,
119
+ a.count,
120
+ a.window,
121
+ a.bonus,
122
+ ...a.times,
123
+ ...a.buttons
124
+ ]
125
+ };
126
+ case "timing-input":
127
+ return { op: 21, data: [a.button, a.timestamp] };
128
+ case "timing-finish":
129
+ return { op: 22, data: [] };
130
+ case "partner-register":
131
+ return { op: 24, data: [a.row, a.health, a.maximumHealth] };
132
+ case "partner-swap":
133
+ return { op: 25, data: [a.row] };
134
+ case "partner-health":
135
+ return { op: 26, data: [a.row, a.health] };
136
+ case "partner-turn":
137
+ return { op: 27, data: [a.turn, a.points] };
138
+ case "passive-row":
139
+ return {
140
+ op: 28,
141
+ data: [
142
+ a.row,
143
+ a.id,
144
+ a.cost,
145
+ a.group,
146
+ a.stat,
147
+ a.amount,
148
+ a.maximumStacks
149
+ ]
150
+ };
151
+ case "passive-equip":
152
+ return { op: 29, data: [...a.counts] };
153
+ case "passive-budget":
154
+ return { op: 30, data: [a.budget] };
155
+ case "passive-clear":
156
+ return { op: 31, data: [] };
157
+ case "field-contact":
158
+ return { op: 32, data: [a.side, a.attackId] };
159
+ case "opening-transfer":
160
+ return { op: 33, data: [a.encounterSerial] };
161
+ case "escape":
162
+ return {
163
+ op: 36,
164
+ data: [a.seed, a.speed, a.enemySpeed, Number(a.eligible)]
165
+ };
166
+ case "escape-turn":
167
+ return { op: 37, data: [a.turn, a.points] };
168
+ case "battle-end":
169
+ return { op: 39, data: [a.outcome] };
170
+ }
171
+ }
172
+
173
+ export {
174
+ BATTLE_ABILITIES,
175
+ BATTLE_EVENTS,
176
+ battleData,
177
+ battleOperation
178
+ };
@@ -0,0 +1,107 @@
1
+ // src/lib/behaviors/rhythm-performance/types.ts
2
+ var RHYTHM_ABILITIES = [
3
+ "timestamped-rhythm-judgment",
4
+ "hold-release-rhythm",
5
+ "call-and-response-pattern",
6
+ "tempo-map-chart-player",
7
+ "fret-chord-strum",
8
+ "hammer-on-pull-off-chain",
9
+ "sustain-note-tracking",
10
+ "phrase-earned-score-power",
11
+ "rhythm-scene-remix",
12
+ "performance-failure-meter"
13
+ ];
14
+ var RHYTHM_EVENTS = [
15
+ ...RHYTHM_ABILITIES,
16
+ "chart-or-clock",
17
+ "note-result",
18
+ "failed",
19
+ "scene-changed",
20
+ "cue"
21
+ ];
22
+ function rhythmData(o) {
23
+ return [
24
+ o.perfectMs ?? 30,
25
+ o.goodMs ?? 80,
26
+ o.lateMs ?? 120,
27
+ o.latencyMs ?? 0,
28
+ 0,
29
+ 0,
30
+ 0,
31
+ 0,
32
+ 0,
33
+ 0,
34
+ 0,
35
+ 0,
36
+ 0,
37
+ 0,
38
+ 0,
39
+ 0
40
+ ];
41
+ }
42
+ function rhythmOperation(a) {
43
+ switch (a.type) {
44
+ case "hit":
45
+ return { op: 0, data: [a.note, a.timestamp, a.lanes, a.scene] };
46
+ case "hold-press":
47
+ return { op: 4, data: [a.note, a.timestamp, a.lanes, a.scene] };
48
+ case "hold-release":
49
+ return { op: 5, data: [a.note, a.timestamp, a.lanes, a.scene] };
50
+ case "call":
51
+ return { op: 8, data: [a.start, a.response, a.duration] };
52
+ case "cue":
53
+ return { op: 9, data: [a.offset, a.lanes] };
54
+ case "response":
55
+ return { op: 10, data: [a.note, a.timestamp, a.lanes, a.scene] };
56
+ case "tempo":
57
+ return { op: 12, data: [a.beat, a.bpm] };
58
+ case "beat-note":
59
+ return { op: 13, data: [a.beat, a.lanes, a.scene] };
60
+ case "chart-hit":
61
+ return { op: 14, data: [a.note, a.timestamp, a.lanes, a.scene] };
62
+ case "seek":
63
+ return { op: 15, data: [a.timestamp] };
64
+ case "strum":
65
+ return { op: 16, data: [a.note, a.timestamp, a.lanes, a.scene] };
66
+ case "chain-strum":
67
+ return { op: 20, data: [a.note, a.timestamp, a.lanes, a.scene] };
68
+ case "fret-edge":
69
+ return { op: 21, data: [a.note, a.timestamp, a.lanes, a.scene] };
70
+ case "sustain-press":
71
+ return { op: 24, data: [a.note, a.timestamp, a.lanes, a.scene] };
72
+ case "sustain-release":
73
+ return { op: 25, data: [a.note, a.timestamp, a.lanes, a.scene] };
74
+ case "phrase":
75
+ return { op: 28, data: [a.first, a.last, a.reward] };
76
+ case "activate-power":
77
+ return { op: 29, data: [a.timestamp] };
78
+ case "power-hit":
79
+ return { op: 30, data: [a.note, a.timestamp, a.lanes, a.scene] };
80
+ case "transition":
81
+ return { op: 32, data: [a.timestamp, a.scene] };
82
+ case "remix-hit":
83
+ return { op: 33, data: [a.note, a.timestamp, a.lanes, a.scene] };
84
+ case "performance":
85
+ return { op: 36, data: [a.initial, a.hitGain, a.missLoss, a.threshold] };
86
+ case "performance-hit":
87
+ return { op: 37, data: [a.note, a.timestamp, a.lanes, a.scene] };
88
+ case "note":
89
+ return {
90
+ op: 40,
91
+ data: [a.kind, a.timestamp, a.end, a.lanes, a.scene, a.eligible]
92
+ };
93
+ case "start":
94
+ return { op: 41, data: [] };
95
+ case "clock":
96
+ return { op: 42, data: [a.timestamp] };
97
+ case "pause":
98
+ return { op: 43, data: [a.paused] };
99
+ }
100
+ }
101
+
102
+ export {
103
+ RHYTHM_ABILITIES,
104
+ RHYTHM_EVENTS,
105
+ rhythmData,
106
+ rhythmOperation
107
+ };
@@ -0,0 +1,132 @@
1
+ import {
2
+ COMBAT_ABILITIES
3
+ } from "./chunk-V4M46BF6.js";
4
+ import {
5
+ defineBehavior
6
+ } from "./chunk-5SMXQ6AU.js";
7
+ import {
8
+ BUILTIN_BEHAVIORS
9
+ } from "./chunk-S44ZHYE6.js";
10
+
11
+ // src/lib/behaviors/melee-combat/index.ts
12
+ var CombatSystem = class {
13
+ constructor(key, abilities, runtime, links) {
14
+ this.key = key;
15
+ this.abilities = abilities;
16
+ this.runtime = runtime;
17
+ this.links = links;
18
+ }
19
+ key;
20
+ abilities;
21
+ runtime;
22
+ links;
23
+ attached = /* @__PURE__ */ new Map();
24
+ update() {
25
+ if (!this.runtime) return;
26
+ const links = [...this.links?.(this.key) ?? []];
27
+ for (const [entity, { slot, ref }] of this.attached) {
28
+ if (!links.some(
29
+ (link) => link.entity === entity && link.ref === ref
30
+ ) || entity.runtimeHandle !== slot)
31
+ this.detach({ entity, ref });
32
+ }
33
+ for (const link of links) {
34
+ const entity = link.entity;
35
+ entity.$combat ??= {};
36
+ entity.combatState ??= null;
37
+ const slot = entity.runtimeHandle;
38
+ if (!Number.isInteger(slot) || slot < 0) continue;
39
+ if (!this.attached.has(entity)) {
40
+ if (!this.runtime.attachCombat(
41
+ slot,
42
+ this.abilities,
43
+ link.ref.options
44
+ )) {
45
+ throw new Error(
46
+ "Combat requires exclusive motion ownership, a dynamic solid body with gravityScale=0, and compatible rotation locks."
47
+ );
48
+ }
49
+ this.attached.set(entity, { slot, ref: link.ref });
50
+ }
51
+ this.runtime.combatInput(slot, entity.$combat);
52
+ }
53
+ }
54
+ postUpdate() {
55
+ for (const [entity, { slot }] of this.attached)
56
+ entity.combatState = this.runtime?.queryCombat(slot) ?? null;
57
+ }
58
+ detach(link) {
59
+ const slot = this.attached.get(link.entity)?.slot;
60
+ if (slot !== void 0 && this.runtime && !this.runtime.detachCombat(slot) && this.runtime.queryCombat(slot))
61
+ throw new Error("Failed to release combat ownership.");
62
+ this.attached.delete(link.entity);
63
+ link.entity.combatState = null;
64
+ }
65
+ destroy() {
66
+ for (const [entity, { ref }] of this.attached)
67
+ this.detach({ entity, ref });
68
+ }
69
+ };
70
+ function descriptor(name, abilities) {
71
+ return defineBehavior({
72
+ name,
73
+ metadata: BUILTIN_BEHAVIORS[name],
74
+ defaultOptions: {
75
+ gravity: 18,
76
+ speed: 5
77
+ },
78
+ systemFactory: (ctx) => new CombatSystem(
79
+ /* @__PURE__ */ Symbol.for(`zylem:behavior:${name}`),
80
+ abilities,
81
+ ctx.wasmStage ?? null,
82
+ ctx.getBehaviorLinks
83
+ )
84
+ });
85
+ }
86
+ var MeleeCombatBehavior = descriptor("melee-combat", COMBAT_ABILITIES);
87
+ var AttackPhaseHitboxesBehavior = descriptor("attack-phase-hitboxes", [
88
+ "attack-phase-hitboxes"
89
+ ]);
90
+ var DamageScaledKnockbackBehavior = descriptor(
91
+ "damage-scaled-knockback",
92
+ ["damage-scaled-knockback"]
93
+ );
94
+ var CombatHitstopBehavior = descriptor("combat-hitstop", [
95
+ "combat-hitstop"
96
+ ]);
97
+ var DepletingShieldBehavior = descriptor("depleting-shield", [
98
+ "depleting-shield"
99
+ ]);
100
+ var TimedPerfectGuardBehavior = descriptor("timed-perfect-guard", [
101
+ "timed-perfect-guard"
102
+ ]);
103
+ var GrabHoldThrowBehavior = descriptor("grab-hold-throw", [
104
+ "grab-hold-throw"
105
+ ]);
106
+ var AirDodgeRecoveryBehavior = descriptor("air-dodge-recovery", [
107
+ "air-dodge-recovery"
108
+ ]);
109
+ var DirectionalInfluenceBehavior = descriptor(
110
+ "directional-influence",
111
+ ["directional-influence"]
112
+ );
113
+ var ImpactTechWindowBehavior = descriptor("impact-tech-window", [
114
+ "impact-tech-window"
115
+ ]);
116
+ var GroundedAttackChainBehavior = descriptor("grounded-attack-chain", [
117
+ "grounded-attack-chain"
118
+ ]);
119
+
120
+ export {
121
+ MeleeCombatBehavior,
122
+ AttackPhaseHitboxesBehavior,
123
+ DamageScaledKnockbackBehavior,
124
+ CombatHitstopBehavior,
125
+ DepletingShieldBehavior,
126
+ TimedPerfectGuardBehavior,
127
+ GrabHoldThrowBehavior,
128
+ AirDodgeRecoveryBehavior,
129
+ DirectionalInfluenceBehavior,
130
+ ImpactTechWindowBehavior,
131
+ GroundedAttackChainBehavior
132
+ };
@@ -0,0 +1,135 @@
1
+ import {
2
+ ENCOUNTER_ABILITIES
3
+ } from "./chunk-73MHJY6R.js";
4
+ import {
5
+ defineBehavior
6
+ } from "./chunk-5SMXQ6AU.js";
7
+ import {
8
+ BUILTIN_BEHAVIORS
9
+ } from "./chunk-S44ZHYE6.js";
10
+
11
+ // src/lib/behaviors/combat-ai/index.ts
12
+ var EncounterSystem = class {
13
+ constructor(key, abilities, runtime, links) {
14
+ this.key = key;
15
+ this.abilities = abilities;
16
+ this.runtime = runtime;
17
+ this.links = links;
18
+ }
19
+ key;
20
+ abilities;
21
+ runtime;
22
+ links;
23
+ attached = /* @__PURE__ */ new Map();
24
+ update() {
25
+ if (!this.runtime) return;
26
+ const links = [...this.links?.(this.key) ?? []];
27
+ for (const [entity, { slot, ref }] of this.attached) {
28
+ if (!links.some(
29
+ (link) => link.entity === entity && link.ref === ref
30
+ ) || entity.runtimeHandle !== slot)
31
+ this.detach({ entity, ref });
32
+ }
33
+ for (const link of links) {
34
+ const entity = link.entity;
35
+ entity.encounterState ??= null;
36
+ const slot = entity.runtimeHandle;
37
+ if (!Number.isInteger(slot) || slot < 0) continue;
38
+ if (!this.attached.has(entity)) {
39
+ if (!this.runtime.attachEncounters(
40
+ slot,
41
+ this.abilities,
42
+ link.ref.options
43
+ )) {
44
+ throw new Error(
45
+ "Encounter attachment requires valid options and an available AI component slot."
46
+ );
47
+ }
48
+ this.attached.set(entity, { slot, ref: link.ref });
49
+ }
50
+ }
51
+ }
52
+ postUpdate() {
53
+ for (const [entity, { slot }] of this.attached)
54
+ entity.encounterState = this.runtime?.queryEncounters(slot) ?? null;
55
+ }
56
+ detach(link) {
57
+ const slot = this.attached.get(link.entity)?.slot;
58
+ if (slot !== void 0 && this.runtime && !this.runtime.detachEncounters(slot) && this.runtime.queryEncounters(slot))
59
+ throw new Error("Failed to detach encounter policy.");
60
+ this.attached.delete(link.entity);
61
+ link.entity.encounterState = null;
62
+ }
63
+ destroy() {
64
+ for (const [entity, { ref }] of this.attached)
65
+ this.detach({ entity, ref });
66
+ }
67
+ };
68
+ function descriptor(name, abilities) {
69
+ return defineBehavior({
70
+ name,
71
+ metadata: BUILTIN_BEHAVIORS[name],
72
+ defaultOptions: {
73
+ health: 100,
74
+ team: 1
75
+ },
76
+ systemFactory: (ctx) => new EncounterSystem(
77
+ /* @__PURE__ */ Symbol.for(`zylem:behavior:${name}`),
78
+ abilities,
79
+ ctx.wasmStage ?? null,
80
+ ctx.getBehaviorLinks
81
+ )
82
+ });
83
+ }
84
+ var CombatAIBehavior = descriptor("combat-ai", ENCOUNTER_ABILITIES);
85
+ var SquadFlankAssignmentBehavior = descriptor(
86
+ "squad-flank-assignment",
87
+ ["squad-flank-assignment"]
88
+ );
89
+ var LeaderLossMoraleBehavior = descriptor("leader-loss-morale", [
90
+ "leader-loss-morale"
91
+ ]);
92
+ var GrenadeDangerEvasionBehavior = descriptor(
93
+ "grenade-danger-evasion",
94
+ ["grenade-danger-evasion"]
95
+ );
96
+ var CoverPeekCycleBehavior = descriptor("cover-peek-cycle", [
97
+ "cover-peek-cycle"
98
+ ]);
99
+ var ThreatTargetSelectionBehavior = descriptor(
100
+ "threat-target-selection",
101
+ ["threat-target-selection"]
102
+ );
103
+ var TacticalBurstSelectionBehavior = descriptor(
104
+ "tactical-burst-selection",
105
+ ["tactical-burst-selection"]
106
+ );
107
+ var LatentAmbushActivationBehavior = descriptor(
108
+ "latent-ambush-activation",
109
+ ["latent-ambush-activation"]
110
+ );
111
+ var BossPhaseControllerBehavior = descriptor("boss-phase-controller", [
112
+ "boss-phase-controller"
113
+ ]);
114
+ var LocalizedWeakPointDamageBehavior = descriptor(
115
+ "localized-weak-point-damage",
116
+ ["localized-weak-point-damage"]
117
+ );
118
+ var ShootableProjectileInterceptionBehavior = descriptor(
119
+ "shootable-projectile-interception",
120
+ ["shootable-projectile-interception"]
121
+ );
122
+
123
+ export {
124
+ CombatAIBehavior,
125
+ SquadFlankAssignmentBehavior,
126
+ LeaderLossMoraleBehavior,
127
+ GrenadeDangerEvasionBehavior,
128
+ CoverPeekCycleBehavior,
129
+ ThreatTargetSelectionBehavior,
130
+ TacticalBurstSelectionBehavior,
131
+ LatentAmbushActivationBehavior,
132
+ BossPhaseControllerBehavior,
133
+ LocalizedWeakPointDamageBehavior,
134
+ ShootableProjectileInterceptionBehavior
135
+ };
@@ -1,16 +1,19 @@
1
- import {
2
- SyncStateMachine,
3
- import_typescript_fsm
4
- } from "./chunk-OBF6BIA2.js";
5
1
  import {
6
2
  STAGE_INPUT_BUTTON_JUMP,
7
3
  STAGE_INPUT_BUTTON_RUN,
8
4
  StagePlatformerShapeSource,
9
5
  readBehaviorSnapshot
10
- } from "./chunk-GZ3DQIIZ.js";
6
+ } from "./chunk-BR33KT4Z.js";
7
+ import {
8
+ SyncStateMachine,
9
+ import_typescript_fsm
10
+ } from "./chunk-CBQSC6W3.js";
11
11
  import {
12
12
  defineBehavior
13
- } from "./chunk-YDLO5M7S.js";
13
+ } from "./chunk-5SMXQ6AU.js";
14
+ import {
15
+ BUILTIN_BEHAVIORS
16
+ } from "./chunk-S44ZHYE6.js";
14
17
 
15
18
  // src/lib/behaviors/platformer-2d/components.ts
16
19
  function createPlatformer2DMovementComponent(options = {}) {
@@ -145,7 +148,8 @@ var Platformer2DFSM = class {
145
148
  const currentState = this.getState();
146
149
  const hasInput = Math.abs(input.moveX) > 0.1;
147
150
  const isRunning = input.run;
148
- if (currentState === "falling" /* Falling */ && state.grounded) {
151
+ const airborne = currentState === "falling" /* Falling */ || currentState === "jumping" /* Jumping */;
152
+ if (airborne && state.grounded) {
149
153
  this.dispatch("land" /* Land */);
150
154
  }
151
155
  if (state.grounded) {
@@ -176,6 +180,15 @@ var FSM_STATE_BY_INDEX = [
176
180
  "falling" /* Falling */,
177
181
  "landing" /* Landing */
178
182
  ];
183
+ function syncStateFromSnapshot(state, snapshot) {
184
+ const fsmState = FSM_STATE_BY_INDEX[snapshot.fsmState];
185
+ state.grounded = snapshot.grounded;
186
+ state.jumping = fsmState === "jumping" /* Jumping */;
187
+ state.falling = fsmState === "falling" /* Falling */;
188
+ state.jumpCount = snapshot.jumpCount;
189
+ state.currentSpeed = snapshot.speed;
190
+ state.verticalVelocity = snapshot.verticalVelocity;
191
+ }
179
192
  var defaultOptions = {
180
193
  walkSpeed: 8,
181
194
  runSpeed: 14,
@@ -234,6 +247,15 @@ var Platformer2DBehaviorSystem = class {
234
247
  wasmStage;
235
248
  getBehaviorLinks;
236
249
  attachedRuntimeSlots = /* @__PURE__ */ new Set();
250
+ snapshot = {
251
+ grounded: false,
252
+ fsmState: 0,
253
+ jumpCount: 0,
254
+ verticalVelocity: 0,
255
+ speed: 0,
256
+ yaw: 0,
257
+ pitch: 0
258
+ };
237
259
  update(_ecs, _delta) {
238
260
  const links = this.getBehaviorLinks?.(PLATFORMER_2D_BEHAVIOR_KEY);
239
261
  if (!links) return;
@@ -261,6 +283,8 @@ var Platformer2DBehaviorSystem = class {
261
283
  this.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_JUMP, !!input.jump);
262
284
  this.wasmStage.writeInputButton(handle, STAGE_INPUT_BUTTON_RUN, !!input.run);
263
285
  }
286
+ const snapshot = this.wasmStage.readSnapshot(handle, this.snapshot);
287
+ if (snapshot) syncStateFromSnapshot(gameEntity.platformer2DState, snapshot);
264
288
  }
265
289
  }
266
290
  ensureWasmAttached(handle, options, gameEntity) {
@@ -292,6 +316,7 @@ var Platformer2DBehaviorSystem = class {
292
316
  };
293
317
  var Platformer2DBehavior = defineBehavior({
294
318
  name: "platformer-2d",
319
+ metadata: BUILTIN_BEHAVIORS["platformer-2d"],
295
320
  defaultOptions,
296
321
  systemFactory: (ctx) => new Platformer2DBehaviorSystem(
297
322
  ctx.wasmStage ?? null,