@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.20

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 (163) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/Game/Map.d.ts +7 -1
  3. package/dist/Gui/Gui.d.ts +128 -5
  4. package/dist/RpgClient.d.ts +217 -59
  5. package/dist/RpgClientEngine.d.ts +345 -6
  6. package/dist/Sound.d.ts +199 -0
  7. package/dist/components/animations/index.d.ts +4 -0
  8. package/dist/components/dynamics/parse-value.d.ts +1 -0
  9. package/dist/components/gui/index.d.ts +3 -3
  10. package/dist/components/index.d.ts +3 -1
  11. package/dist/components/prebuilt/index.d.ts +18 -0
  12. package/dist/index.d.ts +4 -1
  13. package/dist/index.js +9 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/index10.js +149 -4
  16. package/dist/index10.js.map +1 -1
  17. package/dist/index11.js +21 -7
  18. package/dist/index11.js.map +1 -1
  19. package/dist/index12.js +6 -4
  20. package/dist/index12.js.map +1 -1
  21. package/dist/index13.js +11 -14
  22. package/dist/index13.js.map +1 -1
  23. package/dist/index14.js +8 -40
  24. package/dist/index14.js.map +1 -1
  25. package/dist/index15.js +187 -180
  26. package/dist/index15.js.map +1 -1
  27. package/dist/index16.js +104 -7
  28. package/dist/index16.js.map +1 -1
  29. package/dist/index17.js +82 -372
  30. package/dist/index17.js.map +1 -1
  31. package/dist/index18.js +361 -26
  32. package/dist/index18.js.map +1 -1
  33. package/dist/index19.js +46 -20
  34. package/dist/index19.js.map +1 -1
  35. package/dist/index2.js +683 -32
  36. package/dist/index2.js.map +1 -1
  37. package/dist/index20.js +5 -2417
  38. package/dist/index20.js.map +1 -1
  39. package/dist/index21.js +383 -97
  40. package/dist/index21.js.map +1 -1
  41. package/dist/index22.js +41 -104
  42. package/dist/index22.js.map +1 -1
  43. package/dist/index23.js +21 -67
  44. package/dist/index23.js.map +1 -1
  45. package/dist/index24.js +2632 -20
  46. package/dist/index24.js.map +1 -1
  47. package/dist/index25.js +107 -34
  48. package/dist/index25.js.map +1 -1
  49. package/dist/index26.js +69 -3
  50. package/dist/index26.js.map +1 -1
  51. package/dist/index27.js +17 -318
  52. package/dist/index27.js.map +1 -1
  53. package/dist/index28.js +24 -22
  54. package/dist/index28.js.map +1 -1
  55. package/dist/index29.js +92 -8
  56. package/dist/index29.js.map +1 -1
  57. package/dist/index3.js +68 -8
  58. package/dist/index3.js.map +1 -1
  59. package/dist/index30.js +37 -7
  60. package/dist/index30.js.map +1 -1
  61. package/dist/index31.js +18 -168
  62. package/dist/index31.js.map +1 -1
  63. package/dist/index32.js +3 -499
  64. package/dist/index32.js.map +1 -1
  65. package/dist/index33.js +332 -9
  66. package/dist/index33.js.map +1 -1
  67. package/dist/index34.js +24 -4400
  68. package/dist/index34.js.map +1 -1
  69. package/dist/index35.js +6 -311
  70. package/dist/index35.js.map +1 -1
  71. package/dist/index36.js +8 -88
  72. package/dist/index36.js.map +1 -1
  73. package/dist/index37.js +182 -56
  74. package/dist/index37.js.map +1 -1
  75. package/dist/index38.js +500 -16
  76. package/dist/index38.js.map +1 -1
  77. package/dist/index39.js +10 -18
  78. package/dist/index39.js.map +1 -1
  79. package/dist/index4.js +23 -5
  80. package/dist/index4.js.map +1 -1
  81. package/dist/index40.js +7 -0
  82. package/dist/index40.js.map +1 -0
  83. package/dist/index41.js +3690 -0
  84. package/dist/index41.js.map +1 -0
  85. package/dist/index42.js +77 -0
  86. package/dist/index42.js.map +1 -0
  87. package/dist/index43.js +6 -0
  88. package/dist/index43.js.map +1 -0
  89. package/dist/index44.js +20 -0
  90. package/dist/index44.js.map +1 -0
  91. package/dist/index45.js +146 -0
  92. package/dist/index45.js.map +1 -0
  93. package/dist/index46.js +12 -0
  94. package/dist/index46.js.map +1 -0
  95. package/dist/index47.js +113 -0
  96. package/dist/index47.js.map +1 -0
  97. package/dist/index48.js +136 -0
  98. package/dist/index48.js.map +1 -0
  99. package/dist/index49.js +137 -0
  100. package/dist/index49.js.map +1 -0
  101. package/dist/index5.js +2 -1
  102. package/dist/index5.js.map +1 -1
  103. package/dist/index50.js +112 -0
  104. package/dist/index50.js.map +1 -0
  105. package/dist/index51.js +141 -0
  106. package/dist/index51.js.map +1 -0
  107. package/dist/index52.js +9 -0
  108. package/dist/index52.js.map +1 -0
  109. package/dist/index53.js +54 -0
  110. package/dist/index53.js.map +1 -0
  111. package/dist/index6.js +1 -1
  112. package/dist/index6.js.map +1 -1
  113. package/dist/index7.js +11 -3
  114. package/dist/index7.js.map +1 -1
  115. package/dist/index8.js +68 -7
  116. package/dist/index8.js.map +1 -1
  117. package/dist/index9.js +230 -15
  118. package/dist/index9.js.map +1 -1
  119. package/dist/presets/animation.d.ts +31 -0
  120. package/dist/presets/faceset.d.ts +30 -0
  121. package/dist/presets/index.d.ts +103 -0
  122. package/dist/presets/lpc.d.ts +89 -0
  123. package/dist/services/loadMap.d.ts +123 -2
  124. package/dist/services/mmorpg.d.ts +9 -4
  125. package/dist/services/standalone.d.ts +51 -2
  126. package/package.json +22 -18
  127. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  128. package/src/Game/Map.ts +20 -2
  129. package/src/Game/Object.ts +163 -9
  130. package/src/Gui/Gui.ts +300 -17
  131. package/src/RpgClient.ts +222 -58
  132. package/src/RpgClientEngine.ts +804 -36
  133. package/src/Sound.ts +253 -0
  134. package/src/components/{effects → animations}/animation.ce +3 -6
  135. package/src/components/{effects → animations}/index.ts +1 -1
  136. package/src/components/character.ce +165 -37
  137. package/src/components/dynamics/parse-value.ts +80 -0
  138. package/src/components/dynamics/text.ce +183 -0
  139. package/src/components/gui/box.ce +17 -0
  140. package/src/components/gui/dialogbox/index.ce +73 -35
  141. package/src/components/gui/dialogbox/selection.ce +16 -1
  142. package/src/components/gui/index.ts +3 -4
  143. package/src/components/index.ts +5 -1
  144. package/src/components/prebuilt/hp-bar.ce +255 -0
  145. package/src/components/prebuilt/index.ts +21 -0
  146. package/src/components/scenes/draw-map.ce +6 -23
  147. package/src/components/scenes/event-layer.ce +9 -3
  148. package/src/core/setup.ts +2 -0
  149. package/src/index.ts +5 -2
  150. package/src/module.ts +72 -6
  151. package/src/presets/animation.ts +46 -0
  152. package/src/presets/faceset.ts +60 -0
  153. package/src/presets/index.ts +7 -1
  154. package/src/presets/lpc.ts +108 -0
  155. package/src/services/loadMap.ts +132 -3
  156. package/src/services/mmorpg.ts +27 -5
  157. package/src/services/standalone.ts +68 -6
  158. package/tsconfig.json +1 -1
  159. package/vite.config.ts +1 -1
  160. package/dist/Game/EffectManager.d.ts +0 -5
  161. package/dist/components/effects/index.d.ts +0 -4
  162. package/src/components/scenes/element-map.ce +0 -23
  163. /package/src/components/{effects → animations}/hit.ce +0 -0
package/dist/index22.js CHANGED
@@ -1,109 +1,46 @@
1
- import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text } from 'canvasengine';
2
- import component$1 from './index37.js';
3
- import { inject } from './index6.js';
1
+ import { RpgCommonMap } from '@rpgjs/common';
2
+ import { sync, users } from './index21.js';
3
+ import { RpgClientPlayer } from './index35.js';
4
+ import { signal, computed } from 'canvasengine';
5
+ import { RpgClientEvent } from './index36.js';
4
6
  import { RpgClientEngine } from './index2.js';
7
+ import { inject } from './index6.js';
5
8
 
6
- function component($$props) {
7
- useProps($$props);
8
- const defineProps = useDefineProps($$props);
9
- var _a = defineProps(), message = _a.message, _choices = _a.choices, onFinish = _a.onFinish; _a.onInteraction;
10
- var client = inject(RpgClientEngine);
11
- var keyboardControls = client.globalConfig.keyboardControls;
12
- client.stopProcessingInput = true;
13
- var isDestroyed = false;
14
- var texts = [message()];
15
- var height = signal(250);
16
- var isTextCompleted = signal(false);
17
- var border = signal({ width: 5, color: "#595971" });
18
- var shadow = signal({ color: "#000", blur: 10, offsetX: 10, offsetY: 10 });
19
- var contentOpacity = animatedSignal(0, {
20
- duration: 1000,
21
- });
22
- var scaleX = animatedSignal(0, {
23
- duration: 500,
24
- });
25
- scaleX.set(1);
26
- contentOpacity.set(1);
27
- var currentTextIndex = signal(0);
28
- var currentText = computed(function () { var _a; return (_a = texts === null || texts === void 0 ? void 0 : texts[currentTextIndex()]) !== null && _a !== void 0 ? _a : ''; });
29
- var isChoiceDisplayed = signal(false);
30
- var text = computed(function () {
31
- var current = currentText();
32
- return typeof current === "string" ? current : current.text;
33
- });
34
- var choices = computed(function () {
35
- //const current = currentText();
36
- //return typeof current === "string" ? null : current.choices;
37
- return _choices;
38
- });
39
- var visibleSelection = computed(function () { return isChoiceDisplayed() && choices().length != 0; });
40
- var triggerSkip = trigger();
41
- var typewriter = {
42
- speed: 0.3,
43
- skip: triggerSkip,
44
- onComplete: function () {
45
- isTextCompleted.set(true);
46
- }
47
- };
48
- var textStyle = {
49
- wordWrap: true,
50
- wordWrapWidth: 700 - 256 - 80
51
- };
52
- signal({ x: 0, y: 0, width: 256, height: 256 });
53
- mount(function (element) {
54
- var dialogbox = element.props.children[0];
55
- return function () {
56
- dialogbox.directives.controls.onDestroy();
57
- isDestroyed = true;
58
- // Wait destroy is finished before start processing input
59
- setTimeout(function () {
60
- client.stopProcessingInput = false;
61
- }, 500);
62
- };
63
- });
64
- var controls = signal({
65
- next: {
66
- bind: keyboardControls.action,
67
- keyDown: function (e) {
68
- if (isDestroyed)
69
- return;
70
- if (isChoiceDisplayed()) {
71
- // If choices are displayed, do nothing (wait for selection)
72
- return;
73
- }
74
- // If text is still typing, just skip (fast forward) the animation
75
- if (!isTextCompleted()) {
76
- triggerSkip.start();
77
- isTextCompleted.set(true);
78
- }
79
- else {
80
- var isFinished = currentTextIndex() === texts.length - 1;
81
- currentTextIndex.update(function (index) {
82
- if (index < texts.length - 1) {
83
- return index + 1;
84
- }
85
- return index;
86
- });
87
- isChoiceDisplayed.set(false);
88
- isTextCompleted.set(false);
89
- if (isFinished && onFinish) {
90
- onFinish();
91
- }
92
- }
93
- },
94
- },
95
- });
96
- var onSelect = function (index) {
97
- onFinish(index);
9
+ var __defProp = Object.defineProperty;
10
+ var __decorateClass = (decorators, target, key, kind) => {
11
+ var result = void 0 ;
12
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
+ if (decorator = decorators[i])
14
+ result = (decorator(target, key, result) ) || result;
15
+ if (result) __defProp(target, key, result);
16
+ return result;
98
17
  };
99
- effect(function () {
100
- if (choices().length != 0) {
101
- isChoiceDisplayed.set(true);
102
- }
103
- });
104
- let $this = h(Container, { justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' }, h(Container, { ref: 'dialogbox', scale: { x: scaleX }, anchor: [0.5, 0.5], width: 700, height, controls, positionType: 'absolute', bottom: 10 }, [h(Rect, { width: 700, height: 250, color: '#1a1a2e' }), h(Rect, { x: 0, y: 0, width: 700, height, color: '#1a1a2e', alpha: 0.9, borderRadius: 10, border, shadow }), h(Container, { flexDirection: 'row', width: 700, height, alpha: contentOpacity }, h(Container, { flexDirection: 'column' }, [h(Text, { text, color: '#fff', fontSize: 18, margin: 40, typewriter, style: textStyle }), cond(visibleSelection, () => h(component$1, { selectedIndex: 0, items: choices, onSelect }))]))]));
105
- return $this
106
- }
18
+ class RpgClientMap extends RpgCommonMap {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.engine = inject(RpgClientEngine);
22
+ this.players = signal({});
23
+ this.events = signal({});
24
+ this.currentPlayer = computed(() => this.players()[this.engine.playerIdSignal()]);
25
+ }
26
+ getCurrentPlayer() {
27
+ return this.currentPlayer();
28
+ }
29
+ reset() {
30
+ this.players.set({});
31
+ this.events.set({});
32
+ this.clearPhysic();
33
+ }
34
+ stepPredictionTick() {
35
+ this.forceSingleTick();
36
+ }
37
+ }
38
+ __decorateClass([
39
+ users(RpgClientPlayer)
40
+ ], RpgClientMap.prototype, "players");
41
+ __decorateClass([
42
+ sync(RpgClientEvent)
43
+ ], RpgClientMap.prototype, "events");
107
44
 
108
- export { component as default };
45
+ export { RpgClientMap };
109
46
  //# sourceMappingURL=index22.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index22.js","sources":["../src/components/gui/dialogbox/index.ce"],"sourcesContent":["<Container justifyContent=\"center\" alignItems=\"center\" width=\"100%\" height=\"100%\">\n <Container\n ref=\"dialogbox\"\n scale={{ x: scaleX }}\n anchor={[0.5, 0.5]}\n width={700}\n height\n controls\n positionType=\"absolute\"\n bottom={10}\n >\n <Rect width={700} height={250} color=\"#1a1a2e\" />\n <Rect\n x={0}\n y={0}\n width={700}\n height\n color=\"#1a1a2e\"\n alpha={0.9}\n borderRadius={10}\n border\n shadow\n />\n <Container\n flexDirection=\"row\"\n width={700}\n height\n alpha={contentOpacity}\n >\n <Container flexDirection=\"column\">\n <Text\n text\n color=\"#fff\"\n fontSize={18}\n margin={40}\n typewriter\n style={textStyle}\n />\n @if (visibleSelection) {\n <Selection selectedIndex={0} items={choices} onSelect />\n }\n </Container>\n </Container>\n</Container> \n\n \n</Container>\n<script>\n import Selection from './selection.ce'\n\n import {\n animatedSignal,\n computed,\n effect,\n signal,\n trigger,\n mount\n } from \"canvasengine\";\n\n import { inject } from \"../../../core/inject\";\n import { RpgClientEngine } from \"../../../RpgClientEngine\";\n\n const {\n message,\n choices: _choices,\n onFinish,\n onInteraction\n } = defineProps();\n\n const client = inject(RpgClientEngine);\n const keyboardControls = client.globalConfig.keyboardControls;\n\n client.stopProcessingInput = true;\n let isDestroyed = false;\n\n const texts = [message()]\n const height = signal(250);\n const isTextCompleted = signal(false);\n\n const drawSpeaker = (g) => {\n g.beginFill(0xffa500); // Orange color\n g.lineStyle(2, 0x000000); // Black border\n g.moveTo(0, 0);\n g.lineTo(70, 0);\n g.lineTo(80, 15);\n g.lineTo(70, 30);\n g.lineTo(0, 30);\n g.lineTo(0, 0);\n g.endFill();\n };\n\n const border = signal({ width: 5, color: \"#595971\" });\n const shadow = signal({ color: \"#000\", blur: 10, offsetX: 10, offsetY: 10 });\n\n const contentOpacity = animatedSignal(0, {\n duration: 1000,\n });\n\n const scaleX = animatedSignal(0, {\n duration: 500,\n });\n\n scaleX.set(1);\n contentOpacity.set(1);\n\n const currentTextIndex = signal(0);\n const currentText = computed(() => texts?.[currentTextIndex()] ?? '');\n const isChoiceDisplayed = signal(false);\n\n const text = computed(() => {\n const current = currentText();\n return typeof current === \"string\" ? current : current.text;\n });\n\n const choices = computed(() => {\n //const current = currentText();\n //return typeof current === \"string\" ? null : current.choices;\n return _choices;\n });\n\n const visibleSelection = computed(() => isChoiceDisplayed() && choices().length != 0)\n\n const triggerSkip = trigger();\n\n const typewriter = {\n speed: 0.3,\n skip: triggerSkip,\n onComplete: () => {\n isTextCompleted.set(true);\n }\n }\n\n const textStyle = {\n wordWrap: true,\n wordWrapWidth: 700 - 256 - 80\n }\n\n const face = signal({ x: 0, y: 0, width: 256, height: 256 });\n\n mount((element) => {\n const [dialogbox] = element.props.children\n return () => {\n dialogbox.directives.controls.onDestroy()\n isDestroyed = true;\n // Wait destroy is finished before start processing input\n setTimeout(() => {\n client.stopProcessingInput = false;\n }, 500)\n }\n })\n\n const controls = signal({\n next: {\n bind: keyboardControls.action,\n keyDown(e) {\n if (isDestroyed) return;\n if (isChoiceDisplayed()) {\n // If choices are displayed, do nothing (wait for selection)\n return;\n }\n\n // If text is still typing, just skip (fast forward) the animation\n if (!isTextCompleted()) {\n triggerSkip.start();\n isTextCompleted.set(true);\n }\n else {\n const isFinished = currentTextIndex() === texts.length - 1;\n currentTextIndex.update((index) => {\n if (index < texts.length - 1) {\n return index + 1;\n }\n return index;\n });\n isChoiceDisplayed.set(false);\n isTextCompleted.set(false);\n if (isFinished && onFinish) {\n onFinish();\n } \n }\n },\n },\n });\n\n const onSelect = (index) => {\n onFinish(index);\n }\n \n effect(() => {\n if (choices().length != 0) {\n isChoiceDisplayed.set(true);\n }\n });\n</script>"],"names":["Selection"],"mappings":";;;;;AAWqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cA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E,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAACA,WAAS,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjuB,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index22.js","sources":["../src/Game/Map.ts"],"sourcesContent":["import { RpgCommonMap } from \"@rpgjs/common\";\nimport { sync, users } from \"@signe/sync\";\nimport { RpgClientPlayer } from \"./Player\";\nimport { Signal, signal, computed } from \"canvasengine\";\nimport { RpgClientEvent } from \"./Event\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { inject } from \"../core/inject\";\n\nexport class RpgClientMap extends RpgCommonMap<any> {\n engine: RpgClientEngine = inject(RpgClientEngine)\n @users(RpgClientPlayer) players = signal<Record<string, RpgClientPlayer>>({});\n @sync(RpgClientEvent) events = signal<Record<string, RpgClientEvent>>({});\n currentPlayer = computed(() => this.players()[this.engine.playerIdSignal()!])\n\n getCurrentPlayer() {\n return this.currentPlayer()\n }\n\n reset() {\n this.players.set({})\n this.events.set({})\n this.clearPhysic()\n }\n\n stepPredictionTick(): void {\n this.forceSingleTick();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQO,MAAM,qBAAqB,YAAA,CAAkB;AAAA,EAA7C,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAA,MAAA,GAA0B,OAAO,eAAe,CAAA;AACxB,IAAA,IAAA,CAAA,OAAA,GAAU,MAAA,CAAwC,EAAE,CAAA;AACtD,IAAA,IAAA,CAAA,MAAA,GAAS,MAAA,CAAuC,EAAE,CAAA;AACxE,IAAA,IAAA,CAAA,aAAA,GAAgB,QAAA,CAAS,MAAM,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,MAAA,CAAO,cAAA,EAAiB,CAAC,CAAA;AAAA,EAAA;AAAA,EAE5E,gBAAA,GAAmB;AACjB,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC5B;AAAA,EAEA,KAAA,GAAQ;AACN,IAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA;AACnB,IAAA,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,EAAE,CAAA;AAClB,IAAA,IAAA,CAAK,WAAA,EAAY;AAAA,EACnB;AAAA,EAEA,kBAAA,GAA2B;AACzB,IAAA,IAAA,CAAK,eAAA,EAAgB;AAAA,EACvB;AACF;AAjB0B,eAAA,CAAA;AAAA,EAAvB,MAAM,eAAe;AAAA,CAAA,EAFX,YAAA,CAEa,SAAA,EAAA,SAAA,CAAA;AACF,eAAA,CAAA;AAAA,EAArB,KAAK,cAAc;AAAA,CAAA,EAHT,YAAA,CAGW,SAAA,EAAA,QAAA,CAAA;;;;"}
package/dist/index23.js CHANGED
@@ -1,71 +1,25 @@
1
- import { useProps, useDefineProps, animatedSignal, signal, mount, tick, h, Text } from 'canvasengine';
2
- import { Direction } from '@rpgjs/common';
1
+ import { generateUID } from '@rpgjs/common';
2
+ import { signal } from 'canvasengine';
3
3
 
4
- function component($$props) {
5
- useProps($$props);
6
- const defineProps = useDefineProps($$props);
7
- var _a = defineProps({
8
- duration: {
9
- default: 1000
10
- },
11
- color: {
12
- default: 'black'
13
- }
14
- }), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;
15
- var scale = animatedSignal(1, {
16
- duration: duration(),
17
- });
18
- var randomPosition = function () { return Math.floor(Math.random() * 60); };
19
- var initialY = randomPosition();
20
- var x = signal(positionX());
21
- var y = signal(positionY() - initialY);
22
- var velocityX = 0;
23
- var velocityY = 0;
24
- var speed = 200;
25
- switch (direction()) {
26
- case Direction.Left:
27
- velocityX = speed;
28
- break;
29
- case Direction.Right:
30
- velocityX = -200;
31
- break;
32
- case Direction.Up:
33
- velocityY = speed;
34
- break;
35
- case Direction.Down:
36
- velocityY = -200;
37
- break;
38
- }
39
- velocityX += (Math.random() - 0.5) * 100;
40
- velocityY += (Math.random() - 0.5) * 100;
41
- var gravity = 500;
42
- var deceleration = 0.98;
43
- mount(function () {
44
- scale.set(0.1);
45
- });
46
- var elapsedTime = 0;
47
- tick(function (_a) {
48
- var deltaTime = _a.deltaTime;
49
- elapsedTime += deltaTime;
50
- if (elapsedTime < duration()) {
51
- // Update position
52
- x.update(function (x) { return x + (velocityX * deltaTime) / 1000; });
53
- y.update(function (y) { return y + (velocityY * deltaTime) / 1000; });
54
- // Apply gravity
55
- velocityY += (gravity * deltaTime) / 1000;
56
- // Apply deceleration
57
- velocityX *= deceleration;
58
- velocityY *= deceleration;
59
- }
60
- else {
61
- if (onFinish) {
62
- onFinish();
63
- }
64
- }
65
- });
66
- let $this = h(Text, { x, y, zIndex: 10000, color, scale, size: 30, text });
67
- return $this
4
+ class AnimationManager {
5
+ constructor() {
6
+ this.current = signal([]);
7
+ }
8
+ displayEffect(params, player) {
9
+ const id = generateUID();
10
+ this.current().push({
11
+ ...params,
12
+ id,
13
+ x: player.x,
14
+ y: player.y,
15
+ object: player,
16
+ onFinish: () => {
17
+ const index = this.current().findIndex((value) => value.id === id);
18
+ this.current().splice(index, 1);
68
19
  }
20
+ });
21
+ }
22
+ }
69
23
 
70
- export { component as default };
24
+ export { AnimationManager };
71
25
  //# sourceMappingURL=index23.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index23.js","sources":["../src/components/effects/hit.ce"],"sourcesContent":["<Text x y zIndex={10000} color scale size={30} text />\n\n<script>\n import { animatedSignal, mount, signal, tick } from \"canvasengine\";\n import { Direction } from \"@rpgjs/common\";\n const {\n text,\n direction,\n onFinish,\n duration,\n color,\n x: positionX,\n y: positionY\n } = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n });\n\n const scale = animatedSignal(1, {\n duration: duration(),\n });\n\n // Generate random initial position\n const randomPosition = () => Math.floor(Math.random() * 60);\n const initialY = randomPosition();\n const x = signal(positionX());\n const y = signal(positionY() - initialY);\n\n // Initial velocity\n let velocityX = 0;\n let velocityY = 0;\n\n // Set initial velocity based on direction\n const speed = 200;\n switch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n }\n\n // Add some randomness to the velocity\n velocityX += (Math.random() - 0.5) * 100;\n velocityY += (Math.random() - 0.5) * 100;\n\n const gravity = 500; // Gravity effect\n const deceleration = 0.98; // Deceleration factor\n\n mount(() => {\n scale.set(0.1);\n });\n\n let elapsedTime = 0;\n\n tick(({ deltaTime }) => {\n elapsedTime += deltaTime;\n \n if (elapsedTime < duration()) {\n // Update position\n x.update((x) => x + (velocityX * deltaTime) / 1000);\n y.update((y) => y + (velocityY * deltaTime) / 1000);\n\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n } else {\n if (onFinish) {\n onFinish();\n }\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,EAAE,GAAG,WAAW,CAAC;AAC7B,IAAI,QAAQ,EAAE;AACd,QAAQ,OAAO,EAAE;AACjB,KAAK;AACL,IAAI,KAAK,EAAE;AACX,QAAQ,OAAO,EAAE;AACjB;AACA,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAA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CAAC,UAAU,EAAE,EAAE;AACnB,IAAI,IAAI,SAAS,GAAG,EAAE,CAAC,SAAS;AAChC,IAAI,WAAW,IAAI,SAAS;AAC5B,IAAI,IAAI,WAAW,GAAG,QAAQ,EAAE,EAAE;AAClC;AACA,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;AAC7E,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;AAC7E;AACA,QAAQ,SAAS,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,IAAI;AACjD;AACA,QAAQ,SAAS,IAAI,YAAY;AACjC,QAAQ,SAAS,IAAI,YAAY;AACjC;AACA,SAAS;AACT,QAAQ,IAAI,QAAQ,EAAE;AACtB,YAAY,QAAQ,EAAE;AACtB;AACA;AACA,CAAC,CAAC;AACF,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE;AACjF,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index23.js","sources":["../src/Game/AnimationManager.ts"],"sourcesContent":["import { generateUID, RpgCommonPlayer } from \"@rpgjs/common\";\nimport { signal } from \"canvasengine\";\n\nexport class AnimationManager {\n current = signal<any[]>([]);\n\n displayEffect(params: any, player: RpgCommonPlayer | { x: number, y: number }) {\n const id = generateUID();\n this.current().push({\n ...params,\n id,\n x: player.x,\n y: player.y,\n object: player,\n onFinish: () => {\n const index = this.current().findIndex((value) => value.id === id);\n this.current().splice(index, 1);\n },\n });\n }\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,gBAAA,CAAiB;AAAA,EAAvB,WAAA,GAAA;AACL,IAAA,IAAA,CAAA,OAAA,GAAU,MAAA,CAAc,EAAE,CAAA;AAAA,EAAA;AAAA,EAE1B,aAAA,CAAc,QAAa,MAAA,EAAoD;AAC7E,IAAA,MAAM,KAAK,WAAA,EAAY;AACvB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK;AAAA,MAClB,GAAG,MAAA;AAAA,MACH,EAAA;AAAA,MACA,GAAG,MAAA,CAAO,CAAA;AAAA,MACV,GAAG,MAAA,CAAO,CAAA;AAAA,MACV,MAAA,EAAQ,MAAA;AAAA,MACR,UAAU,MAAM;AACd,QAAA,MAAM,KAAA,GAAQ,KAAK,OAAA,EAAQ,CAAE,UAAU,CAAC,KAAA,KAAU,KAAA,CAAM,EAAA,KAAO,EAAE,CAAA;AACjE,QAAA,IAAA,CAAK,OAAA,EAAQ,CAAE,MAAA,CAAO,KAAA,EAAO,CAAC,CAAA;AAAA,MAChC;AAAA,KACD,CAAA;AAAA,EACH;AACF;;;;"}