forked from Bitcoindefi/OpenAO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentityOverlays.ts
More file actions
823 lines (708 loc) · 25.7 KB
/
Copy pathentityOverlays.ts
File metadata and controls
823 lines (708 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
import { AnimatedSprite, Container, Graphics, Sprite, Text } from "pixi.js";
import type { SpellData } from "../../../types/game";
import { TILE_SIZE } from "../../../lib/viewport";
import type { Engine } from "../engine/Engine";
import { createSpellProjectileVisual } from "./effectsRenderer";
import {
getDialogLabelPosition,
type BodyRenderMetrics,
} from "./characterLayout";
import {
getEntityFXRowContainer,
syncDisplayObjectToEntityFXRow,
} from "./rowLayerContainers";
type ActiveDialogMessage = {
text: string;
color?: string;
timeoutId: number;
variant: "bubble" | "floatingCombat";
startedAt: number;
durationMs: number;
};
type ActiveCastBar = {
startedAt: number;
durationMs: number;
};
type CreateEntityOverlaysOptions = {
getActiveDialogMessages: () => Map<number, ActiveDialogMessage>;
getActiveCastBars: () => Map<number, ActiveCastBar>;
getEngine: () => Engine | null;
destroyDisplayObjectSafely: (
displayObject: any,
options?: { children?: boolean },
) => void;
canUseEngineContainer: (
engine: Engine,
container: Container | null | undefined,
) => boolean;
loadTextures: (engine: Engine, graphicIds: string[]) => Promise<void>;
createCastBar: () => Container;
createDialogBubble: (text: string, color?: string) => Container;
createFloatingCombatText: (text: string, color?: string) => Text;
isCombatDialogMessage: (text: string, color?: string) => boolean;
getDialogMessageDuration: (text: string) => number;
getEntityContainer: (engine: Engine, entityId: number) => Container | null;
getPersistentEntityFxIds: () => Set<number>;
defaultEntityFxDurationMs: number;
entityFxAlpha: number;
projectileBaseAngleRadians: number;
projectileMinDurationMs: number;
projectileMaxDurationMs: number;
projectilePixelsPerMs: number;
};
export function createEntityOverlays(options: CreateEntityOverlaysOptions) {
const removeDialogBubbleFromContainer = (
container: Container | null | undefined,
) => {
if (!container) {
return;
}
const dialogBubble = container.children.find(
(child) => (child as any).isDialogBubble,
);
if (!dialogBubble) {
return;
}
container.removeChild(dialogBubble);
options.destroyDisplayObjectSafely(dialogBubble as any, {
children: true,
});
};
const removeDialogBubbleFromOverlay = (
engine: Engine,
entityId: number,
) => {
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
const dialogBubble = overlay.children.find(
(child) => (child as any).dialogEntityId === entityId,
);
if (!dialogBubble) {
return;
}
overlay.removeChild(dialogBubble);
options.destroyDisplayObjectSafely(dialogBubble as any, {
children: true,
});
};
const removeCastBarFromOverlay = (engine: Engine, entityId: number) => {
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
const castBar = overlay.children.find(
(child) => (child as any).castBarEntityId === entityId,
);
if (!castBar) {
return;
}
overlay.removeChild(castBar);
options.destroyDisplayObjectSafely(castBar as any, { children: true });
};
const positionCastBar = (
engine: Engine,
entityId: number,
castBar: Container,
): boolean => {
const container = options.getEntityContainer(engine, entityId);
if (!container) {
return false;
}
const bodySprite = ((container as any).bodySprite ??
container.children.find((child) =>
Boolean((child as any).renderMetrics),
)) as Container["children"][number] | undefined;
const bodyMetrics = (bodySprite as any)?.renderMetrics as
| BodyRenderMetrics
| undefined;
if (!bodyMetrics) {
return false;
}
const anchor = getDialogLabelPosition(bodyMetrics);
castBar.x = Math.round(container.x + anchor.x);
castBar.y = Math.round(container.y + anchor.y + 20);
castBar.zIndex = Number(container.zIndex ?? 0) + 0.95;
return true;
};
const syncCastBar = (engine: Engine, entityId: number) => {
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
removeCastBarFromOverlay(engine, entityId);
const castBarState = options.getActiveCastBars().get(entityId);
if (!castBarState) {
return;
}
const castBar = options.createCastBar();
if (!positionCastBar(engine, entityId, castBar)) {
castBar.destroy({ children: true });
return;
}
const elapsed = Math.max(0, performance.now() - castBarState.startedAt);
const progress = Math.max(0, 1 - elapsed / castBarState.durationMs);
const fill = (castBar as any).castBarFill as Graphics | undefined;
if (fill) {
fill.scale.x = progress;
}
(castBar as any).castBarEntityId = entityId;
overlay.addChild(castBar);
};
const clearEntityFX = (
engine: Engine,
entityId: number,
fxOptions?: { clearStoredGraphic?: boolean },
) => {
const activeEffect = engine.entityEffects.get(entityId);
if (activeEffect) {
if (activeEffect instanceof AnimatedSprite) {
engine.animatedSpriteFrameCounters.delete(activeEffect);
}
if (activeEffect.parent) {
activeEffect.parent.removeChild(activeEffect);
}
options.destroyDisplayObjectSafely(activeEffect as any);
engine.entityEffects.delete(entityId);
}
const timeoutId = engine.entityEffectTimeouts.get(entityId);
if (typeof timeoutId === "number") {
window.clearTimeout(timeoutId);
engine.entityEffectTimeouts.delete(entityId);
}
if (fxOptions?.clearStoredGraphic !== false) {
engine.entityEffectGraphicIds.delete(entityId);
engine.entityEffectStartedAt.delete(entityId);
engine.entityEffectExpiresAt.delete(entityId);
}
};
const positionEntityFX = (engine: Engine, entityId: number): boolean => {
const overlay = engine.entityFXOverlayContainer;
const container = options.getEntityContainer(engine, entityId);
const effectSprite = engine.entityEffects.get(entityId);
if (!overlay || !container || !effectSprite) {
return false;
}
const offsetX = Number((effectSprite as any).entityFXOffsetX ?? 0);
const offsetY = Number((effectSprite as any).entityFXOffsetY ?? 0);
effectSprite.x = Math.round(container.x + offsetX);
effectSprite.y = Math.round(container.y + offsetY);
if (
!getEntityFXRowContainer(
engine,
Math.floor(effectSprite.y / TILE_SIZE) + 1,
)
) {
return false;
}
syncDisplayObjectToEntityFXRow(engine, effectSprite.y, effectSprite);
return true;
};
const renderEntityFX = async (
engine: Engine,
entityId: number,
graphicId: number,
) => {
if (graphicId <= 0) {
clearEntityFX(engine, entityId);
return;
}
const storedGraphicId = engine.entityEffectGraphicIds.get(entityId);
const storedStartedAt = engine.entityEffectStartedAt.get(entityId);
const storedExpiresAt = engine.entityEffectExpiresAt.get(entityId);
const container = options.getEntityContainer(engine, entityId);
if (
!options.canUseEngineContainer(engine, container) ||
!options.canUseEngineContainer(
engine,
engine.entityFXOverlayContainer,
) ||
!engine.graphicsDB ||
!engine.fxsDB
) {
return;
}
const activeEffect = engine.entityEffects.get(entityId);
if (
activeEffect &&
!(activeEffect as any).destroyed &&
storedGraphicId === graphicId &&
activeEffect.parent
) {
positionEntityFX(engine, entityId);
return;
}
engine.entityEffectGraphicIds.set(entityId, graphicId);
clearEntityFX(engine, entityId, { clearStoredGraphic: false });
const effectData = engine.fxsDB[graphicId.toString()];
if (!effectData) {
return;
}
const graphicKey = effectData.grh.toString();
if (
!engine.textureCache.has(graphicKey) &&
!engine.animatedTextureCache.has(graphicKey)
) {
await options.loadTextures(engine, [graphicKey]);
const currentContainer = options.getEntityContainer(
engine,
entityId,
);
if (
!options.canUseEngineContainer(engine, currentContainer) ||
!options.canUseEngineContainer(
engine,
engine.entityFXOverlayContainer,
) ||
currentContainer !== container
) {
return;
}
}
const graphicData = engine.graphicsDB[graphicKey];
if (!graphicData) {
return;
}
const effectFrameSpeed = graphicData.speed || 500;
const effectTimeoutDuration = Math.max(
options.defaultEntityFxDurationMs,
effectFrameSpeed * Math.max(graphicData.numFrames, 1),
);
const now = Date.now();
const isPersistentEffect = options
.getPersistentEntityFxIds()
.has(graphicId);
const startedAt =
storedGraphicId === graphicId && typeof storedStartedAt === "number"
? storedStartedAt
: now;
const expiresAt =
storedGraphicId === graphicId && typeof storedExpiresAt === "number"
? storedExpiresAt
: now + effectTimeoutDuration;
const durationMs = Math.max(0, expiresAt - now);
if (durationMs <= 0) {
clearEntityFX(engine, entityId);
return;
}
let effectSprite: Sprite | AnimatedSprite | null = null;
if (graphicData.numFrames > 1) {
const frameTextures = engine.animatedTextureCache.get(graphicKey);
if (!frameTextures || frameTextures.length === 0) {
return;
}
const animatedSprite = new AnimatedSprite(frameTextures);
animatedSprite.stop();
animatedSprite.alpha = options.entityFxAlpha;
animatedSprite.visible = true;
const elapsedMs = Math.max(0, now - startedAt);
const frameCounter = isPersistentEffect
? 0.1 + ((elapsedMs / effectFrameSpeed) % graphicData.numFrames)
: Math.min(
graphicData.numFrames,
0.1 + elapsedMs / effectFrameSpeed,
);
const frameNumber = Math.ceil(frameCounter);
const frameIndex = Math.max(
0,
Math.min(frameNumber - 1, frameTextures.length - 1),
);
animatedSprite.currentFrame = frameIndex;
(animatedSprite as any).frameCounter = frameCounter;
engine.animatedSpriteFrameCounters.set(animatedSprite, {
graphicId: graphicKey,
graphicData,
loop: isPersistentEffect,
});
effectSprite = animatedSprite;
} else {
const texture = engine.textureCache.get(graphicKey);
if (!texture) {
return;
}
effectSprite = new Sprite(texture);
}
effectSprite.alpha = options.entityFxAlpha;
(effectSprite as any).entityFXOffsetX = effectData.offsetX;
(effectSprite as any).entityFXOffsetY = effectData.offsetY;
(effectSprite as any).isEntityFX = true;
(effectSprite as any).entityId = entityId;
engine.entityEffects.set(entityId, effectSprite);
engine.entityEffectStartedAt.set(entityId, startedAt);
positionEntityFX(engine, entityId);
if (isPersistentEffect) {
engine.entityEffectExpiresAt.delete(entityId);
return;
}
engine.entityEffectExpiresAt.set(entityId, expiresAt);
const timeoutId = window.setTimeout(() => {
const activeGraphicId = engine.entityEffectGraphicIds.get(entityId);
if (activeGraphicId !== graphicId) {
return;
}
clearEntityFX(engine, entityId);
}, durationMs);
engine.entityEffectTimeouts.set(entityId, timeoutId);
};
const syncEntityFX = async (engine: Engine, entityId: number) => {
const graphicId = engine.entityEffectGraphicIds.get(entityId);
if (!graphicId) {
return;
}
await renderEntityFX(engine, entityId, graphicId);
};
const renderProjectileVisual = async (
engine: Engine,
startPos: { x: number; y: number },
endPos: { x: number; y: number },
graphicId: number,
) => {
const overlay = engine.entityFXOverlayContainer;
if (
graphicId <= 0 ||
!overlay ||
!engine.graphicsDB ||
engine.isDestroyed
) {
return;
}
const graphicKey = graphicId.toString();
if (
!engine.textureCache.has(graphicKey) &&
!engine.animatedTextureCache.has(graphicKey)
) {
await options.loadTextures(engine, [graphicKey]);
if (engine.isDestroyed || !engine.entityFXOverlayContainer) {
return;
}
}
const graphicData = engine.graphicsDB[graphicKey];
if (!graphicData) {
return;
}
let projectileSprite: Sprite | AnimatedSprite | null = null;
if (graphicData.numFrames > 1) {
const frameTextures = engine.animatedTextureCache.get(graphicKey);
if (!frameTextures || frameTextures.length === 0) {
return;
}
const animatedSprite = new AnimatedSprite(frameTextures);
animatedSprite.stop();
animatedSprite.currentFrame = 0;
engine.animatedSpriteFrameCounters.set(animatedSprite, {
graphicId: graphicKey,
graphicData,
loop: true,
});
projectileSprite = animatedSprite;
} else {
const texture = engine.textureCache.get(graphicKey);
if (!texture) {
return;
}
projectileSprite = new Sprite(texture);
}
const startWorldX = (startPos.x - 1) * TILE_SIZE + TILE_SIZE / 2;
const startWorldY = (startPos.y - 1) * TILE_SIZE + TILE_SIZE / 2;
const endWorldX = (endPos.x - 1) * TILE_SIZE + TILE_SIZE / 2;
const endWorldY = (endPos.y - 1) * TILE_SIZE + TILE_SIZE / 2;
const distancePixels = Math.hypot(
endWorldX - startWorldX,
endWorldY - startWorldY,
);
const durationMs = Math.max(
options.projectileMinDurationMs,
Math.min(
options.projectileMaxDurationMs,
distancePixels / options.projectilePixelsPerMs,
),
);
const rotation =
Math.atan2(endWorldY - startWorldY, endWorldX - startWorldX) -
options.projectileBaseAngleRadians;
projectileSprite.anchor.set(0.5);
projectileSprite.rotation = rotation;
projectileSprite.x = Math.round(startWorldX);
projectileSprite.y = Math.round(startWorldY);
const targetContainer = getEntityFXRowContainer(
engine,
Math.floor(startWorldY / TILE_SIZE) + 1,
);
if (!targetContainer) {
options.destroyDisplayObjectSafely(projectileSprite as any);
return;
}
targetContainer.addChild(projectileSprite);
const projectileId = engine.nextProjectileVisualId++;
engine.projectileVisuals.set(projectileId, {
id: projectileId,
sprite: projectileSprite,
startedAt: performance.now(),
durationMs,
startWorldX,
startWorldY,
endWorldX,
endWorldY,
});
};
const renderSpellProjectileVisual = (
engine: Engine,
startPos: { x: number; y: number },
endPos: { x: number; y: number },
spellData: SpellData | null | undefined,
) => {
const overlay = engine.entityFXOverlayContainer;
if (!overlay || engine.isDestroyed) {
return;
}
const startWorldX = (startPos.x - 1) * TILE_SIZE + TILE_SIZE / 2;
const startWorldY = (startPos.y - 1) * TILE_SIZE + TILE_SIZE / 2;
const endWorldX = (endPos.x - 1) * TILE_SIZE + TILE_SIZE / 2;
const endWorldY = (endPos.y - 1) * TILE_SIZE + TILE_SIZE / 2;
const distancePixels = Math.hypot(
endWorldX - startWorldX,
endWorldY - startWorldY,
);
if (distancePixels < 8) {
return;
}
const durationMs = Math.max(
options.projectileMinDurationMs,
Math.min(
options.projectileMaxDurationMs,
distancePixels / options.projectilePixelsPerMs,
),
);
const rotation = Math.atan2(
endWorldY - startWorldY,
endWorldX - startWorldX,
);
const { container, updateVisual, cleanupVisual } =
createSpellProjectileVisual(
(worldY) =>
getEntityFXRowContainer(
engine,
Math.floor(worldY / TILE_SIZE) + 1,
) ?? overlay,
rotation,
spellData,
);
container.x = Math.round(startWorldX);
container.y = Math.round(startWorldY);
const targetContainer = getEntityFXRowContainer(
engine,
Math.floor(startWorldY / TILE_SIZE) + 1,
);
if (!targetContainer) {
cleanupVisual();
options.destroyDisplayObjectSafely(container as any, {
children: true,
});
return;
}
targetContainer.addChild(container);
const projectileId = engine.nextProjectileVisualId++;
engine.projectileVisuals.set(projectileId, {
id: projectileId,
sprite: container,
startedAt: performance.now(),
durationMs,
startWorldX,
startWorldY,
endWorldX,
endWorldY,
updateVisual,
cleanupVisual,
});
};
const positionDialogBubble = (
engine: Engine,
entityId: number,
bubble: Container | Text,
dialog?: ActiveDialogMessage,
): boolean => {
const container = options.getEntityContainer(engine, entityId);
if (!container) {
return false;
}
const bodySprite = ((container as any).bodySprite ??
container.children.find(
(child) =>
(child as any).isPlayerBody || (child as any).isRemoteBody,
)) as AnimatedSprite | undefined;
const bodyMetrics = bodySprite
? ((bodySprite as any).renderMetrics as BodyRenderMetrics)
: (((container as any).bodyMetrics as
| BodyRenderMetrics
| undefined) ?? undefined);
if (!bodyMetrics) {
return false;
}
const bubblePosition = getDialogLabelPosition(bodyMetrics);
let offsetY = 0;
if (dialog?.variant === "floatingCombat") {
const elapsed = Math.max(0, performance.now() - dialog.startedAt);
const progress = Math.min(
1,
elapsed / Math.max(1, dialog.durationMs),
);
const easedProgress = 1 - (1 - progress) * (1 - progress);
offsetY = 25 - easedProgress * 10;
bubble.alpha = 1 - easedProgress * 0.25;
bubble.scale.set(1 + (1 - progress) * 0.03);
} else {
bubble.alpha = 1;
bubble.scale.set(1);
}
bubble.x = Math.round(container.x + bubblePosition.x);
bubble.y = Math.round(container.y + bubblePosition.y + offsetY);
return true;
};
const syncDialogBubble = (engine: Engine, entityId: number) => {
const dialog = options.getActiveDialogMessages().get(entityId);
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
removeDialogBubbleFromOverlay(engine, entityId);
if (!dialog) {
return;
}
const bubble =
dialog.variant === "floatingCombat"
? options.createFloatingCombatText(dialog.text, dialog.color)
: options.createDialogBubble(dialog.text, dialog.color);
if (!positionDialogBubble(engine, entityId, bubble, dialog)) {
bubble.destroy({ children: true });
return;
}
(bubble as any).dialogEntityId = entityId;
overlay.addChild(bubble);
};
const showDialogBubble = (
entityId: number,
text: string,
color?: string,
) => {
const engine = options.getEngine();
const activeDialogMessages = options.getActiveDialogMessages();
const previousDialog = activeDialogMessages.get(entityId);
if (text.trim().length === 0) {
if (previousDialog) {
window.clearTimeout(previousDialog.timeoutId);
activeDialogMessages.delete(entityId);
}
if (engine) {
syncDialogBubble(engine, entityId);
}
return;
}
if (previousDialog) {
window.clearTimeout(previousDialog.timeoutId);
}
const startedAt = performance.now();
const variant = options.isCombatDialogMessage(text, color)
? "floatingCombat"
: "bubble";
const durationMs =
variant === "floatingCombat"
? 500
: options.getDialogMessageDuration(text);
const timeoutId = window.setTimeout(() => {
activeDialogMessages.delete(entityId);
if (engine) {
syncDialogBubble(engine, entityId);
}
}, durationMs);
activeDialogMessages.set(entityId, {
text,
color,
timeoutId,
variant,
startedAt,
durationMs,
});
if (engine) {
syncDialogBubble(engine, entityId);
}
};
const updateActiveDialogBubblePositions = (engine: Engine) => {
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
for (const bubble of overlay.children) {
const entityId = (bubble as any).dialogEntityId;
if (typeof entityId !== "number") {
continue;
}
positionDialogBubble(
engine,
entityId,
bubble as Container,
options.getActiveDialogMessages().get(entityId),
);
}
};
const updateActiveCastBarPositions = (engine: Engine) => {
const overlay = engine.dialogOverlayContainer;
if (!overlay) {
return;
}
for (const [entityId, castBarState] of options.getActiveCastBars()) {
const castBar = overlay.children.find(
(child) => (child as any).castBarEntityId === entityId,
) as Container | undefined;
if (!castBar) {
syncCastBar(engine, entityId);
continue;
}
if (!positionCastBar(engine, entityId, castBar)) {
removeCastBarFromOverlay(engine, entityId);
continue;
}
const elapsed = Math.max(
0,
performance.now() - castBarState.startedAt,
);
const progress = Math.max(0, 1 - elapsed / castBarState.durationMs);
const fill = (castBar as any).castBarFill as Graphics | undefined;
if (fill) {
fill.scale.x = progress;
}
}
};
const updateEntityFXPositions = (engine: Engine) => {
for (const entityId of engine.entityEffects.keys()) {
positionEntityFX(engine, entityId);
}
};
const clearAllDialogMessages = () => {
for (const dialog of options.getActiveDialogMessages().values()) {
window.clearTimeout(dialog.timeoutId);
}
options.getActiveDialogMessages().clear();
};
const clearAllCastBars = () => {
options.getActiveCastBars().clear();
};
return {
clearAllCastBars,
clearAllDialogMessages,
clearEntityFX,
removeCastBarFromOverlay,
removeDialogBubbleFromContainer,
removeDialogBubbleFromOverlay,
renderEntityFX,
renderProjectileVisual,
renderSpellProjectileVisual,
showDialogBubble,
syncCastBar,
syncDialogBubble,
syncEntityFX,
updateActiveCastBarPositions,
updateActiveDialogBubblePositions,
updateEntityFXPositions,
};
}