@rpgjs/client 5.0.0-alpha.43 → 5.0.0-alpha.44

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 (137) hide show
  1. package/dist/Game/AnimationManager.js +25 -24
  2. package/dist/Game/AnimationManager.js.map +1 -1
  3. package/dist/Game/Event.js +11 -10
  4. package/dist/Game/Event.js.map +1 -1
  5. package/dist/Game/Map.js +78 -94
  6. package/dist/Game/Map.js.map +1 -1
  7. package/dist/Game/Object.js +182 -216
  8. package/dist/Game/Object.js.map +1 -1
  9. package/dist/Game/Player.js +11 -10
  10. package/dist/Game/Player.js.map +1 -1
  11. package/dist/Gui/Gui.js +440 -473
  12. package/dist/Gui/Gui.js.map +1 -1
  13. package/dist/Gui/NotificationManager.js +48 -50
  14. package/dist/Gui/NotificationManager.js.map +1 -1
  15. package/dist/Resource.js +132 -113
  16. package/dist/Resource.js.map +1 -1
  17. package/dist/RpgClientEngine.js +1333 -1486
  18. package/dist/RpgClientEngine.js.map +1 -1
  19. package/dist/Sound.js +162 -92
  20. package/dist/Sound.js.map +1 -1
  21. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.js +9 -0
  22. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.js +6 -0
  23. package/dist/components/animations/animation.ce.js +22 -19
  24. package/dist/components/animations/animation.ce.js.map +1 -1
  25. package/dist/components/animations/hit.ce.js +67 -68
  26. package/dist/components/animations/hit.ce.js.map +1 -1
  27. package/dist/components/animations/index.js +9 -8
  28. package/dist/components/animations/index.js.map +1 -1
  29. package/dist/components/character.ce.js +390 -314
  30. package/dist/components/character.ce.js.map +1 -1
  31. package/dist/components/dynamics/parse-value.js +42 -52
  32. package/dist/components/dynamics/parse-value.js.map +1 -1
  33. package/dist/components/dynamics/text.ce.js +71 -139
  34. package/dist/components/dynamics/text.ce.js.map +1 -1
  35. package/dist/components/gui/box.ce.js +26 -25
  36. package/dist/components/gui/box.ce.js.map +1 -1
  37. package/dist/components/gui/dialogbox/index.ce.js +202 -149
  38. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  39. package/dist/components/gui/gameover.ce.js +190 -138
  40. package/dist/components/gui/gameover.ce.js.map +1 -1
  41. package/dist/components/gui/hud/hud.ce.js +90 -33
  42. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  43. package/dist/components/gui/index.js +14 -0
  44. package/dist/components/gui/menu/equip-menu.ce.js +478 -346
  45. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  46. package/dist/components/gui/menu/exit-menu.ce.js +52 -33
  47. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  48. package/dist/components/gui/menu/items-menu.ce.js +341 -226
  49. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  50. package/dist/components/gui/menu/main-menu.ce.js +414 -205
  51. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  52. package/dist/components/gui/menu/options-menu.ce.js +46 -26
  53. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  54. package/dist/components/gui/menu/skills-menu.ce.js +104 -50
  55. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  56. package/dist/components/gui/mobile/index.js +18 -21
  57. package/dist/components/gui/mobile/index.js.map +1 -1
  58. package/dist/components/gui/mobile/mobile.ce.js +76 -15
  59. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  60. package/dist/components/gui/notification/notification.ce.js +62 -36
  61. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  62. package/dist/components/gui/save-load.ce.js +386 -239
  63. package/dist/components/gui/save-load.ce.js.map +1 -1
  64. package/dist/components/gui/shop/shop.ce.js +649 -319
  65. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  66. package/dist/components/gui/title-screen.ce.js +187 -145
  67. package/dist/components/gui/title-screen.ce.js.map +1 -1
  68. package/dist/components/index.js +4 -0
  69. package/dist/components/prebuilt/hp-bar.ce.js +114 -104
  70. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  71. package/dist/components/prebuilt/index.js +2 -0
  72. package/dist/components/prebuilt/light-halo.ce.js +92 -74
  73. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  74. package/dist/components/scenes/canvas.ce.js +58 -42
  75. package/dist/components/scenes/canvas.ce.js.map +1 -1
  76. package/dist/components/scenes/draw-map.ce.js +87 -64
  77. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  78. package/dist/components/scenes/event-layer.ce.js +26 -16
  79. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  80. package/dist/core/inject.js +11 -10
  81. package/dist/core/inject.js.map +1 -1
  82. package/dist/core/setup.js +13 -13
  83. package/dist/core/setup.js.map +1 -1
  84. package/dist/index.js +44 -41
  85. package/dist/module.js +169 -168
  86. package/dist/module.js.map +1 -1
  87. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js +209 -298
  88. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js.map +1 -1
  89. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +430 -507
  90. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -1
  91. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js +2062 -2571
  92. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js.map +1 -1
  93. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +8 -3
  94. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -1
  95. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js +78 -101
  96. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map +1 -1
  97. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js +264 -401
  98. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js.map +1 -1
  99. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +9 -7
  100. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -1
  101. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +106 -165
  102. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  103. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +361 -461
  104. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  105. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  106. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3633 -4280
  107. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  108. package/dist/presets/animation.js +37 -25
  109. package/dist/presets/animation.js.map +1 -1
  110. package/dist/presets/faceset.js +49 -22
  111. package/dist/presets/faceset.js.map +1 -1
  112. package/dist/presets/icon.js +13 -13
  113. package/dist/presets/icon.js.map +1 -1
  114. package/dist/presets/index.js +15 -14
  115. package/dist/presets/index.js.map +1 -1
  116. package/dist/presets/lpc.js +96 -93
  117. package/dist/presets/lpc.js.map +1 -1
  118. package/dist/presets/rmspritesheet.js +40 -39
  119. package/dist/presets/rmspritesheet.js.map +1 -1
  120. package/dist/services/AbstractSocket.js +10 -8
  121. package/dist/services/AbstractSocket.js.map +1 -1
  122. package/dist/services/keyboardControls.js +20 -18
  123. package/dist/services/keyboardControls.js.map +1 -1
  124. package/dist/services/loadMap.js +120 -36
  125. package/dist/services/loadMap.js.map +1 -1
  126. package/dist/services/mmorpg.js +128 -136
  127. package/dist/services/mmorpg.js.map +1 -1
  128. package/dist/services/save.js +74 -66
  129. package/dist/services/save.js.map +1 -1
  130. package/dist/services/standalone.js +165 -167
  131. package/dist/services/standalone.js.map +1 -1
  132. package/dist/utils/getEntityProp.js +49 -51
  133. package/dist/utils/getEntityProp.js.map +1 -1
  134. package/package.json +8 -8
  135. package/src/components/character.ce +1 -1
  136. package/src/components/scenes/draw-map.ce +3 -1
  137. package/dist/index.js.map +0 -1
@@ -1,106 +1,116 @@
1
- import { useProps, useDefineProps, computed, animatedSignal, effect, h, Container, Graphics } from 'canvasengine';
2
-
1
+ import { Container, Graphics, animatedSignal, computed, effect, h, useDefineProps, useProps } from "canvasengine";
2
+ //#region src/components/prebuilt/hp-bar.ce
3
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 });
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: position.x, y: 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
- }
104
-
4
+ useProps($$props);
5
+ var object = useDefineProps($$props)().object;
6
+ var barWidth = 50;
7
+ var barHeight = 8;
8
+ var borderRadius = 4;
9
+ var innerRadius = 3;
10
+ var padding = 1;
11
+ var bgColor = 1450302;
12
+ var shadowColor = 0;
13
+ var borderColor = 4871528;
14
+ var maxFillWidth = barWidth - padding * 2;
15
+ var fillHeight = barHeight - padding * 2;
16
+ var highlightHeight = Math.floor(fillHeight / 2);
17
+ var hitbox = object.hitbox;
18
+ var currentHp = computed(function() {
19
+ var _a, _b;
20
+ return (_b = (_a = object.hpSignal) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : 0;
21
+ });
22
+ var maxHp = computed(function() {
23
+ var _a, _b, _c;
24
+ return (_c = ((_b = (_a = object._param) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : {}).maxHp) !== null && _c !== void 0 ? _c : 100;
25
+ });
26
+ var hpPercent = computed(function() {
27
+ var max = maxHp();
28
+ if (max <= 0) return 0;
29
+ var percent = currentHp() / max;
30
+ return Math.max(0, Math.min(1, percent));
31
+ });
32
+ var animatedPercent = animatedSignal(hpPercent(), {
33
+ duration: 300,
34
+ easing: "easeOutCubic"
35
+ });
36
+ effect(function() {
37
+ var newPercent = hpPercent();
38
+ animatedPercent.set(newPercent);
39
+ });
40
+ var position = computed(function() {
41
+ return {
42
+ x: hitbox().w / 2 - barWidth / 2,
43
+ y: -barHeight - 8
44
+ };
45
+ });
46
+ var fillWidth = computed(function() {
47
+ var percent = animatedPercent();
48
+ var width = maxFillWidth * percent;
49
+ if (percent > 0 && width < innerRadius * 2) return innerRadius * 2;
50
+ return Math.max(0, width);
51
+ });
52
+ var hpColorHex = computed(function() {
53
+ var percent = hpPercent();
54
+ if (percent > .6) return 4906624;
55
+ else if (percent > .3) return 16436245;
56
+ else if (percent > .15) return 16486972;
57
+ else return 15680580;
58
+ });
59
+ var drawShadow = function(g) {
60
+ g.roundRect(0, 0, barWidth, barHeight, borderRadius);
61
+ g.fill({
62
+ color: shadowColor,
63
+ alpha: .3
64
+ });
65
+ };
66
+ var drawBackground = function(g) {
67
+ g.roundRect(0, 0, barWidth, barHeight, borderRadius);
68
+ g.fill({
69
+ color: bgColor,
70
+ alpha: .9
71
+ });
72
+ };
73
+ var drawFill = function(g) {
74
+ var width = fillWidth();
75
+ if (width > 0) {
76
+ g.roundRect(padding, padding, width, fillHeight, innerRadius);
77
+ g.fill({ color: hpColorHex() });
78
+ }
79
+ };
80
+ var drawHighlight = function(g) {
81
+ var width = fillWidth();
82
+ if (width > 0) {
83
+ g.roundRect(padding, padding, width, highlightHeight, innerRadius);
84
+ g.fill({
85
+ color: 16777215,
86
+ alpha: .25
87
+ });
88
+ }
89
+ };
90
+ var drawBorder = function(g) {
91
+ g.roundRect(0, 0, barWidth, barHeight, borderRadius);
92
+ g.stroke({
93
+ color: borderColor,
94
+ width: 1,
95
+ alpha: .7
96
+ });
97
+ };
98
+ return [, h(Container, {
99
+ x: position.x,
100
+ y: position.y
101
+ }, [
102
+ h(Graphics, {
103
+ draw: drawShadow,
104
+ x: 1,
105
+ y: 1
106
+ }),
107
+ h(Graphics, { draw: drawBackground }),
108
+ h(Graphics, { draw: drawFill }),
109
+ h(Graphics, { draw: drawHighlight }),
110
+ h(Graphics, { draw: drawBorder })
111
+ ])];
112
+ }
113
+ //#endregion
105
114
  export { component as default };
106
- //# sourceMappingURL=hp-bar.ce.js.map
115
+
116
+ //# sourceMappingURL=hp-bar.ce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hp-bar.ce.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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AAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC;AACxD,IAAI,CAAC,CAAC,MAAM,CAAC;AACb,QAAQ,KAAK,EAAE,WAAW;AAC1B,QAAQ,KAAK,EAAE,CAAC;AAChB,QAAQ,KAAK,EAAE;AACf,KAAK,CAAC;AACN,CAAC;AACD,QAAQ,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,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;AACtQ,QAAQ,OAAO;AACf,MAAM;;;;"}
1
+ {"version":3,"file":"hp-bar.ce.js","names":[],"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"],"mappings":";;AAOC,SAAA,UAAA,SAAA;AACsB,UAAC,QAAY;CAEhC,IAAQ,SADgB,eAAe,QAAC,EACV,CAAC;CACnC,IAAI,WAAS;CACb,IAAI,YAAY;CAChB,IAAC,eAAA;CACD,IAAG,cAAA;CACH,IAAI,UAAC;CACL,IAAE,UAAY;CACd,IAAC,cAAA;CACD,IAAI,cAAW;CACf,IAAE,eAAe,WAAa,UAAW;CACzC,IAAI,aAAQ,YAAA,UAAA;CACZ,IAAI,kBAAE,KAAoB,MAAK,aAAA,EAAA;CAC/B,IAAI,SAAA,OAAA;CACJ,IAAG,YAAA,SAAA,WAAA;EACC,IAAA,IAAA;AACF,UAAA,MAAA,KAAA,OAAA,cAAA,QAAA,OAAA,KAAA,IAAA,KAAA,IAAA,GAAA,KAAA,OAAA,MAAA,QAAA,OAAA,KAAA,IAAA,KAAA;;CAEF,IAAC,QAAW,SAAE,WAAe;EACzB,IAAG,IAAA,IAAA;AAEN,UAAA,OADiB,MAAA,KAAW,OAAO,YAAO,QAAA,OAAA,KAAA,IAAA,KAAA,IAAA,GAAA,KAAA,OAAA,MAAA,QAAA,OAAA,KAAA,IAAA,KAAA,EAAA,EAC1C,WAAA,QAAA,OAAA,KAAA,IAAA,KAAA;GACC;CACF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AAA,EAAA,UAAA;GAAA,MAAA;GAAA,GAAA;GAAA,GAAA;GAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,gBAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,UAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,eAAA,CAAA;EAAA,EAAA,UAAA,EAAA,MAAA,YAAA,CAAA;EAAA,CAAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ import "./hp-bar.ce.js";
2
+ import "./light-halo.ce.js";
@@ -1,76 +1,94 @@
1
- import { useProps, useDefineProps, computed, signal, tick, h, Container, Graphics } from 'canvasengine';
2
- import { BlurFilter } from 'pixi.js';
3
-
1
+ import { Container, Graphics, computed, h, signal, tick, useDefineProps, useProps } from "canvasengine";
2
+ import { BlurFilter } from "pixi.js";
3
+ //#region src/components/prebuilt/light-halo.ce
4
4
  function component($$props) {
5
- useProps($$props);
6
- const defineProps = useDefineProps($$props);
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: position.x, y: position.y }, h(Graphics, { draw: drawHalo }));
72
- return $this
73
- }
74
-
5
+ useProps($$props);
6
+ var _a = useDefineProps($$props)(), object = _a.object, baseRadius = _a.baseRadius, radiusVariation = _a.radiusVariation, baseOpacity = _a.baseOpacity, opacityVariation = _a.opacityVariation, sizeSpeed = _a.sizeSpeed, opacitySpeed = _a.opacitySpeed, lightColor = _a.lightColor;
7
+ var getBaseRadius = computed(function() {
8
+ var _a;
9
+ return (_a = baseRadius === null || baseRadius === void 0 ? void 0 : baseRadius()) !== null && _a !== void 0 ? _a : 30;
10
+ });
11
+ var getRadiusVariation = computed(function() {
12
+ var _a;
13
+ return (_a = radiusVariation === null || radiusVariation === void 0 ? void 0 : radiusVariation()) !== null && _a !== void 0 ? _a : 10;
14
+ });
15
+ var getBaseOpacity = computed(function() {
16
+ var _a;
17
+ return (_a = baseOpacity === null || baseOpacity === void 0 ? void 0 : baseOpacity()) !== null && _a !== void 0 ? _a : .6;
18
+ });
19
+ var getOpacityVariation = computed(function() {
20
+ var _a;
21
+ return (_a = opacityVariation === null || opacityVariation === void 0 ? void 0 : opacityVariation()) !== null && _a !== void 0 ? _a : .3;
22
+ });
23
+ var getSizeSpeed = computed(function() {
24
+ var _a;
25
+ return (_a = sizeSpeed === null || sizeSpeed === void 0 ? void 0 : sizeSpeed()) !== null && _a !== void 0 ? _a : .002;
26
+ });
27
+ var getOpacitySpeed = computed(function() {
28
+ var _a;
29
+ return (_a = opacitySpeed === null || opacitySpeed === void 0 ? void 0 : opacitySpeed()) !== null && _a !== void 0 ? _a : .003;
30
+ });
31
+ var getLightColor = computed(function() {
32
+ var _a;
33
+ return (_a = lightColor === null || lightColor === void 0 ? void 0 : lightColor()) !== null && _a !== void 0 ? _a : 16777130;
34
+ });
35
+ var time = signal(0);
36
+ var currentRadius = computed(function() {
37
+ var t = time();
38
+ var base = getBaseRadius();
39
+ var variation = getRadiusVariation();
40
+ var speed = getSizeSpeed();
41
+ return base + (Math.sin(t * speed) + Math.sin(t * speed * 1.5) * .5) / 1.5 * variation;
42
+ });
43
+ var currentOpacity = computed(function() {
44
+ var t = time();
45
+ var base = getBaseOpacity();
46
+ var variation = getOpacityVariation();
47
+ var speed = getOpacitySpeed();
48
+ var fade = Math.sin(t * speed);
49
+ var flicker = (Math.random() - .5) * .1;
50
+ return Math.max(0, Math.min(1, base + fade * variation + flicker));
51
+ });
52
+ var hitbox = object.hitbox;
53
+ var position = computed(function() {
54
+ return {
55
+ x: hitbox().w / 2,
56
+ y: hitbox().h / 2
57
+ };
58
+ });
59
+ var blurFilter = new BlurFilter({
60
+ strength: 20,
61
+ quality: 3
62
+ });
63
+ var drawHalo = function(g) {
64
+ var radius = currentRadius();
65
+ var opacity = currentOpacity();
66
+ var color = getLightColor();
67
+ if (opacity <= 0 || radius <= 0) return;
68
+ g.blendMode = "add";
69
+ g.filters = [blurFilter];
70
+ g.circle(0, 0, radius);
71
+ g.fill({
72
+ color,
73
+ alpha: opacity
74
+ });
75
+ g.circle(0, 0, radius * .4);
76
+ g.fill({
77
+ color: 16777215,
78
+ alpha: opacity * .5
79
+ });
80
+ };
81
+ tick(function() {
82
+ time.update(function(t) {
83
+ return t + 1;
84
+ });
85
+ });
86
+ return h(Container, {
87
+ x: position.x,
88
+ y: position.y
89
+ }, h(Graphics, { draw: drawHalo }));
90
+ }
91
+ //#endregion
75
92
  export { component as default };
76
- //# sourceMappingURL=light-halo.ce.js.map
93
+
94
+ //# sourceMappingURL=light-halo.ce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"light-halo.ce.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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CAAC,IAAI,MAAM,IAAI,CAAC;AACnC,QAAQ;AACR;AACA,IAAI,CAAC,CAAC,SAAS,GAAG,KAAK;AACvB;AACA,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;AAC5B;AACA;AACA,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;AAC1B,IAAI,CAAC,CAAC,IAAI,CAAC;AACX,QAAQ,KAAK,EAAE,KAAK;AACpB,QAAQ,KAAK,EAAE;AACf,KAAK,CAAC;AACN;AACA,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;AAChC,IAAI,CAAC,CAAC,IAAI,CAAC;AACX,QAAQ,KAAK,EAAE,QAAQ;AACvB,QAAQ,KAAK,EAAE,OAAO,GAAG;AACzB,KAAK,CAAC;AACN,CAAC;AACD,IAAI,CAAC,YAAY;AACjB,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AACF,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClG,QAAQ,OAAO;AACf,MAAM;;;;"}
1
+ {"version":3,"file":"light-halo.ce.js","names":[],"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"],"mappings":";;;AAQE,SAAA,UAAA,SAAA;AACqB,UAAA,QAAA;CAEhB,IAAK,KADV,eAAA,QAAA,EAC4B,EAAC,SAAO,GAAM,QAAQ,aAAa,GAAG,YAAE,kBAAA,GAAA,iBAAA,cAAA,GAAA,aAAA,mBAAA,GAAA,kBAAA,YAAA,GAAA,WAAA,eAAA,GAAA,cAAA,aAAA,GAAA;CACtE,IAAG,gBAAU,SAAa,WAAS;EAAQ,IAAA;AAAO,UAAO,KAAA,eAAQ,QAAA,eAAA,KAAA,IAAA,KAAA,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AAA,GAAA,MACK,MACP;GACT;CACF,IAAE,iBAAA,SAAA,WAAA;EACE,IAAA,IAAA,MAAa;;EAEb,IAAI,YAAY,qBAAE;EACnB,IAAK,QAAM,iBAAQ;;EAItB,IAAM,WAAA,KAAkB,QAAG,GAAQ,MAAO;AAC1C,SAAM,KAAA,IAAc,GAAG,KAAA,IAAS,GAAG,OAAG,OAAY,YAAW,QAAA,CAAA;GAC7D;CACA,IAAA,SAAM,OAAc;CACpB,IAAA,WAAM,SAAkB,WAAY;AAAE,SAAC;GACvC,GAAM,QAAA,CAAA,IAAc;;GAEnB;GAAK;CACN,IAAG,aAAU,IAAA,WAAA;EAAA,UAAA;EAAA,SAAA;EAAA,CAAA;CACb,IAAI,WAAW,SAAO,GAAA;;EAElB,IAAI,UAAS,gBAAgB;EACjC,IAAM,QAAO,eAAS;kCAEpB;AAEC,IAAA,YAAc;AAEjB,IAAM,UAAA,CAAA,WAAgB;AAGpB,IAAA,OAAM,GAAA,GAAW,OAAC;AAClB,IAAA,KAAM;GACP;GACI,OAAQ;GACX,CAAA;AAEA,IAAA,OAAM,GAAA,GAAA,SAAiB,GAAO;AAC/B,IAAA,KAAA;GACO,OAAO;GACb,OAAA,UAAA;;;AAGF,MAAG,WAAQ;AACR,OAAA,OAAW,SAAO,GAAQ;AAAA,UAAA,IAAA;IAAA;GAC3B;AAEM,QADY,EAAE,WAAW;EAAE,GAAG,SAAA;EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,UAAA,EAAA,MAAA,UAAA,CAAA,CAAA"}
@@ -1,44 +1,60 @@
1
- import { useProps, useDefineProps, computed, effect, h, Canvas, loop, Viewport, cond, Container } from 'canvasengine';
2
- import { inject } from '../../core/inject.js';
3
- import { RpgClientEngine } from '../../RpgClientEngine.js';
4
- import component$1 from './draw-map.ce.js';
5
- import { RpgGui } from '../../Gui/Gui.js';
6
- import { delay } from '@rpgjs/common';
7
-
1
+ import { inject } from "../../core/inject.js";
2
+ import component$1 from "./draw-map.ce.js";
3
+ import { RpgGui } from "../../Gui/Gui.js";
4
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
5
+ import { Canvas, Container, Viewport, computed, cond, effect, h, loop, useDefineProps, useProps } from "canvasengine";
6
+ import { delay } from "@rpgjs/common";
7
+ //#region src/components/scenes/canvas.ce
8
8
  function component($$props) {
9
- useProps($$props);
10
- useDefineProps($$props);
11
- var engine = inject(RpgClientEngine);
12
- var guiService = inject(RpgGui);
13
- var sceneData = engine.sceneMap.data;
14
- var guiList = computed(function () {
15
- return Object.values(guiService.gui()).filter(function (gui) { return !gui.attachToSprite; });
16
- });
17
- var worldWidth = computed(function () { var _a; return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.width; });
18
- var worldHeight = computed(function () { var _a; return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.height; });
19
- effect(function () {
20
- if (sceneData() && !sceneData().component) {
21
- throw new Error("Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.");
22
- }
23
- });
24
- var onGuiFinish = function (gui, data) {
25
- delay(function () {
26
- guiService.guiClose(gui.name, data);
27
- });
28
- };
29
- var onGuiInteraction = function (gui, name, data) {
30
- guiService.guiInteraction(gui.name, name, data);
31
- };
32
- var clamp = {
33
- direction: "all"
34
- };
35
- let $this = h(Canvas, { width: engine.width, height: engine.height }, [h(Viewport, { worldWidth, worldHeight, clamp, sortableChildren: true }, cond(sceneData, () => h(component$1))), loop(guiList, gui => h(Container, { display: 'flex' }, cond(gui.display, () => h(gui.component, { data: gui.data, dependencies: gui.dependencies, onFinish: (data) => {
36
- onGuiFinish(gui, data);
37
- }, onInteraction: (name, data) => {
38
- onGuiInteraction(gui, name, data);
39
- } }))))]);
40
- return $this
41
- }
42
-
9
+ useProps($$props);
10
+ useDefineProps($$props);
11
+ var engine = inject(RpgClientEngine);
12
+ var guiService = inject(RpgGui);
13
+ var sceneData = engine.sceneMap.data;
14
+ var guiList = computed(function() {
15
+ return Object.values(guiService.gui()).filter(function(gui) {
16
+ return !gui.attachToSprite;
17
+ });
18
+ });
19
+ var worldWidth = computed(function() {
20
+ var _a;
21
+ return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.width;
22
+ });
23
+ var worldHeight = computed(function() {
24
+ var _a;
25
+ return (_a = sceneData()) === null || _a === void 0 ? void 0 : _a.height;
26
+ });
27
+ effect(function() {
28
+ if (sceneData() && !sceneData().component) throw new Error("Warning ! You need to define a component for the scene. Use provideLoadMap() to define a component for the scene.");
29
+ });
30
+ var onGuiFinish = function(gui, data) {
31
+ delay(function() {
32
+ guiService.guiClose(gui.name, data);
33
+ });
34
+ };
35
+ var onGuiInteraction = function(gui, name, data) {
36
+ guiService.guiInteraction(gui.name, name, data);
37
+ };
38
+ return h(Canvas, {
39
+ width: engine.width,
40
+ height: engine.height
41
+ }, [h(Viewport, {
42
+ worldWidth,
43
+ worldHeight,
44
+ clamp: { direction: "all" },
45
+ sortableChildren: true
46
+ }, cond(sceneData, () => h(component$1))), loop(guiList, (gui) => h(Container, { display: "flex" }, cond(gui.display, () => h(gui.component, {
47
+ data: gui.data,
48
+ dependencies: gui.dependencies,
49
+ onFinish: (data) => {
50
+ onGuiFinish(gui, data);
51
+ },
52
+ onInteraction: (name, data) => {
53
+ onGuiInteraction(gui, name, data);
54
+ }
55
+ }))))]);
56
+ }
57
+ //#endregion
43
58
  export { component as default };
44
- //# sourceMappingURL=canvas.ce.js.map
59
+
60
+ //# sourceMappingURL=canvas.ce.js.map