@rpgjs/client 5.0.0-alpha.22 → 5.0.0-alpha.24
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.
- package/dist/Game/Object.d.ts +2 -0
- package/dist/RpgClientEngine.d.ts +115 -9
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/prebuilt/index.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +6 -5
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +2 -2
- package/dist/index13.js +102 -10
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +67 -9
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +10 -263
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +9 -97
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +300 -89
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +63 -80
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +96 -348
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +176 -24
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +360 -17
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +19 -50
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +212 -5
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +6 -395
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +4 -39
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +19 -20
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +43 -2624
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +5 -110
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +394 -65
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +40 -15
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +3 -3
- package/dist/index30.js +21 -23
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +2624 -86
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +107 -34
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +69 -22
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +19 -3
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +21 -329
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +91 -30
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +37 -7
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +22 -9
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +139 -10
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +3 -3
- package/dist/index40.js +16 -6
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +1 -325
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +530 -3680
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +24 -67
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +9 -184
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +6 -503
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +325 -2
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +3687 -17
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +69 -202
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +182 -7
- package/dist/index49.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.js +497 -106
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +48 -130
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +17 -134
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +3 -109
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +9 -138
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +111 -7
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +130 -48
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +137 -0
- package/dist/index57.js.map +1 -0
- package/dist/index58.js +112 -0
- package/dist/index58.js.map +1 -0
- package/dist/index59.js +9 -0
- package/dist/index59.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +17 -2
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +10 -27
- package/dist/index9.js.map +1 -1
- package/dist/services/keyboardControls.d.ts +1 -2
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +9 -9
- package/src/Game/Object.ts +8 -0
- package/src/Gui/Gui.ts +4 -31
- package/src/RpgClientEngine.ts +193 -20
- package/src/components/character.ce +146 -9
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/prebuilt/index.ts +1 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +2 -2
- package/src/components/scenes/event-layer.ce +1 -0
- package/src/components/scenes/transition.ce +60 -0
- package/src/index.ts +6 -1
- package/src/module.ts +15 -0
- package/src/services/keyboardControls.ts +1 -1
package/dist/Game/Object.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Context } from '@signe/di';
|
|
2
1
|
import { AbstractWebsocket } from './services/AbstractSocket';
|
|
3
2
|
import { Direction } from '@rpgjs/common';
|
|
4
3
|
import { RpgClientMap } from './Game/Map';
|
|
@@ -6,7 +5,7 @@ import { AnimationManager } from './Game/AnimationManager';
|
|
|
6
5
|
import { Observable } from 'rxjs';
|
|
7
6
|
import * as PIXI from "pixi.js";
|
|
8
7
|
export declare class RpgClientEngine<T = any> {
|
|
9
|
-
context:
|
|
8
|
+
context: any;
|
|
10
9
|
private guiService;
|
|
11
10
|
private webSocket;
|
|
12
11
|
private loadMapService;
|
|
@@ -35,6 +34,7 @@ export declare class RpgClientEngine<T = any> {
|
|
|
35
34
|
cameraFollowTargetId: import('canvasengine').WritableSignal<string | null>;
|
|
36
35
|
/** Trigger for map shake animation */
|
|
37
36
|
mapShakeTrigger: import('canvasengine').Trigger<any>;
|
|
37
|
+
controlsReady: import('canvasengine').WritableSignal<undefined>;
|
|
38
38
|
private predictionEnabled;
|
|
39
39
|
private prediction?;
|
|
40
40
|
private readonly SERVER_CORRECTION_THRESHOLD;
|
|
@@ -44,7 +44,12 @@ export declare class RpgClientEngine<T = any> {
|
|
|
44
44
|
private pingInterval;
|
|
45
45
|
private readonly PING_INTERVAL_MS;
|
|
46
46
|
private lastInputTime;
|
|
47
|
-
|
|
47
|
+
private mapLoadCompleted$;
|
|
48
|
+
private playerIdReceived$;
|
|
49
|
+
private playersReceived$;
|
|
50
|
+
private eventsReceived$;
|
|
51
|
+
private onAfterLoadingSubscription?;
|
|
52
|
+
constructor(context: any);
|
|
48
53
|
/**
|
|
49
54
|
* Assigns a CanvasEngine KeyboardControls instance to the dependency injection context
|
|
50
55
|
*
|
|
@@ -353,13 +358,38 @@ export declare class RpgClientEngine<T = any> {
|
|
|
353
358
|
* Add a component to render behind sprites
|
|
354
359
|
* Components added with this method will be displayed with a lower z-index than the sprite
|
|
355
360
|
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
361
|
+
* Supports multiple formats:
|
|
362
|
+
* 1. Direct component: `ShadowComponent`
|
|
363
|
+
* 2. Configuration object: `{ component: LightHalo, props: {...} }`
|
|
364
|
+
* 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`
|
|
365
|
+
* 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`
|
|
366
|
+
*
|
|
367
|
+
* Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).
|
|
368
|
+
* The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.
|
|
369
|
+
*
|
|
370
|
+
* @param component - The component to add behind sprites, or a configuration object
|
|
371
|
+
* @param component.component - The component function to render
|
|
372
|
+
* @param component.props - Static props object or function that receives the sprite object and returns props
|
|
373
|
+
* @param component.dependencies - Function that receives the sprite object and returns an array of Signals
|
|
374
|
+
* @returns The added component or configuration
|
|
358
375
|
*
|
|
359
376
|
* @example
|
|
360
377
|
* ```ts
|
|
361
378
|
* // Add a shadow component behind all sprites
|
|
362
379
|
* engine.addSpriteComponentBehind(ShadowComponent);
|
|
380
|
+
*
|
|
381
|
+
* // Add a component with static props
|
|
382
|
+
* engine.addSpriteComponentBehind({
|
|
383
|
+
* component: LightHalo,
|
|
384
|
+
* props: { radius: 30 }
|
|
385
|
+
* });
|
|
386
|
+
*
|
|
387
|
+
* // Add a component with dynamic props and dependencies
|
|
388
|
+
* engine.addSpriteComponentBehind({
|
|
389
|
+
* component: HealthBar,
|
|
390
|
+
* props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),
|
|
391
|
+
* dependencies: (object) => [object.hp, object.param.maxHp]
|
|
392
|
+
* });
|
|
363
393
|
* ```
|
|
364
394
|
*/
|
|
365
395
|
addSpriteComponentBehind(component: any): any;
|
|
@@ -367,16 +397,45 @@ export declare class RpgClientEngine<T = any> {
|
|
|
367
397
|
* Add a component to render in front of sprites
|
|
368
398
|
* Components added with this method will be displayed with a higher z-index than the sprite
|
|
369
399
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
400
|
+
* Supports multiple formats:
|
|
401
|
+
* 1. Direct component: `HealthBarComponent`
|
|
402
|
+
* 2. Configuration object: `{ component: StatusIndicator, props: {...} }`
|
|
403
|
+
* 3. With dynamic props: `{ component: HealthBar, props: (object) => {...} }`
|
|
404
|
+
* 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`
|
|
405
|
+
*
|
|
406
|
+
* Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).
|
|
407
|
+
* The object (sprite) is passed to the dependencies function to allow sprite-specific dependency resolution.
|
|
408
|
+
*
|
|
409
|
+
* @param component - The component to add in front of sprites, or a configuration object
|
|
410
|
+
* @param component.component - The component function to render
|
|
411
|
+
* @param component.props - Static props object or function that receives the sprite object and returns props
|
|
412
|
+
* @param component.dependencies - Function that receives the sprite object and returns an array of Signals
|
|
413
|
+
* @returns The added component or configuration
|
|
372
414
|
*
|
|
373
415
|
* @example
|
|
374
416
|
* ```ts
|
|
375
417
|
* // Add a health bar component in front of all sprites
|
|
376
418
|
* engine.addSpriteComponentInFront(HealthBarComponent);
|
|
419
|
+
*
|
|
420
|
+
* // Add a component with static props
|
|
421
|
+
* engine.addSpriteComponentInFront({
|
|
422
|
+
* component: StatusIndicator,
|
|
423
|
+
* props: { type: 'poison' }
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* // Add a component with dynamic props and dependencies
|
|
427
|
+
* engine.addSpriteComponentInFront({
|
|
428
|
+
* component: HealthBar,
|
|
429
|
+
* props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),
|
|
430
|
+
* dependencies: (object) => [object.hp, object.param.maxHp]
|
|
431
|
+
* });
|
|
377
432
|
* ```
|
|
378
433
|
*/
|
|
379
|
-
addSpriteComponentInFront(component: any
|
|
434
|
+
addSpriteComponentInFront(component: any | {
|
|
435
|
+
component: any;
|
|
436
|
+
props: (object: any) => any;
|
|
437
|
+
dependencies?: (object: any) => any[];
|
|
438
|
+
}): any;
|
|
380
439
|
/**
|
|
381
440
|
* Add a component animation to the engine
|
|
382
441
|
*
|
|
@@ -428,6 +487,27 @@ export declare class RpgClientEngine<T = any> {
|
|
|
428
487
|
* ```
|
|
429
488
|
*/
|
|
430
489
|
getComponentAnimation(id: string): AnimationManager;
|
|
490
|
+
/**
|
|
491
|
+
* Start a transition
|
|
492
|
+
*
|
|
493
|
+
* Convenience method to display a transition by its ID using the GUI system.
|
|
494
|
+
*
|
|
495
|
+
* @param id - The unique identifier of the transition to start
|
|
496
|
+
* @param props - Props to pass to the transition component
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* // Start a fade transition
|
|
501
|
+
* engine.startTransition('fade', { duration: 1000, color: 'black' });
|
|
502
|
+
*
|
|
503
|
+
* // Start with onFinish callback
|
|
504
|
+
* engine.startTransition('fade', {
|
|
505
|
+
* duration: 1000,
|
|
506
|
+
* onFinish: () => console.log('Fade complete')
|
|
507
|
+
* });
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
startTransition(id: string, props?: any): void;
|
|
431
511
|
processInput({ input }: {
|
|
432
512
|
input: Direction;
|
|
433
513
|
}): Promise<void>;
|
|
@@ -442,7 +522,33 @@ export declare class RpgClientEngine<T = any> {
|
|
|
442
522
|
private getLocalPlayerState;
|
|
443
523
|
private applyAuthoritativeState;
|
|
444
524
|
private initializePredictionController;
|
|
445
|
-
getCurrentPlayer(): import('
|
|
525
|
+
getCurrentPlayer(): import('.').RpgClientPlayer;
|
|
526
|
+
/**
|
|
527
|
+
* Setup RxJS observer to wait for all conditions before calling onAfterLoading hook
|
|
528
|
+
*
|
|
529
|
+
* This method uses RxJS `combineLatest` to wait for all conditions to be met,
|
|
530
|
+
* regardless of the order in which they arrive:
|
|
531
|
+
* 1. The map loading is completed (loadMapService.load is finished)
|
|
532
|
+
* 2. We received a player ID (pId)
|
|
533
|
+
* 3. Players array has at least one element
|
|
534
|
+
* 4. Events property is present in the sync data
|
|
535
|
+
*
|
|
536
|
+
* Once all conditions are met, it uses `switchMap` to call the onAfterLoading hook once.
|
|
537
|
+
*
|
|
538
|
+
* ## Design
|
|
539
|
+
*
|
|
540
|
+
* Uses BehaviorSubjects to track each condition state, allowing events to arrive
|
|
541
|
+
* in any order. The `combineLatest` operator waits until all observables emit `true`,
|
|
542
|
+
* then `take(1)` ensures the hook is called only once, and `switchMap` handles
|
|
543
|
+
* the hook execution.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```ts
|
|
547
|
+
* // Called automatically in loadScene to setup the observer
|
|
548
|
+
* this.setupOnAfterLoadingObserver();
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
private setupOnAfterLoadingObserver;
|
|
446
552
|
/**
|
|
447
553
|
* Clear client prediction states for cleanup
|
|
448
554
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './module';
|
|
|
9
9
|
export * from './Gui/Gui';
|
|
10
10
|
export * from './components/gui';
|
|
11
11
|
export * from './components/animations';
|
|
12
|
+
export * from './components/prebuilt';
|
|
12
13
|
export * from './presets';
|
|
13
14
|
export * from './components';
|
|
14
15
|
export * from './components/gui';
|
|
@@ -17,3 +18,7 @@ export * from './Resource';
|
|
|
17
18
|
export { Context } from '@signe/di';
|
|
18
19
|
export { KeyboardControls, Input } from 'canvasengine';
|
|
19
20
|
export { Control } from './services/keyboardControls';
|
|
21
|
+
export { RpgClientObject } from './Game/Object';
|
|
22
|
+
export { RpgClientPlayer } from './Game/Player';
|
|
23
|
+
export { RpgClientEvent } from './Game/Event';
|
|
24
|
+
export { withMobile } from './components/gui/mobile';
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,18 @@ export { RpgGui } from './index9.js';
|
|
|
9
9
|
export { default as DialogboxComponent } from './index10.js';
|
|
10
10
|
export { default as BoxComponent } from './index11.js';
|
|
11
11
|
export { PrebuiltComponentAnimations } from './index12.js';
|
|
12
|
-
export {
|
|
13
|
-
export { default as
|
|
14
|
-
export {
|
|
15
|
-
export { default as
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
12
|
+
export { default as HpBar } from './index13.js';
|
|
13
|
+
export { default as LightHalo } from './index14.js';
|
|
14
|
+
export { Presets } from './index15.js';
|
|
15
|
+
export { default as EventLayerComponent } from './index16.js';
|
|
16
|
+
export { default as CharacterComponent } from './index17.js';
|
|
17
|
+
export { RpgSound, Sound, getSoundMetadata } from './index18.js';
|
|
18
|
+
export { RpgResource } from './index19.js';
|
|
19
|
+
export { Context } from './index20.js';
|
|
19
20
|
export { Input, KeyboardControls } from 'canvasengine';
|
|
20
|
-
export { Control } from './
|
|
21
|
+
export { Control } from './index21.js';
|
|
22
|
+
export { RpgClientObject } from './index22.js';
|
|
23
|
+
export { RpgClientPlayer } from './index23.js';
|
|
24
|
+
export { RpgClientEvent } from './index24.js';
|
|
25
|
+
export { withMobile } from './index25.js';
|
|
21
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index10.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text, Sprite } from 'canvasengine';
|
|
2
|
-
import component$1 from './
|
|
2
|
+
import component$1 from './index48.js';
|
|
3
3
|
import { inject } from './index6.js';
|
|
4
4
|
import { RpgClientEngine } from './index2.js';
|
|
5
5
|
|
package/dist/index11.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useProps, useDefineProps, computed, h, Container, Rect } from 'canvasengine';
|
|
2
2
|
import { RpgClientEngine } from './index2.js';
|
|
3
|
-
import './
|
|
3
|
+
import './index31.js';
|
|
4
4
|
import '@rpgjs/common';
|
|
5
|
-
import './
|
|
5
|
+
import './index20.js';
|
|
6
6
|
import { inject } from './index6.js';
|
|
7
7
|
import 'rxjs';
|
|
8
|
-
import './
|
|
9
|
-
import './index17.js';
|
|
10
|
-
import '@canvasengine/presets';
|
|
8
|
+
import './index32.js';
|
|
11
9
|
import './index18.js';
|
|
10
|
+
import 'pixi.js';
|
|
11
|
+
import '@canvasengine/presets';
|
|
12
|
+
import './index19.js';
|
|
12
13
|
|
|
13
14
|
function component($$props) {
|
|
14
15
|
useProps($$props);
|
package/dist/index11.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index11.js","sources":["../src/components/gui/box.ce"],"sourcesContent":["<Container positionType=\"absolute\" top={top} left={left}>\n <Container\n anchor={[0.5, 0.5]}\n >\n <Rect width height color={_color} />\n <Container attach={child}></Container>\n </Container> \n</Container>\n\n<script>\n import { RpgClientEngine, inject } from \"../../index\";\n\n const { width, height, children, color, top, left } = defineProps();\n const engine = inject(RpgClientEngine)\n const child = children[0]\n const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || \"#1a1a2e\")\n</script>"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index11.js","sources":["../src/components/gui/box.ce"],"sourcesContent":["<Container positionType=\"absolute\" top={top} left={left}>\n <Container\n anchor={[0.5, 0.5]}\n >\n <Rect width height color={_color} />\n <Container attach={child}></Container>\n </Container> \n</Container>\n\n<script>\n import { RpgClientEngine, inject } from \"../../index\";\n\n const { width, height, children, color, top, left } = defineProps();\n const engine = inject(RpgClientEngine)\n const child = children[0]\n const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || \"#1a1a2e\")\n</script>"],"names":[],"mappings":";;;;;;;;;;;;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI;AAC5I,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvB,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,WAAW,MAAM,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC;AAClN,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACvM,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index12.js
CHANGED
package/dist/index13.js
CHANGED
|
@@ -1,14 +1,106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LPCSpritesheetPreset } from './index31.js';
|
|
3
|
-
import { RMSpritesheet } from './index32.js';
|
|
4
|
-
import { FacesetPreset } from './index33.js';
|
|
1
|
+
import { useProps, useDefineProps, computed, animatedSignal, effect, h, Container, Graphics } from 'canvasengine';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
function component($$props) {
|
|
4
|
+
useProps($$props);
|
|
5
|
+
const defineProps = useDefineProps($$props);
|
|
6
|
+
var object = defineProps().object;
|
|
7
|
+
var barWidth = 50;
|
|
8
|
+
var barHeight = 8;
|
|
9
|
+
var borderRadius = 4;
|
|
10
|
+
var innerRadius = 3;
|
|
11
|
+
var padding = 1;
|
|
12
|
+
var bgColor = 0x16213e;
|
|
13
|
+
var shadowColor = 0x000000;
|
|
14
|
+
var borderColor = 0x4a5568;
|
|
15
|
+
var maxFillWidth = barWidth - (padding * 2);
|
|
16
|
+
var fillHeight = barHeight - (padding * 2);
|
|
17
|
+
var highlightHeight = Math.floor(fillHeight / 2);
|
|
18
|
+
var hitbox = object.hitbox;
|
|
19
|
+
var currentHp = computed(function () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = object.hpSignal) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : 0;
|
|
22
|
+
});
|
|
23
|
+
var maxHp = computed(function () {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
var params = (_b = (_a = object._param) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : {};
|
|
26
|
+
return (_c = params.maxHp) !== null && _c !== void 0 ? _c : 100;
|
|
27
|
+
});
|
|
28
|
+
var hpPercent = computed(function () {
|
|
29
|
+
var max = maxHp();
|
|
30
|
+
if (max <= 0)
|
|
31
|
+
return 0;
|
|
32
|
+
var percent = currentHp() / max;
|
|
33
|
+
return Math.max(0, Math.min(1, percent));
|
|
34
|
+
});
|
|
35
|
+
var animatedPercent = animatedSignal(hpPercent(), {
|
|
36
|
+
duration: 300,
|
|
37
|
+
easing: 'easeOutCubic'
|
|
38
|
+
});
|
|
39
|
+
effect(function () {
|
|
40
|
+
var newPercent = hpPercent();
|
|
41
|
+
animatedPercent.set(newPercent);
|
|
42
|
+
});
|
|
43
|
+
var position = computed(function () { return ({
|
|
44
|
+
x: (hitbox().w / 2) - (barWidth / 2),
|
|
45
|
+
y: -barHeight - 8
|
|
46
|
+
}); });
|
|
47
|
+
var fillWidth = computed(function () {
|
|
48
|
+
var percent = animatedPercent();
|
|
49
|
+
var width = maxFillWidth * percent;
|
|
50
|
+
// Ensure minimum visible width when HP > 0
|
|
51
|
+
if (percent > 0 && width < innerRadius * 2) {
|
|
52
|
+
return innerRadius * 2;
|
|
53
|
+
}
|
|
54
|
+
return Math.max(0, width);
|
|
55
|
+
});
|
|
56
|
+
var hpColorHex = computed(function () {
|
|
57
|
+
var percent = hpPercent();
|
|
58
|
+
if (percent > 0.6) {
|
|
59
|
+
return 0x4ade80; // Green - healthy
|
|
60
|
+
}
|
|
61
|
+
else if (percent > 0.3) {
|
|
62
|
+
return 0xfacc15; // Yellow - caution
|
|
63
|
+
}
|
|
64
|
+
else if (percent > 0.15) {
|
|
65
|
+
return 0xfb923c; // Orange - danger
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return 0xef4444; // Red - critical
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var drawShadow = function (g) {
|
|
72
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
73
|
+
g.fill({ color: shadowColor, alpha: 0.3 });
|
|
11
74
|
};
|
|
75
|
+
var drawBackground = function (g) {
|
|
76
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
77
|
+
g.fill({ color: bgColor, alpha: 0.9 });
|
|
78
|
+
};
|
|
79
|
+
var drawFill = function (g) {
|
|
80
|
+
var width = fillWidth();
|
|
81
|
+
if (width > 0) {
|
|
82
|
+
g.roundRect(padding, padding, width, fillHeight, innerRadius);
|
|
83
|
+
g.fill({ color: hpColorHex() });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var drawHighlight = function (g) {
|
|
87
|
+
var width = fillWidth();
|
|
88
|
+
if (width > 0) {
|
|
89
|
+
g.roundRect(padding, padding, width, highlightHeight, innerRadius);
|
|
90
|
+
g.fill({ color: 0xffffff, alpha: 0.25 });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var drawBorder = function (g) {
|
|
94
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
95
|
+
g.stroke({
|
|
96
|
+
color: borderColor,
|
|
97
|
+
width: 1,
|
|
98
|
+
alpha: 0.7
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
let $this = [,h(Container, { x: computed(() => position().x), y: computed(() => position().y) }, [h(Graphics, { draw: drawShadow, x: 1, y: 1 }), h(Graphics, { draw: drawBackground }), h(Graphics, { draw: drawFill }), h(Graphics, { draw: drawHighlight }), h(Graphics, { draw: drawBorder })])];
|
|
102
|
+
return $this
|
|
103
|
+
}
|
|
12
104
|
|
|
13
|
-
export {
|
|
105
|
+
export { component as default };
|
|
14
106
|
//# sourceMappingURL=index13.js.map
|
package/dist/index13.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index13.js","sources":["../src/presets/index.ts"],"sourcesContent":["import { AnimationSpritesheetPreset } from \"./animation\";\nimport { LPCSpritesheetPreset } from \"./lpc\";\nimport { RMSpritesheet } from \"./rmspritesheet\";\nimport { FacesetPreset } from \"./faceset\";\n\nexport const Presets = {\n RMSpritesheet,\n LPCSpritesheetPreset,\n AnimationSpritesheetPreset,\n FacesetPreset\n}"],"names":[],"mappings":";;;;;AAKO,MAAM,OAAA,GAAU;AAAA,EACnB,aAAA;AAAA,EACA,oBAAA;AAAA,EACA,0BAAA;AAAA,EACA;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index13.js","sources":["../src/components/prebuilt/hp-bar.ce"],"sourcesContent":["<!-- \n HP Bar Component\n \n A beautiful, animated health bar component for displaying player HP above sprites.\n Features a gradient color based on HP level, smooth animations, and modern styling.\n \n ## Design\n \n The bar changes color dynamically based on HP percentage:\n - Green (#4ade80) when HP > 60% - Healthy state\n - Yellow (#facc15) when HP 30-60% - Caution state \n - Orange (#fb923c) when HP 15-30% - Danger state\n - Red (#ef4444) when HP < 15% - Critical state\n \n @example\n ```ts\n import HpBar from './hp-bar.ce';\n \n // In module configuration\n export default defineModule<RpgClient>({\n sprite: {\n componentsInFront: [HpBar]\n }\n })\n ```\n-->\n\n<Container x={position.@x} y={position.@y}>\n <!-- Background shadow for depth effect -->\n <Graphics draw={drawShadow} x={1} y={1} />\n \n <!-- Main background -->\n <Graphics draw={drawBackground} />\n \n <!-- HP fill bar -->\n <Graphics draw={drawFill} />\n \n <!-- Highlight overlay for 3D effect -->\n <Graphics draw={drawHighlight} />\n \n <!-- Border frame -->\n <Graphics draw={drawBorder} />\n</Container>\n\n<script>\nimport { computed, animatedSignal, effect } from \"canvasengine\";\n\nconst { object } = defineProps();\n\n// ====================\n// Configuration\n// ====================\n\n/** Total width of the HP bar in pixels */\nconst barWidth = 50;\n\n/** Total height of the HP bar in pixels */\nconst barHeight = 8;\n\n/** Border radius for rounded corners */\nconst borderRadius = 4;\n\n/** Inner border radius for the fill bar */\nconst innerRadius = 3;\n\n/** Padding between background and fill */\nconst padding = 1;\n\n/** Background color (dark theme) */\nconst bgColor = 0x16213e;\n\n/** Shadow color */\nconst shadowColor = 0x000000;\n\n/** Border color */\nconst borderColor = 0x4a5568;\n\n// ====================\n// Calculated dimensions\n// ====================\n\n/** Maximum fill width */\nconst maxFillWidth = barWidth - (padding * 2);\n\n/** Fill height */\nconst fillHeight = barHeight - (padding * 2);\n\n/** Highlight height (half of fill) */\nconst highlightHeight = Math.floor(fillHeight / 2);\n\n// ====================\n// Reactive HP values\n// ====================\n\n/** Gets hitbox dimensions for positioning */\nconst hitbox = object.hitbox;\n\n/**\n * Gets the current HP value from the player object\n * Uses hpSignal which is synchronized from the server\n */\nconst currentHp = computed(() => {\n return object.hpSignal?.() ?? 0;\n});\n\n/**\n * Gets the maximum HP value from player parameters\n * Reads from _param.maxHp which contains calculated stats\n */\nconst maxHp = computed(() => {\n const params = object._param?.() ?? {};\n return params.maxHp ?? 100;\n});\n\n/**\n * Calculates HP percentage (0 to 1)\n */\nconst hpPercent = computed(() => {\n const max = maxHp();\n if (max <= 0) return 0;\n const percent = currentHp() / max;\n return Math.max(0, Math.min(1, percent));\n});\n\n// ====================\n// Animated values\n// ====================\n\n/**\n * Animated percentage for smooth bar transitions\n */\nconst animatedPercent = animatedSignal(hpPercent(), {\n duration: 300,\n easing: 'easeOutCubic'\n});\n\n// Update animated value when HP changes\neffect(() => {\n const newPercent = hpPercent();\n animatedPercent.set(newPercent);\n});\n\n// ====================\n// Visual calculations\n// ====================\n\n/**\n * Position of the bar relative to the sprite\n */\nconst position = computed(() => ({\n x: (hitbox().w / 2) - (barWidth / 2),\n y: -barHeight - 8\n}));\n\n/**\n * Current width of the HP fill based on animated percentage\n */\nconst fillWidth = computed(() => {\n const percent = animatedPercent();\n const width = maxFillWidth * percent;\n // Ensure minimum visible width when HP > 0\n if (percent > 0 && width < innerRadius * 2) {\n return innerRadius * 2;\n }\n return Math.max(0, width);\n});\n\n/**\n * Determines HP bar color based on current HP percentage\n * Returns hex color number for PixiJS\n * \n * ## Color Thresholds\n * - Green (0x4ade80): HP > 60% - Healthy\n * - Yellow (0xfacc15): HP 30-60% - Caution\n * - Orange (0xfb923c): HP 15-30% - Danger\n * - Red (0xef4444): HP < 15% - Critical\n */\nconst hpColorHex = computed(() => {\n const percent = hpPercent();\n \n if (percent > 0.6) {\n return 0x4ade80; // Green - healthy\n } else if (percent > 0.3) {\n return 0xfacc15; // Yellow - caution\n } else if (percent > 0.15) {\n return 0xfb923c; // Orange - danger\n } else {\n return 0xef4444; // Red - critical\n }\n});\n\n// ====================\n// Drawing functions\n// ====================\n\n/**\n * Draws the shadow behind the HP bar for depth effect\n */\nconst drawShadow = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: shadowColor, alpha: 0.3 });\n};\n\n/**\n * Draws the main background of the HP bar\n */\nconst drawBackground = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: bgColor, alpha: 0.9 });\n};\n\n/**\n * Draws the HP fill bar with dynamic color\n */\nconst drawFill = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, fillHeight, innerRadius);\n g.fill({ color: hpColorHex() });\n }\n};\n\n/**\n * Draws the highlight overlay for 3D effect\n */\nconst drawHighlight = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, highlightHeight, innerRadius);\n g.fill({ color: 0xffffff, alpha: 0.25 });\n }\n};\n\n/**\n * Draws the border frame around the HP bar\n * \n * Uses PixiJS Graphics API to create a rounded rectangle stroke\n * that serves as a visual border for the bar.\n * \n * @param g - PixiJS Graphics object\n * \n * @example\n * ```html\n * <Graphics draw={drawBorder} />\n * ```\n */\nconst drawBorder = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.stroke({ \n color: borderColor, \n width: 1,\n alpha: 0.7\n });\n};\n</script>\n"],"names":[],"mappings":";;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,WAAW,EAAE,CAAC,MAAM;AACzC,IAAI,QAAQ,GAAG,EAAE;AACjB,IAAI,SAAS,GAAG,CAAC;AACjB,IAAI,YAAY,GAAG,CAAC;AACpB,IAAI,WAAW,GAAG,CAAC;AACnB,IAAI,OAAO,GAAG,CAAC;AACf,IAAI,OAAO,GAAG,QAAQ;AACtB,IAAI,WAAW,GAAG,QAAQ;AAC1B,IAAI,WAAW,GAAG,QAAQ;AAC1B,IAAI,YAAY,GAAG,QAAQ,IAAI,OAAO,GAAG,CAAC,CAAC;AAC3C,IAAI,UAAU,GAAG,SAAS,IAAI,OAAO,GAAG,CAAC,CAAC;AAC1C,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;AAChD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM;AAC1B,IAAI,SAAS,GAAG,QAAQ,CAAC,YAAY;AACrC,IAAI,IAAI,EAAE,EAAE,EAAE;AACd,IAAI,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC;AAChI,CAAC,CAAC;AACF,IAAI,KAAK,GAAG,QAAQ,CAAC,YAAY;AACjC,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;A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C,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;AAC1S,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index14.js
CHANGED
|
@@ -1,16 +1,74 @@
|
|
|
1
|
-
import { useProps, useDefineProps, h, Container,
|
|
2
|
-
import {
|
|
3
|
-
import { RpgClientEngine } from './index2.js';
|
|
4
|
-
import component$1 from './index15.js';
|
|
1
|
+
import { useProps, useDefineProps, computed, signal, tick, h, Container, Graphics } from 'canvasengine';
|
|
2
|
+
import { BlurFilter } from 'pixi.js';
|
|
5
3
|
|
|
6
4
|
function component($$props) {
|
|
7
5
|
useProps($$props);
|
|
8
6
|
const defineProps = useDefineProps($$props);
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
7
|
+
var _a = defineProps(), object = _a.object, baseRadius = _a.baseRadius, radiusVariation = _a.radiusVariation, baseOpacity = _a.baseOpacity, opacityVariation = _a.opacityVariation, sizeSpeed = _a.sizeSpeed, opacitySpeed = _a.opacitySpeed, lightColor = _a.lightColor;
|
|
8
|
+
var getBaseRadius = computed(function () { var _a; return (_a = baseRadius === null || baseRadius === void 0 ? void 0 : baseRadius()) !== null && _a !== void 0 ? _a : 30; });
|
|
9
|
+
var getRadiusVariation = computed(function () { var _a; return (_a = radiusVariation === null || radiusVariation === void 0 ? void 0 : radiusVariation()) !== null && _a !== void 0 ? _a : 10; });
|
|
10
|
+
var getBaseOpacity = computed(function () { var _a; return (_a = baseOpacity === null || baseOpacity === void 0 ? void 0 : baseOpacity()) !== null && _a !== void 0 ? _a : 0.6; });
|
|
11
|
+
var getOpacityVariation = computed(function () { var _a; return (_a = opacityVariation === null || opacityVariation === void 0 ? void 0 : opacityVariation()) !== null && _a !== void 0 ? _a : 0.3; });
|
|
12
|
+
var getSizeSpeed = computed(function () { var _a; return (_a = sizeSpeed === null || sizeSpeed === void 0 ? void 0 : sizeSpeed()) !== null && _a !== void 0 ? _a : 0.002; });
|
|
13
|
+
var getOpacitySpeed = computed(function () { var _a; return (_a = opacitySpeed === null || opacitySpeed === void 0 ? void 0 : opacitySpeed()) !== null && _a !== void 0 ? _a : 0.003; });
|
|
14
|
+
var getLightColor = computed(function () { var _a; return (_a = lightColor === null || lightColor === void 0 ? void 0 : lightColor()) !== null && _a !== void 0 ? _a : 0xffffaa; });
|
|
15
|
+
var time = signal(0);
|
|
16
|
+
var currentRadius = computed(function () {
|
|
17
|
+
var t = time();
|
|
18
|
+
var base = getBaseRadius();
|
|
19
|
+
var variation = getRadiusVariation();
|
|
20
|
+
var speed = getSizeSpeed();
|
|
21
|
+
// Combine two sine waves for less predictable pulsing
|
|
22
|
+
var pulse1 = Math.sin(t * speed);
|
|
23
|
+
var pulse2 = Math.sin(t * speed * 1.5) * 0.5;
|
|
24
|
+
var combinedPulse = (pulse1 + pulse2) / 1.5;
|
|
25
|
+
return base + (combinedPulse * variation);
|
|
26
|
+
});
|
|
27
|
+
var currentOpacity = computed(function () {
|
|
28
|
+
var t = time();
|
|
29
|
+
var base = getBaseOpacity();
|
|
30
|
+
var variation = getOpacityVariation();
|
|
31
|
+
var speed = getOpacitySpeed();
|
|
32
|
+
// Main breathing cycle
|
|
33
|
+
var fade = Math.sin(t * speed);
|
|
34
|
+
// Subtle high-frequency flicker (candle-like)
|
|
35
|
+
var flicker = (Math.random() - 0.5) * 0.1;
|
|
36
|
+
return Math.max(0, Math.min(1, base + (fade * variation) + flicker));
|
|
37
|
+
});
|
|
38
|
+
var hitbox = object.hitbox;
|
|
39
|
+
var position = computed(function () { return ({
|
|
40
|
+
x: hitbox().w / 2,
|
|
41
|
+
y: hitbox().h / 2
|
|
42
|
+
}); });
|
|
43
|
+
var blurFilter = new BlurFilter({ strength: 20, quality: 3 });
|
|
44
|
+
var drawHalo = function (g) {
|
|
45
|
+
var radius = currentRadius();
|
|
46
|
+
var opacity = currentOpacity();
|
|
47
|
+
var color = getLightColor();
|
|
48
|
+
if (opacity <= 0 || radius <= 0)
|
|
49
|
+
return;
|
|
50
|
+
// Set blend mode to ADD for glowing light effect
|
|
51
|
+
g.blendMode = 'add';
|
|
52
|
+
// Apply blur filter for soft light diffusion
|
|
53
|
+
g.filters = [blurFilter];
|
|
54
|
+
// Draw main light source
|
|
55
|
+
// The blur filter will spread this out into a nice gradient
|
|
56
|
+
g.circle(0, 0, radius);
|
|
57
|
+
g.fill({
|
|
58
|
+
color: color,
|
|
59
|
+
alpha: opacity
|
|
60
|
+
});
|
|
61
|
+
// Draw a smaller, brighter core
|
|
62
|
+
g.circle(0, 0, radius * 0.4);
|
|
63
|
+
g.fill({
|
|
64
|
+
color: 0xffffff,
|
|
65
|
+
alpha: opacity * 0.5
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
tick(function () {
|
|
69
|
+
time.update(function (t) { return t + 1; });
|
|
70
|
+
});
|
|
71
|
+
let $this = h(Container, { x: computed(() => position().x), y: computed(() => position().y) }, h(Graphics, { draw: drawHalo }));
|
|
14
72
|
return $this
|
|
15
73
|
}
|
|
16
74
|
|
package/dist/index14.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index14.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"index14.js","sources":["../src/components/prebuilt/light-halo.ce"],"sourcesContent":["<Container x={position.@x} y={position.@y}>\n <Graphics draw={drawHalo} />\n</Container>\n\n<script>\nimport { computed, signal, tick, mount } from \"canvasengine\";\nimport { BlurFilter } from \"pixi.js\";\n\n/**\n * Component props for LightHalo\n * \n * All props are signals (even static ones) and must be read with `()`.\n * Props are optional and will use default values if not provided.\n * \n * @property {Object} object - The sprite object (required)\n * @property {number|Signal<number>} [baseRadius] - Base radius of the light halo in pixels (default: 30)\n * @property {number|Signal<number>} [radiusVariation] - Radius variation range (halo will pulse between baseRadius ± radiusVariation) (default: 10)\n * @property {number|Signal<number>} [baseOpacity] - Base opacity of the light halo (0 to 1) (default: 0.6)\n * @property {number|Signal<number>} [opacityVariation] - Opacity variation range (halo will fade between baseOpacity ± opacityVariation) (default: 0.3)\n * @property {number|Signal<number>} [sizeSpeed] - Animation speed for size pulsing (higher = faster) (default: 0.002)\n * @property {number|Signal<number>} [opacitySpeed] - Animation speed for opacity fading (higher = faster) (default: 0.003)\n * @property {number|Signal<number>} [lightColor] - Color of the light halo (hex value, warm yellow-white by default: 0xffffaa)\n */\nconst { \n object, \n baseRadius,\n radiusVariation,\n baseOpacity,\n opacityVariation,\n sizeSpeed,\n opacitySpeed,\n lightColor\n} = defineProps();\n\n// ====================\n// Props with default values\n// ====================\n\nconst getBaseRadius = computed(() => baseRadius?.() ?? 30);\nconst getRadiusVariation = computed(() => radiusVariation?.() ?? 10);\nconst getBaseOpacity = computed(() => baseOpacity?.() ?? 0.6);\nconst getOpacityVariation = computed(() => opacityVariation?.() ?? 0.3);\nconst getSizeSpeed = computed(() => sizeSpeed?.() ?? 0.002);\nconst getOpacitySpeed = computed(() => opacitySpeed?.() ?? 0.003);\nconst getLightColor = computed(() => lightColor?.() ?? 0xffffaa);\n\n// ====================\n// Animation state\n// ====================\n\n/** Time counter for animations */\nconst time = signal(0);\n\n/**\n * Current radius of the halo with pulsing animation\n * Uses multiple sine waves for more organic movement\n */\nconst currentRadius = computed(() => {\n const t = time();\n const base = getBaseRadius();\n const variation = getRadiusVariation();\n const speed = getSizeSpeed();\n \n // Combine two sine waves for less predictable pulsing\n const pulse1 = Math.sin(t * speed);\n const pulse2 = Math.sin(t * speed * 1.5) * 0.5;\n const combinedPulse = (pulse1 + pulse2) / 1.5;\n \n return base + (combinedPulse * variation);\n});\n\n/**\n * Current opacity of the halo with fading animation\n * Includes a subtle flicker effect\n */\nconst currentOpacity = computed(() => {\n const t = time();\n const base = getBaseOpacity();\n const variation = getOpacityVariation();\n const speed = getOpacitySpeed();\n \n // Main breathing cycle\n const fade = Math.sin(t * speed);\n \n // Subtle high-frequency flicker (candle-like)\n const flicker = (Math.random() - 0.5) * 0.1;\n \n return Math.max(0, Math.min(1, base + (fade * variation) + flicker));\n});\n\n// ====================\n// Position calculations\n// ====================\n\nconst hitbox = object.hitbox;\n\nconst position = computed(() => ({\n x: hitbox().w / 2,\n y: hitbox().h / 2\n}));\n\n// ====================\n// Drawing function\n// ====================\n\n// Create filters once to avoid recreation on every frame\nconst blurFilter = new BlurFilter({ strength: 20, quality: 3 });\n\n/**\n * Draws the light halo effect with realistic diffusion\n */\nconst drawHalo = (g) => {\n const radius = currentRadius();\n const opacity = currentOpacity();\n const color = getLightColor();\n \n if (opacity <= 0 || radius <= 0) return;\n\n // Set blend mode to ADD for glowing light effect\n g.blendMode = 'add';\n \n // Apply blur filter for soft light diffusion\n g.filters = [blurFilter];\n \n // Draw main light source\n // The blur filter will spread this out into a nice gradient\n g.circle(0, 0, radius);\n g.fill({ \n color: color, \n alpha: opacity \n });\n \n // Draw a smaller, brighter core\n g.circle(0, 0, radius * 0.4);\n g.fill({ \n color: 0xffffff, \n alpha: opacity * 0.5 \n });\n};\n\n// ====================\n// Animation loop\n// ====================\ntick(() => {\n time.update(t => t + 1);\n});\n</script>\n\n"],"names":[],"mappings":";;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU,EAAE,eAAe,GAAG,EAAE,CAA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