@holoscript/engine 6.0.3 → 6.0.4

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 (192) hide show
  1. package/dist/AutoMesher-CK47F6AV.js +17 -0
  2. package/dist/GPUBuffers-2LHBCD7X.js +9 -0
  3. package/dist/WebGPUContext-TNEUYU2Y.js +11 -0
  4. package/dist/animation/index.cjs +38 -38
  5. package/dist/animation/index.d.cts +1 -1
  6. package/dist/animation/index.d.ts +1 -1
  7. package/dist/animation/index.js +1 -1
  8. package/dist/audio/index.cjs +16 -6
  9. package/dist/audio/index.d.cts +1 -1
  10. package/dist/audio/index.d.ts +1 -1
  11. package/dist/audio/index.js +1 -1
  12. package/dist/camera/index.cjs +23 -23
  13. package/dist/camera/index.d.cts +1 -1
  14. package/dist/camera/index.d.ts +1 -1
  15. package/dist/camera/index.js +1 -1
  16. package/dist/character/index.cjs +6 -4
  17. package/dist/character/index.js +1 -1
  18. package/dist/choreography/index.cjs +1194 -0
  19. package/dist/choreography/index.d.cts +687 -0
  20. package/dist/choreography/index.d.ts +687 -0
  21. package/dist/choreography/index.js +1156 -0
  22. package/dist/chunk-2CSNRI2N.js +217 -0
  23. package/dist/chunk-33T2WINR.js +266 -0
  24. package/dist/chunk-35R73OFM.js +1257 -0
  25. package/dist/chunk-4MMDSUNP.js +1256 -0
  26. package/dist/chunk-5V6HOU72.js +319 -0
  27. package/dist/chunk-6QOP6PYF.js +1038 -0
  28. package/dist/chunk-7KMJVHIL.js +8944 -0
  29. package/dist/chunk-7VPUC62U.js +1106 -0
  30. package/dist/chunk-A2Y6RCAT.js +1878 -0
  31. package/dist/chunk-AHM42MK6.js +8944 -0
  32. package/dist/chunk-BL7IDTHE.js +218 -0
  33. package/dist/chunk-CITOMSWL.js +10462 -0
  34. package/dist/chunk-CXDPKW2K.js +8944 -0
  35. package/dist/chunk-CXZPLD4S.js +223 -0
  36. package/dist/chunk-CZYJE7IH.js +5169 -0
  37. package/dist/chunk-D2OP7YC7.js +6325 -0
  38. package/dist/chunk-EDRVQHUU.js +1544 -0
  39. package/dist/chunk-EJSLOOW2.js +3589 -0
  40. package/dist/chunk-F53SFGW5.js +1878 -0
  41. package/dist/chunk-HCFPELPY.js +919 -0
  42. package/dist/chunk-HNEE36PY.js +93 -0
  43. package/dist/chunk-HYXNV36F.js +1256 -0
  44. package/dist/chunk-IB7KHVFY.js +821 -0
  45. package/dist/chunk-IBBO7YYG.js +690 -0
  46. package/dist/chunk-ILIBGINU.js +5470 -0
  47. package/dist/chunk-IS4MHLKN.js +5479 -0
  48. package/dist/chunk-JT2PFKWD.js +5479 -0
  49. package/dist/chunk-K4CUB4NY.js +1038 -0
  50. package/dist/chunk-KATDQXRJ.js +10462 -0
  51. package/dist/chunk-KBQE6ZFJ.js +8944 -0
  52. package/dist/chunk-KBVD5K7E.js +560 -0
  53. package/dist/chunk-KCDPVQRY.js +4088 -0
  54. package/dist/chunk-KN4QJPKN.js +8944 -0
  55. package/dist/chunk-KWJ3ROSI.js +8944 -0
  56. package/dist/chunk-L45VF6DD.js +919 -0
  57. package/dist/chunk-LY4T37YK.js +307 -0
  58. package/dist/chunk-MDN5WZXA.js +1544 -0
  59. package/dist/chunk-MGCDP6VU.js +928 -0
  60. package/dist/chunk-NCX7X6G2.js +8681 -0
  61. package/dist/chunk-OF54BPVD.js +913 -0
  62. package/dist/chunk-OWSN2Q3Q.js +690 -0
  63. package/dist/chunk-PRRB5TTA.js +406 -0
  64. package/dist/chunk-PXWVQF76.js +4086 -0
  65. package/dist/chunk-PYCOIDT2.js +812 -0
  66. package/dist/chunk-PZCSADOV.js +928 -0
  67. package/dist/chunk-Q2XBVS2K.js +1038 -0
  68. package/dist/chunk-QDZRXWN5.js +1776 -0
  69. package/dist/chunk-RNWOZ6WQ.js +913 -0
  70. package/dist/chunk-ROLFT4CJ.js +1693 -0
  71. package/dist/chunk-SLTJRZ2N.js +266 -0
  72. package/dist/chunk-SRUS5XSU.js +4088 -0
  73. package/dist/chunk-TKCA3WZ5.js +5409 -0
  74. package/dist/chunk-TNRMXYI2.js +1650 -0
  75. package/dist/chunk-TQB3GJGM.js +9763 -0
  76. package/dist/chunk-TUFGXG6K.js +510 -0
  77. package/dist/chunk-U6KMTGQJ.js +632 -0
  78. package/dist/chunk-VMGJQST6.js +8681 -0
  79. package/dist/chunk-X4F4TCG4.js +5470 -0
  80. package/dist/chunk-ZIFROE75.js +1544 -0
  81. package/dist/chunk-ZIJQYHSQ.js +1204 -0
  82. package/dist/combat/index.cjs +4 -4
  83. package/dist/combat/index.d.cts +1 -1
  84. package/dist/combat/index.d.ts +1 -1
  85. package/dist/combat/index.js +1 -1
  86. package/dist/ecs/index.cjs +1 -1
  87. package/dist/ecs/index.js +1 -1
  88. package/dist/environment/index.cjs +14 -14
  89. package/dist/environment/index.d.cts +1 -1
  90. package/dist/environment/index.d.ts +1 -1
  91. package/dist/environment/index.js +1 -1
  92. package/dist/gpu/index.cjs +4810 -0
  93. package/dist/gpu/index.js +3714 -0
  94. package/dist/hologram/index.cjs +27 -1
  95. package/dist/hologram/index.js +1 -1
  96. package/dist/index-B2PIsAmR.d.cts +2180 -0
  97. package/dist/index-B2PIsAmR.d.ts +2180 -0
  98. package/dist/index-BHySEPX7.d.cts +2921 -0
  99. package/dist/index-BJV21zuy.d.cts +341 -0
  100. package/dist/index-BJV21zuy.d.ts +341 -0
  101. package/dist/index-BQutTphC.d.cts +790 -0
  102. package/dist/index-ByIq2XrS.d.cts +3910 -0
  103. package/dist/index-BysHjDSO.d.cts +224 -0
  104. package/dist/index-BysHjDSO.d.ts +224 -0
  105. package/dist/index-CKwAJGck.d.ts +455 -0
  106. package/dist/index-CUl3QstQ.d.cts +3006 -0
  107. package/dist/index-CUl3QstQ.d.ts +3006 -0
  108. package/dist/index-CmYtNiI-.d.cts +953 -0
  109. package/dist/index-CmYtNiI-.d.ts +953 -0
  110. package/dist/index-CnRzWxi_.d.cts +522 -0
  111. package/dist/index-CnRzWxi_.d.ts +522 -0
  112. package/dist/index-CwRWbSC7.d.ts +2921 -0
  113. package/dist/index-CxKIBstO.d.ts +790 -0
  114. package/dist/index-DJ6-R8vh.d.cts +455 -0
  115. package/dist/index-DQKisbcI.d.cts +4968 -0
  116. package/dist/index-DQKisbcI.d.ts +4968 -0
  117. package/dist/index-DRT2zJez.d.ts +3910 -0
  118. package/dist/index-DfNLiAka.d.cts +192 -0
  119. package/dist/index-DfNLiAka.d.ts +192 -0
  120. package/dist/index-nMvkoRm8.d.cts +405 -0
  121. package/dist/index-nMvkoRm8.d.ts +405 -0
  122. package/dist/index-s9yOFU37.d.cts +604 -0
  123. package/dist/index-s9yOFU37.d.ts +604 -0
  124. package/dist/index.cjs +22966 -6960
  125. package/dist/index.d.cts +864 -20
  126. package/dist/index.d.ts +864 -20
  127. package/dist/index.js +3062 -48
  128. package/dist/input/index.cjs +1 -1
  129. package/dist/input/index.js +1 -1
  130. package/dist/orbital/index.cjs +3 -3
  131. package/dist/orbital/index.d.cts +1 -1
  132. package/dist/orbital/index.d.ts +1 -1
  133. package/dist/orbital/index.js +1 -1
  134. package/dist/particles/index.cjs +16 -16
  135. package/dist/particles/index.d.cts +1 -1
  136. package/dist/particles/index.d.ts +1 -1
  137. package/dist/particles/index.js +1 -1
  138. package/dist/physics/index.cjs +2377 -21
  139. package/dist/physics/index.d.cts +1 -1
  140. package/dist/physics/index.d.ts +1 -1
  141. package/dist/physics/index.js +35 -1
  142. package/dist/postfx/index.cjs +3491 -0
  143. package/dist/postfx/index.js +93 -0
  144. package/dist/procedural/index.cjs +1 -1
  145. package/dist/procedural/index.js +1 -1
  146. package/dist/puppeteer-5VF6KDVO.js +52197 -0
  147. package/dist/puppeteer-IZVZ3SG4.js +52197 -0
  148. package/dist/rendering/index.cjs +33 -32
  149. package/dist/rendering/index.d.cts +1 -1
  150. package/dist/rendering/index.d.ts +1 -1
  151. package/dist/rendering/index.js +8 -6
  152. package/dist/runtime/index.cjs +23 -13
  153. package/dist/runtime/index.d.cts +1 -1
  154. package/dist/runtime/index.d.ts +1 -1
  155. package/dist/runtime/index.js +8 -6
  156. package/dist/runtime/protocols/index.cjs +349 -0
  157. package/dist/runtime/protocols/index.js +15 -0
  158. package/dist/scene/index.cjs +8 -8
  159. package/dist/scene/index.d.cts +1 -1
  160. package/dist/scene/index.d.ts +1 -1
  161. package/dist/scene/index.js +1 -1
  162. package/dist/shader/index.cjs +3087 -0
  163. package/dist/shader/index.js +3044 -0
  164. package/dist/simulation/index.cjs +10680 -0
  165. package/dist/simulation/index.d.cts +3 -0
  166. package/dist/simulation/index.d.ts +3 -0
  167. package/dist/simulation/index.js +307 -0
  168. package/dist/spatial/index.cjs +2443 -0
  169. package/dist/spatial/index.d.cts +1545 -0
  170. package/dist/spatial/index.d.ts +1545 -0
  171. package/dist/spatial/index.js +2400 -0
  172. package/dist/terrain/index.cjs +1 -1
  173. package/dist/terrain/index.d.cts +1 -1
  174. package/dist/terrain/index.d.ts +1 -1
  175. package/dist/terrain/index.js +1 -1
  176. package/dist/transformers.node-4NKAPD5U.js +45620 -0
  177. package/dist/vm/index.cjs +7 -8
  178. package/dist/vm/index.d.cts +1 -1
  179. package/dist/vm/index.d.ts +1 -1
  180. package/dist/vm/index.js +1 -1
  181. package/dist/vm-bridge/index.cjs +2 -2
  182. package/dist/vm-bridge/index.d.cts +2 -2
  183. package/dist/vm-bridge/index.d.ts +2 -2
  184. package/dist/vm-bridge/index.js +1 -1
  185. package/dist/vr/index.cjs +6 -6
  186. package/dist/vr/index.js +1 -1
  187. package/dist/world/index.cjs +3 -3
  188. package/dist/world/index.d.cts +1 -1
  189. package/dist/world/index.d.ts +1 -1
  190. package/dist/world/index.js +1 -1
  191. package/package.json +53 -21
  192. package/LICENSE +0 -21
@@ -0,0 +1,690 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-AKLW2MUS.js";
4
+
5
+ // src/combat/index.ts
6
+ var combat_exports = {};
7
+ __export(combat_exports, {
8
+ CombatManager: () => CombatManager,
9
+ ComboTracker: () => ComboTracker,
10
+ DamageSystem: () => DamageSystem,
11
+ HitboxSystem: () => HitboxSystem,
12
+ ProjectileSystem: () => ProjectileSystem,
13
+ StatusEffectSystem: () => StatusEffectSystem
14
+ });
15
+
16
+ // src/combat/CombatManager.ts
17
+ var CombatManager = class {
18
+ hitboxes = /* @__PURE__ */ new Map();
19
+ hurtboxes = /* @__PURE__ */ new Map();
20
+ combos = /* @__PURE__ */ new Map();
21
+ cooldowns = /* @__PURE__ */ new Map();
22
+ hitLog = [];
23
+ // ---------------------------------------------------------------------------
24
+ // Hitbox / Hurtbox
25
+ // ---------------------------------------------------------------------------
26
+ addHitBox(hitbox) {
27
+ this.hitboxes.set(hitbox.id, hitbox);
28
+ }
29
+ addHurtBox(hurtbox) {
30
+ this.hurtboxes.set(hurtbox.id, hurtbox);
31
+ }
32
+ removeHitBox(id) {
33
+ this.hitboxes.delete(id);
34
+ }
35
+ removeHurtBox(id) {
36
+ this.hurtboxes.delete(id);
37
+ }
38
+ setHitBoxActive(id, active) {
39
+ const hb = this.hitboxes.get(id);
40
+ if (hb) hb.active = active;
41
+ }
42
+ checkCollisions() {
43
+ const hits = [];
44
+ for (const hb of this.hitboxes.values()) {
45
+ if (!hb.active) continue;
46
+ for (const hr of this.hurtboxes.values()) {
47
+ if (!hr.active) continue;
48
+ if (hb.ownerId === hr.ownerId) continue;
49
+ if (this.aabbOverlap(hb.position, hb.size, hr.position, hr.size)) {
50
+ hits.push({ hitbox: hb, hurtbox: hr });
51
+ this.hitLog.push({ hitboxId: hb.id, hurtboxId: hr.id, time: Date.now() });
52
+ }
53
+ }
54
+ }
55
+ return hits;
56
+ }
57
+ aabbOverlap(posA, sizeA, posB, sizeB) {
58
+ return Math.abs(posA.x - posB.x) < (sizeA.x + sizeB.x) / 2 && Math.abs(posA.y - posB.y) < (sizeA.y + sizeB.y) / 2 && Math.abs(posA.z - posB.z) < (sizeA.z + sizeB.z) / 2;
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Combo System
62
+ // ---------------------------------------------------------------------------
63
+ registerCombo(id, steps) {
64
+ const chain = { id, steps, currentStep: 0, timer: 0, completed: false };
65
+ this.combos.set(id, chain);
66
+ return chain;
67
+ }
68
+ advanceCombo(comboId, input) {
69
+ const combo = this.combos.get(comboId);
70
+ if (!combo || combo.completed) return { hit: false, completed: false, step: -1 };
71
+ const step = combo.steps[combo.currentStep];
72
+ if (step.input === input) {
73
+ combo.currentStep++;
74
+ combo.timer = 0;
75
+ const completed = combo.currentStep >= combo.steps.length;
76
+ if (completed) combo.completed = true;
77
+ return { hit: true, completed, step: combo.currentStep - 1 };
78
+ }
79
+ combo.currentStep = 0;
80
+ combo.timer = 0;
81
+ return { hit: false, completed: false, step: 0 };
82
+ }
83
+ updateCombos(dt) {
84
+ for (const combo of this.combos.values()) {
85
+ if (combo.completed || combo.currentStep === 0) continue;
86
+ combo.timer += dt;
87
+ const window = combo.steps[combo.currentStep - 1]?.window ?? 1;
88
+ if (combo.timer > window) {
89
+ combo.currentStep = 0;
90
+ combo.timer = 0;
91
+ }
92
+ }
93
+ }
94
+ resetCombo(comboId) {
95
+ const combo = this.combos.get(comboId);
96
+ if (combo) {
97
+ combo.currentStep = 0;
98
+ combo.timer = 0;
99
+ combo.completed = false;
100
+ }
101
+ }
102
+ // ---------------------------------------------------------------------------
103
+ // Cooldowns
104
+ // ---------------------------------------------------------------------------
105
+ startCooldown(abilityId, duration) {
106
+ this.cooldowns.set(abilityId, { abilityId, duration, remaining: duration });
107
+ }
108
+ isOnCooldown(abilityId) {
109
+ const cd = this.cooldowns.get(abilityId);
110
+ return cd ? cd.remaining > 0 : false;
111
+ }
112
+ getCooldownRemaining(abilityId) {
113
+ return this.cooldowns.get(abilityId)?.remaining ?? 0;
114
+ }
115
+ updateCooldowns(dt) {
116
+ for (const cd of this.cooldowns.values()) {
117
+ cd.remaining = Math.max(0, cd.remaining - dt);
118
+ }
119
+ }
120
+ // ---------------------------------------------------------------------------
121
+ // Targeting
122
+ // ---------------------------------------------------------------------------
123
+ findTargets(position, candidates, maxRange) {
124
+ return candidates.map((c) => {
125
+ const dx = c.position[0] - position[0];
126
+ const dy = c.position[1] - position[1];
127
+ const dz = c.position[2] - position[2];
128
+ const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
129
+ return { entityId: c.entityId, position: c.position, priority: c.priority ?? 0, distance };
130
+ }).filter((t) => t.distance <= maxRange).sort((a, b) => b.priority - a.priority || a.distance - b.distance);
131
+ }
132
+ // ---------------------------------------------------------------------------
133
+ // Queries
134
+ // ---------------------------------------------------------------------------
135
+ getHitLog() {
136
+ return [...this.hitLog];
137
+ }
138
+ getHitBoxCount() {
139
+ return this.hitboxes.size;
140
+ }
141
+ getHurtBoxCount() {
142
+ return this.hurtboxes.size;
143
+ }
144
+ };
145
+
146
+ // src/combat/ComboTracker.ts
147
+ var ComboTracker = class {
148
+ combos = [];
149
+ activeStates = [];
150
+ completedCombos = [];
151
+ currentTime = 0;
152
+ // ---------------------------------------------------------------------------
153
+ // Combo Registration
154
+ // ---------------------------------------------------------------------------
155
+ registerCombo(combo) {
156
+ this.combos.push(combo);
157
+ }
158
+ // ---------------------------------------------------------------------------
159
+ // Input Processing
160
+ // ---------------------------------------------------------------------------
161
+ pushInput(input, timestamp) {
162
+ this.currentTime = timestamp;
163
+ this.completedCombos = [];
164
+ for (let i = this.activeStates.length - 1; i >= 0; i--) {
165
+ const state = this.activeStates[i];
166
+ const combo = this.combos.find((c) => c.id === state.comboId);
167
+ const step = combo.steps[state.currentStep];
168
+ if (timestamp - state.lastInputTime > step.maxDelay) {
169
+ this.activeStates.splice(i, 1);
170
+ continue;
171
+ }
172
+ if (step.input === input) {
173
+ state.currentStep++;
174
+ state.lastInputTime = timestamp;
175
+ if (state.currentStep >= combo.steps.length) {
176
+ state.completed = true;
177
+ this.completedCombos.push(combo.reward);
178
+ this.activeStates.splice(i, 1);
179
+ }
180
+ }
181
+ }
182
+ for (const combo of this.combos) {
183
+ if (combo.steps[0].input === input) {
184
+ const exists = this.activeStates.some((s) => s.comboId === combo.id && s.currentStep === 1);
185
+ if (!exists) {
186
+ if (combo.steps.length === 1) {
187
+ this.completedCombos.push(combo.reward);
188
+ } else {
189
+ this.activeStates.push({
190
+ comboId: combo.id,
191
+ currentStep: 1,
192
+ lastInputTime: timestamp,
193
+ completed: false
194
+ });
195
+ }
196
+ }
197
+ }
198
+ }
199
+ return this.completedCombos.length > 0 ? this.completedCombos[0] : null;
200
+ }
201
+ // ---------------------------------------------------------------------------
202
+ // State
203
+ // ---------------------------------------------------------------------------
204
+ tick(timestamp) {
205
+ this.currentTime = timestamp;
206
+ this.activeStates = this.activeStates.filter((state) => {
207
+ const combo = this.combos.find((c) => c.id === state.comboId);
208
+ const step = combo.steps[state.currentStep];
209
+ return timestamp - state.lastInputTime <= step.maxDelay;
210
+ });
211
+ }
212
+ getActiveComboCount() {
213
+ return this.activeStates.length;
214
+ }
215
+ getCompletedCombos() {
216
+ return [...this.completedCombos];
217
+ }
218
+ reset() {
219
+ this.activeStates = [];
220
+ this.completedCombos = [];
221
+ }
222
+ };
223
+
224
+ // src/combat/DamageSystem.ts
225
+ var _dmgId = 0;
226
+ var _dotId = 0;
227
+ var DamageSystem = class {
228
+ config = {
229
+ critChance: 0.1,
230
+ critMultiplier: 2,
231
+ armorPenetration: 0,
232
+ globalMultiplier: 1
233
+ };
234
+ damageLog = [];
235
+ dots = /* @__PURE__ */ new Map();
236
+ resistances = /* @__PURE__ */ new Map();
237
+ callbacks = [];
238
+ // ---------------------------------------------------------------------------
239
+ // Configuration
240
+ // ---------------------------------------------------------------------------
241
+ setConfig(config) {
242
+ Object.assign(this.config, config);
243
+ }
244
+ getConfig() {
245
+ return { ...this.config };
246
+ }
247
+ setResistances(entityId, res) {
248
+ const base = {
249
+ physical: 0,
250
+ fire: 0,
251
+ ice: 0,
252
+ lightning: 0,
253
+ poison: 0,
254
+ holy: 0,
255
+ dark: 0
256
+ };
257
+ this.resistances.set(entityId, { ...base, ...res });
258
+ }
259
+ getResistances(entityId) {
260
+ return this.resistances.get(entityId) ?? {
261
+ physical: 0,
262
+ fire: 0,
263
+ ice: 0,
264
+ lightning: 0,
265
+ poison: 0,
266
+ holy: 0,
267
+ dark: 0
268
+ };
269
+ }
270
+ // ---------------------------------------------------------------------------
271
+ // Damage Calculation
272
+ // ---------------------------------------------------------------------------
273
+ calculateDamage(sourceId, targetId, baseDamage, type, forceCrit = false) {
274
+ const isCrit = forceCrit || Math.random() < this.config.critChance;
275
+ let damage = baseDamage;
276
+ if (isCrit) damage *= this.config.critMultiplier;
277
+ if (type !== "true") {
278
+ const res = this.getResistances(targetId);
279
+ const resValue = res[type] ?? 0;
280
+ const effectiveRes = resValue * (1 - this.config.armorPenetration);
281
+ damage *= Math.max(0, 1 - effectiveRes);
282
+ }
283
+ damage *= this.config.globalMultiplier;
284
+ damage = Math.max(0, Math.round(damage * 100) / 100);
285
+ const instance = {
286
+ id: `dmg_${_dmgId++}`,
287
+ sourceId,
288
+ targetId,
289
+ baseDamage,
290
+ type,
291
+ isCritical: isCrit,
292
+ finalDamage: damage,
293
+ timestamp: Date.now()
294
+ };
295
+ this.damageLog.push(instance);
296
+ this.callbacks.forEach((cb) => cb(instance));
297
+ return instance;
298
+ }
299
+ // ---------------------------------------------------------------------------
300
+ // Damage Over Time
301
+ // ---------------------------------------------------------------------------
302
+ applyDoT(sourceId, targetId, type, damagePerTick, tickInterval, duration, stacks = 1) {
303
+ const dot = {
304
+ id: `dot_${_dotId++}`,
305
+ sourceId,
306
+ targetId,
307
+ type,
308
+ damagePerTick,
309
+ tickInterval,
310
+ duration,
311
+ elapsed: 0,
312
+ lastTick: 0,
313
+ stacks
314
+ };
315
+ this.dots.set(dot.id, dot);
316
+ return dot;
317
+ }
318
+ updateDoTs(dt) {
319
+ const ticked = [];
320
+ const expired = [];
321
+ for (const dot of this.dots.values()) {
322
+ dot.elapsed += dt;
323
+ while (dot.elapsed - dot.lastTick >= dot.tickInterval && dot.lastTick < dot.duration) {
324
+ dot.lastTick += dot.tickInterval;
325
+ const dmg = this.calculateDamage(
326
+ dot.sourceId,
327
+ dot.targetId,
328
+ dot.damagePerTick * dot.stacks,
329
+ dot.type
330
+ );
331
+ ticked.push(dmg);
332
+ }
333
+ if (dot.elapsed >= dot.duration) expired.push(dot.id);
334
+ }
335
+ for (const id of expired) this.dots.delete(id);
336
+ return ticked;
337
+ }
338
+ getActiveDoTs(targetId) {
339
+ const all = [...this.dots.values()];
340
+ return targetId ? all.filter((d) => d.targetId === targetId) : all;
341
+ }
342
+ // ---------------------------------------------------------------------------
343
+ // Events & Queries
344
+ // ---------------------------------------------------------------------------
345
+ onDamage(callback) {
346
+ this.callbacks.push(callback);
347
+ }
348
+ getDamageLog(limit = 100) {
349
+ return this.damageLog.slice(-limit);
350
+ }
351
+ getTotalDamageDealt(sourceId) {
352
+ return this.damageLog.filter((d) => d.sourceId === sourceId).reduce((sum, d) => sum + d.finalDamage, 0);
353
+ }
354
+ clearLog() {
355
+ this.damageLog = [];
356
+ }
357
+ };
358
+
359
+ // src/combat/HitboxSystem.ts
360
+ var HitboxSystem = class {
361
+ hitboxes = /* @__PURE__ */ new Map();
362
+ hurtboxes = /* @__PURE__ */ new Map();
363
+ currentFrame = 0;
364
+ hitLog = /* @__PURE__ */ new Set();
365
+ // "hitboxGroup:hurtboxEntity" dedup
366
+ events = [];
367
+ // ---------------------------------------------------------------------------
368
+ // Registration
369
+ // ---------------------------------------------------------------------------
370
+ addHitbox(hb) {
371
+ this.hitboxes.set(hb.id, hb);
372
+ }
373
+ addHurtbox(hb) {
374
+ this.hurtboxes.set(hb.id, hb);
375
+ }
376
+ removeHitbox(id) {
377
+ this.hitboxes.delete(id);
378
+ }
379
+ removeHurtbox(id) {
380
+ this.hurtboxes.delete(id);
381
+ }
382
+ // ---------------------------------------------------------------------------
383
+ // Frame Update
384
+ // ---------------------------------------------------------------------------
385
+ update(frame) {
386
+ this.currentFrame = frame;
387
+ this.events = [];
388
+ for (const hitbox of this.hitboxes.values()) {
389
+ if (frame < hitbox.activeStart || frame > hitbox.activeEnd) continue;
390
+ for (const hurtbox of this.hurtboxes.values()) {
391
+ if (hitbox.ownerId === hurtbox.entityId) continue;
392
+ const key = `${hitbox.group}:${hurtbox.entityId}`;
393
+ if (this.hitLog.has(key)) continue;
394
+ if (this.overlaps(hitbox, hurtbox)) {
395
+ this.hitLog.add(key);
396
+ this.events.push({
397
+ hitboxId: hitbox.id,
398
+ hurtboxId: hurtbox.id,
399
+ attackerId: hitbox.ownerId,
400
+ defenderId: hurtbox.entityId,
401
+ damage: hitbox.damage,
402
+ knockbackX: hitbox.knockbackX,
403
+ knockbackY: hitbox.knockbackY
404
+ });
405
+ }
406
+ }
407
+ }
408
+ return [...this.events];
409
+ }
410
+ // ---------------------------------------------------------------------------
411
+ // Collision Test
412
+ // ---------------------------------------------------------------------------
413
+ overlaps(hb, hr) {
414
+ return hb.x < hr.x + hr.width && hb.x + hb.width > hr.x && hb.y < hr.y + hr.height && hb.y + hb.height > hr.y && hb.z < hr.z + hr.depth && hb.z + hb.depth > hr.z;
415
+ }
416
+ // ---------------------------------------------------------------------------
417
+ // State
418
+ // ---------------------------------------------------------------------------
419
+ clearHitLog() {
420
+ this.hitLog.clear();
421
+ }
422
+ getHitCount() {
423
+ return this.hitLog.size;
424
+ }
425
+ getLastEvents() {
426
+ return [...this.events];
427
+ }
428
+ };
429
+
430
+ // src/combat/ProjectileSystem.ts
431
+ var ProjectileSystem = class {
432
+ projectiles = /* @__PURE__ */ new Map();
433
+ nextId = 0;
434
+ onImpact = null;
435
+ // ---------------------------------------------------------------------------
436
+ // Spawning
437
+ // ---------------------------------------------------------------------------
438
+ spawn(ownerId, x, y, z, dx, dy, dz, config) {
439
+ const id = `proj_${this.nextId++}`;
440
+ const len = Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
441
+ this.projectiles.set(id, {
442
+ id,
443
+ x,
444
+ y,
445
+ z,
446
+ vx: dx / len * config.speed,
447
+ vy: dy / len * config.speed,
448
+ vz: dz / len * config.speed,
449
+ config,
450
+ age: 0,
451
+ hitCount: 0,
452
+ alive: true,
453
+ ownerId
454
+ });
455
+ return id;
456
+ }
457
+ setImpactCallback(cb) {
458
+ this.onImpact = cb;
459
+ }
460
+ // ---------------------------------------------------------------------------
461
+ // Update
462
+ // ---------------------------------------------------------------------------
463
+ update(dt, targets) {
464
+ for (const proj of this.projectiles.values()) {
465
+ if (!proj.alive) continue;
466
+ proj.age += dt;
467
+ if (proj.age >= proj.config.lifetime) {
468
+ proj.alive = false;
469
+ continue;
470
+ }
471
+ proj.vy -= proj.config.gravity * dt;
472
+ if (proj.config.homing && targets && targets.length > 0) {
473
+ const nearest = this.findNearest(proj, targets);
474
+ if (nearest) {
475
+ const dx = nearest.x - proj.x, dy = nearest.y - proj.y, dz = nearest.z - proj.z;
476
+ const dist = Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
477
+ const str = proj.config.homingStrength * dt;
478
+ proj.vx += dx / dist * str;
479
+ proj.vy += dy / dist * str;
480
+ proj.vz += dz / dist * str;
481
+ const sp = Math.sqrt(proj.vx * proj.vx + proj.vy * proj.vy + proj.vz * proj.vz) || 1;
482
+ proj.vx = proj.vx / sp * proj.config.speed;
483
+ proj.vy = proj.vy / sp * proj.config.speed;
484
+ proj.vz = proj.vz / sp * proj.config.speed;
485
+ }
486
+ }
487
+ proj.x += proj.vx * dt;
488
+ proj.y += proj.vy * dt;
489
+ proj.z += proj.vz * dt;
490
+ if (targets) {
491
+ for (const t of targets) {
492
+ const dx = t.x - proj.x, dy = t.y - proj.y, dz = t.z - proj.z;
493
+ if (Math.sqrt(dx * dx + dy * dy + dz * dz) <= t.radius) {
494
+ proj.hitCount++;
495
+ if (this.onImpact) this.onImpact(proj, t.id);
496
+ if (proj.hitCount > proj.config.piercing) {
497
+ proj.alive = false;
498
+ break;
499
+ }
500
+ }
501
+ }
502
+ }
503
+ }
504
+ }
505
+ // ---------------------------------------------------------------------------
506
+ // Helpers
507
+ // ---------------------------------------------------------------------------
508
+ findNearest(proj, targets) {
509
+ let best = null;
510
+ let bestDist = Infinity;
511
+ for (const t of targets) {
512
+ const d = Math.sqrt((t.x - proj.x) ** 2 + (t.y - proj.y) ** 2 + (t.z - proj.z) ** 2);
513
+ if (d < bestDist) {
514
+ bestDist = d;
515
+ best = t;
516
+ }
517
+ }
518
+ return best;
519
+ }
520
+ // ---------------------------------------------------------------------------
521
+ // Queries
522
+ // ---------------------------------------------------------------------------
523
+ getProjectile(id) {
524
+ return this.projectiles.get(id);
525
+ }
526
+ getAliveCount() {
527
+ return [...this.projectiles.values()].filter((p) => p.alive).length;
528
+ }
529
+ cleanup() {
530
+ for (const [id, p] of this.projectiles) if (!p.alive) this.projectiles.delete(id);
531
+ }
532
+ };
533
+
534
+ // src/combat/StatusEffects.ts
535
+ var _effectId = 0;
536
+ var StatusEffectSystem = class {
537
+ effects = /* @__PURE__ */ new Map();
538
+ // entityId → effectName → effect
539
+ immunities = /* @__PURE__ */ new Map();
540
+ // entityId → immune effect names
541
+ tickResults = [];
542
+ // ---------------------------------------------------------------------------
543
+ // Application
544
+ // ---------------------------------------------------------------------------
545
+ apply(entityId, effectDef) {
546
+ const immune = this.immunities.get(entityId);
547
+ if (immune?.has(effectDef.name)) return null;
548
+ let entityEffects = this.effects.get(entityId);
549
+ if (!entityEffects) {
550
+ entityEffects = /* @__PURE__ */ new Map();
551
+ this.effects.set(entityId, entityEffects);
552
+ }
553
+ const existing = entityEffects.get(effectDef.name);
554
+ if (existing) {
555
+ switch (effectDef.stackBehavior) {
556
+ case "stack":
557
+ existing.stacks = Math.min(existing.stacks + (effectDef.stacks ?? 1), existing.maxStacks);
558
+ return existing;
559
+ case "refresh":
560
+ existing.elapsed = 0;
561
+ return existing;
562
+ case "replace":
563
+ break;
564
+ case "ignore":
565
+ return existing;
566
+ }
567
+ }
568
+ const effect = {
569
+ ...effectDef,
570
+ id: `effect_${_effectId++}`,
571
+ elapsed: 0,
572
+ lastTick: 0,
573
+ stacks: effectDef.stacks ?? 1
574
+ };
575
+ entityEffects.set(effect.name, effect);
576
+ return effect;
577
+ }
578
+ // ---------------------------------------------------------------------------
579
+ // Removal
580
+ // ---------------------------------------------------------------------------
581
+ remove(entityId, effectName) {
582
+ const entityEffects = this.effects.get(entityId);
583
+ return entityEffects ? entityEffects.delete(effectName) : false;
584
+ }
585
+ removeAllOfType(entityId, type) {
586
+ const entityEffects = this.effects.get(entityId);
587
+ if (!entityEffects) return 0;
588
+ let count = 0;
589
+ for (const [name, effect] of entityEffects) {
590
+ if (effect.type === type) {
591
+ entityEffects.delete(name);
592
+ count++;
593
+ }
594
+ }
595
+ return count;
596
+ }
597
+ cleanse(entityId, _count = Infinity) {
598
+ return this.removeAllOfType(entityId, "debuff");
599
+ }
600
+ // ---------------------------------------------------------------------------
601
+ // Update
602
+ // ---------------------------------------------------------------------------
603
+ update(dt) {
604
+ this.tickResults = [];
605
+ const toRemove = [];
606
+ for (const [entityId, entityEffects] of this.effects) {
607
+ for (const [name, effect] of entityEffects) {
608
+ effect.elapsed += dt;
609
+ if (effect.tickInterval > 0 && effect.tickDamage > 0) {
610
+ while (effect.elapsed - effect.lastTick >= effect.tickInterval) {
611
+ effect.lastTick += effect.tickInterval;
612
+ this.tickResults.push({
613
+ entityId,
614
+ effectName: name,
615
+ damage: effect.tickDamage * effect.stacks
616
+ });
617
+ }
618
+ }
619
+ if (effect.duration > 0 && effect.elapsed >= effect.duration) {
620
+ toRemove.push({ entityId, name });
621
+ }
622
+ }
623
+ }
624
+ for (const { entityId, name } of toRemove) {
625
+ this.remove(entityId, name);
626
+ }
627
+ }
628
+ getTickResults() {
629
+ return [...this.tickResults];
630
+ }
631
+ // ---------------------------------------------------------------------------
632
+ // Immunity
633
+ // ---------------------------------------------------------------------------
634
+ addImmunity(entityId, effectName) {
635
+ let set = this.immunities.get(entityId);
636
+ if (!set) {
637
+ set = /* @__PURE__ */ new Set();
638
+ this.immunities.set(entityId, set);
639
+ }
640
+ set.add(effectName);
641
+ }
642
+ removeImmunity(entityId, effectName) {
643
+ this.immunities.get(entityId)?.delete(effectName);
644
+ }
645
+ // ---------------------------------------------------------------------------
646
+ // Stat Queries
647
+ // ---------------------------------------------------------------------------
648
+ getStatModifiers(entityId, stat) {
649
+ let flat = 0, percent = 1;
650
+ const entityEffects = this.effects.get(entityId);
651
+ if (entityEffects) {
652
+ for (const effect of entityEffects.values()) {
653
+ for (const mod of effect.modifiers) {
654
+ if (mod.stat === stat) {
655
+ flat += mod.flat * effect.stacks;
656
+ percent *= Math.pow(mod.percent, effect.stacks);
657
+ }
658
+ }
659
+ }
660
+ }
661
+ return { flat, percent };
662
+ }
663
+ applyStatModifiers(entityId, stat, baseValue) {
664
+ const { flat, percent } = this.getStatModifiers(entityId, stat);
665
+ return (baseValue + flat) * percent;
666
+ }
667
+ // ---------------------------------------------------------------------------
668
+ // Queries
669
+ // ---------------------------------------------------------------------------
670
+ getEffects(entityId) {
671
+ const entityEffects = this.effects.get(entityId);
672
+ return entityEffects ? [...entityEffects.values()] : [];
673
+ }
674
+ hasEffect(entityId, effectName) {
675
+ return this.effects.get(entityId)?.has(effectName) ?? false;
676
+ }
677
+ getEffectCount(entityId) {
678
+ return this.effects.get(entityId)?.size ?? 0;
679
+ }
680
+ };
681
+
682
+ export {
683
+ CombatManager,
684
+ ComboTracker,
685
+ DamageSystem,
686
+ HitboxSystem,
687
+ ProjectileSystem,
688
+ StatusEffectSystem,
689
+ combat_exports
690
+ };