@rpgjs/client 5.0.0-alpha.8 → 5.0.0-alpha.9

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.
@@ -1,8 +1,8 @@
1
+ import { ComponentFunction } from 'canvasengine';
1
2
  import { RpgClientEngine } from './RpgClientEngine';
2
- import { Loader } from 'pixi.js';
3
- type RpgClass<T = any> = new (...args: any[]) => T;
4
- type RpgComponent = any;
5
- type SceneMap = any;
3
+ import { Loader, Container } from 'pixi.js';
4
+ type RpgComponent = Container;
5
+ type SceneMap = Container;
6
6
  export interface RpgClientEngineHooks {
7
7
  /**
8
8
  * When the engine is started. If you send false, you prevent the client from connecting to the server
@@ -59,6 +59,34 @@ export interface RpgClientEngineHooks {
59
59
  onWindowResize?: () => any;
60
60
  }
61
61
  export interface RpgSpriteHooks {
62
+ /**
63
+ * Array of components to render behind the sprite
64
+ * These components will be displayed with a lower z-index than the sprite itself
65
+ *
66
+ * @prop { ComponentFunction[] } [componentsBehind]
67
+ * @memberof RpgSpriteHooks
68
+ * @example
69
+ * ```ts
70
+ * const sprite: RpgSpriteHooks = {
71
+ * componentsBehind: [ShadowComponent, AuraComponent]
72
+ * }
73
+ * ```
74
+ */
75
+ componentsBehind?: ComponentFunction[];
76
+ /**
77
+ * Array of components to render in front of the sprite
78
+ * These components will be displayed with a higher z-index than the sprite itself
79
+ *
80
+ * @prop { ComponentFunction[] } [componentsInFront]
81
+ * @memberof RpgSpriteHooks
82
+ * @example
83
+ * ```ts
84
+ * const sprite: RpgSpriteHooks = {
85
+ * componentsInFront: [HealthBarComponent, StatusEffectComponent]
86
+ * }
87
+ * ```
88
+ */
89
+ componentsInFront?: ComponentFunction[];
62
90
  /**
63
91
  * As soon as the sprite is initialized
64
92
  *
@@ -163,14 +191,13 @@ export interface RpgClient {
163
191
  * @example
164
192
  *
165
193
  * ```ts
166
- * import { RpgClient, RpgModule } from '@rpgjs/client'
194
+ * import { RpgClient, defineModule } from '@rpgjs/client'
167
195
  *
168
- * @RpgModule<RpgClient>({
196
+ * defineModule<RpgClient>({
169
197
  * hooks: {
170
198
  * player: ['onAuth']
171
199
  * }
172
200
  * })
173
- * class RpgClientEngine { }
174
201
  * ```
175
202
  *
176
203
  * Emit the hook:
@@ -207,7 +234,7 @@ export interface RpgClient {
207
234
  * Object containing the hooks concerning the engine
208
235
  *
209
236
  * ```ts
210
- * import { RpgClientEngine, RpgClientEngineHooks, RpgModule, RpgClient } from '@rpgjs/client'
237
+ * import { RpgClientEngine, RpgClientEngineHooks, defineModule, RpgClient } from '@rpgjs/client'
211
238
  *
212
239
  * const engine: RpgClientEngineHooks = {
213
240
  * onConnected(engine: RpgClientEngine) {
@@ -215,10 +242,9 @@ export interface RpgClient {
215
242
  * }
216
243
  * }
217
244
  *
218
- * @RpgModule<RpgClient>({
245
+ * defineModule<RpgClient>({
219
246
  * engine
220
247
  * })
221
- * class RpgClientModule {}
222
248
  * ```
223
249
  *
224
250
  * @prop {RpgClientEngineHooks} [engine]
@@ -227,99 +253,79 @@ export interface RpgClient {
227
253
  engine?: RpgClientEngineHooks;
228
254
  /**
229
255
  * Array containing the list of spritesheets
230
- * An element contains a class with the `@Spritesheet` decorator
256
+ * Each element is a simple object containing spritesheet definitions
231
257
  *
232
258
  * ```ts
233
- * import { Spritesheet, Animation, Direction, RpgClient, RpgModule } from '@rpgjs/client'
234
- *
235
- * @Spritesheet({
236
- * id: 'chest',
237
- * image: require('./assets/chest.png'),
238
- * // other options
239
- * })
240
- * class Chest { }
259
+ * import { defineModule, RpgClient } from '@rpgjs/client'
241
260
  *
242
- * @RpgModule<RpgClient>({
261
+ * defineModule<RpgClient>({
243
262
  * spritesheets: [
244
- * Chest
263
+ * {
264
+ * id: 'chest',
265
+ * image: require('./assets/chest.png'),
266
+ * framesWidth: 32,
267
+ * framesHeight: 32,
268
+ * animations: {
269
+ * default: {
270
+ * frames: [0, 1, 2],
271
+ * duration: 1000
272
+ * }
273
+ * }
274
+ * }
245
275
  * ]
246
276
  * })
247
- * class RpgClientEngine {}
248
277
  * ```
249
278
  *
250
279
  * [Guide: Create Sprite](/guide/create-sprite.html)
251
280
  *
252
- * @prop {Array<Class>} [spritesheets]
281
+ * @prop {Array<Object>} [spritesheets]
253
282
  * @memberof RpgClient
254
283
  * */
255
284
  spritesheets?: any[];
256
285
  /**
257
286
  * Array containing the list of VueJS components
258
287
  *
259
- * ```ts
260
- * import { RpgClient, RpgModule } from '@rpgjs/client'
261
- *
262
- * const component = {
263
- * name: 'my-gui',
264
- * template: `
265
- * <div>
266
- * Component
267
- * </div>
268
- * `
269
- * }
270
- *
271
- * @RpgModule<RpgClient>({
272
- * gui: [
273
- * component
274
- * ]
275
- * })
276
- * class RpgClientEngine {}
277
- * ```
278
288
  *
279
289
  * [Guide: Create GUI](/guide/create-gui.html)
280
290
  *
281
- * @prop {Array<Component of VueJS>} [gui]
291
+ * @prop {Array<Component of CanvasEngine>} [gui]
282
292
  * @memberof RpgClient
283
293
  * */
284
- gui?: any[];
294
+ gui?: ComponentFunction[];
285
295
  /**
286
296
  * Array containing the list of sounds
287
- * An element contains a class with the `@Sound` decorator
297
+ * Each element is a simple object containing sound definitions
288
298
  *
289
299
  * ```ts
290
- * import { Sound, RpgModule, RpgClient } from '@rpgjs/client'
291
- *
292
- * @Sound({
293
- * sounds: {
294
- * town: require('./assets/Town_Theme.ogg')
295
- * }
296
- * })
297
- * class Sounds {}
298
- *
299
- * @RpgModule<RpgClient>({
300
- * sounds: [ Sounds ]
300
+ * import { defineModule, RpgClient } from '@rpgjs/client'
301
+ *
302
+ * defineModule<RpgClient>({
303
+ * sounds: [
304
+ * {
305
+ * town: require('./assets/Town_Theme.ogg'),
306
+ * battle: require('./assets/Battle_Theme.ogg')
307
+ * }
308
+ * ]
301
309
  * })
302
- * class RpgClientEngine {}
303
310
  * ```
304
311
  *
305
- * @prop {Array<Class>} [sounds]
312
+ * @prop {Array<Object>} [sounds]
306
313
  * @memberof RpgClient
307
314
  * */
308
- sounds?: RpgClass[];
315
+ sounds?: any[];
309
316
  /**
310
317
  * Give the `RpgSprite` class. A Sprite represents a player or an event
311
318
  *
312
319
  * ```ts
313
- * import { RpgSprite, RpgSpriteHooks, RpgClient, RpgModule } from '@rpgjs/client'
320
+ * import { RpgSprite, RpgSpriteHooks, RpgClient, defineModule } from '@rpgjs/client'
314
321
  *
315
322
  * export const sprite: RpgSpriteHooks = {
316
323
  * onInit(sprite: RpgSprite) {}
317
324
  * }
318
325
  *
319
- * @RpgModule<RpgClient>({
326
+ * defineModule<RpgClient>({
320
327
  * sprite
321
328
  * })
322
- * class RpgClientEngine {}
323
329
  * ```
324
330
  *
325
331
  * @prop {RpgSpriteHooks} [sprite]
@@ -330,19 +336,18 @@ export interface RpgClient {
330
336
  * Reference the scenes of the game. Here you can put your own class that inherits RpgSceneMap
331
337
  *
332
338
  * ```ts
333
- * import { RpgSceneMapHooks, RpgClient, RpgModule } from '@rpgjs/client'
339
+ * import { RpgSceneMapHooks, RpgClient, defineModule } from '@rpgjs/client'
334
340
  *
335
341
  * export const sceneMap: RpgSceneMapHooks = {
336
342
  *
337
343
  * }
338
344
  *
339
- * @RpgModule<RpgClient>({
345
+ * defineModule<RpgClient>({
340
346
  * scenes: {
341
347
  * // If you put the RpgSceneMap scene, Thhe key is called mandatory `map`
342
348
  * map: sceneMap
343
349
  * }
344
350
  * })
345
- * class RpgClientEngine {}
346
351
  * ```
347
352
  *
348
353
  * @prop { [sceneName: string]: RpgSceneMapHooks } [scenes]
@@ -353,7 +358,7 @@ export interface RpgClient {
353
358
  };
354
359
  effects?: {
355
360
  id: string;
356
- component: any;
361
+ component: ComponentFunction;
357
362
  }[];
358
363
  }
359
364
  export {};
@@ -1,5 +1,8 @@
1
1
  import { Context } from '@signe/di';
2
+ import { AbstractWebsocket } from './services/AbstractSocket';
2
3
  import { EffectManager } from './Game/EffectManager';
4
+ import { Observable } from 'rxjs';
5
+ import * as PIXI from "pixi.js";
3
6
  export declare class RpgClientEngine<T = any> {
4
7
  context: Context;
5
8
  private guiService;
@@ -19,6 +22,11 @@ export declare class RpgClientEngine<T = any> {
19
22
  particleSettings: {
20
23
  emitters: any[];
21
24
  };
25
+ renderer: PIXI.Renderer;
26
+ tick: Observable<number>;
27
+ playerIdSignal: import('canvasengine').WritableSignal<string | null>;
28
+ spriteComponentsBehind: import('canvasengine').WritableArraySignal<any[]>;
29
+ spriteComponentsInFront: import('canvasengine').WritableArraySignal<any[]>;
22
30
  constructor(context: Context);
23
31
  start(): Promise<void>;
24
32
  private initListeners;
@@ -26,6 +34,34 @@ export declare class RpgClientEngine<T = any> {
26
34
  addSpriteSheet<T = any>(spritesheetClass: any, id?: string): any;
27
35
  addSound(sound: any, id?: string): any;
28
36
  addParticle(particle: any): any;
37
+ /**
38
+ * Add a component to render behind sprites
39
+ * Components added with this method will be displayed with a lower z-index than the sprite
40
+ *
41
+ * @param component - The component to add behind sprites
42
+ * @returns The added component
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * // Add a shadow component behind all sprites
47
+ * engine.addSpriteComponentBehind(ShadowComponent);
48
+ * ```
49
+ */
50
+ addSpriteComponentBehind(component: any): any;
51
+ /**
52
+ * Add a component to render in front of sprites
53
+ * Components added with this method will be displayed with a higher z-index than the sprite
54
+ *
55
+ * @param component - The component to add in front of sprites
56
+ * @returns The added component
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * // Add a health bar component in front of all sprites
61
+ * engine.addSpriteComponentInFront(HealthBarComponent);
62
+ * ```
63
+ */
64
+ addSpriteComponentInFront(component: any): any;
29
65
  addEffect(effect: {
30
66
  component: any;
31
67
  id: string;
@@ -40,4 +76,7 @@ export declare class RpgClientEngine<T = any> {
40
76
  processAction({ action }: {
41
77
  action: number;
42
78
  }): void;
79
+ get PIXI(): typeof PIXI;
80
+ get socket(): AbstractWebsocket;
81
+ get playerId(): string | null;
43
82
  }
package/dist/index13.js CHANGED
@@ -9,7 +9,7 @@ function component($$props) {
9
9
  var engine = inject(RpgClientEngine);
10
10
  var players = engine.sceneMap.players;
11
11
  var events = engine.sceneMap.events;
12
- let $this = h(Container, { sortableChildren: true }, [loop(events, (event, id) => h(component$1, { id: id, object: event, isMe: false })), loop(players, (player, id) => h(component$1, { id: id, object: player, isMe: true }))]);
12
+ let $this = h(Container, { sortableChildren: true }, [loop(events, (event, id) => h(component$1, { id: id, object: event })), loop(players, (player, id) => h(component$1, { id: id, object: player }))]);
13
13
  return $this
14
14
  }
15
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"index13.js","sources":["../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} isMe={false} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} isMe={true} />\n }\n</Container>\n\n<script>\n import { effect, signal } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n \n const engine = inject(RpgClientEngine);\n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>"],"names":["Character"],"mappings":";;;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAA4B,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AAC5C,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO;AACrC,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrO,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index13.js","sources":["../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n</Container>\n\n<script>\n import { effect, signal } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n \n const engine = inject(RpgClientEngine);\n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>"],"names":["Character"],"mappings":";;;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAA4B,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AAC5C,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO;AACrC,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5M,QAAQ,OAAO;AACf;;;;"}
package/dist/index14.js CHANGED
@@ -1,15 +1,20 @@
1
- import { useProps, useDefineProps, computed, signal, h, Container, loop, Sprite } from 'canvasengine';
1
+ import { useProps, useDefineProps, computed, signal, mount, tick, h, Container, loop, Sprite } from 'canvasengine';
2
2
  import { Particle } from '@canvasengine/presets';
3
+ import { Direction, ModulesToken } from '@rpgjs/common';
3
4
  import { RpgClientEngine } from './index2.js';
4
5
  import { inject } from './index6.js';
5
- import { Direction } from '@rpgjs/common';
6
6
 
7
7
  function component($$props) {
8
8
  useProps($$props);
9
9
  const defineProps = useDefineProps($$props);
10
- var _a = defineProps(), object = _a.object; _a.id; var isMe = _a.isMe;
10
+ var _a = defineProps(), object = _a.object, id = _a.id;
11
11
  var client = inject(RpgClientEngine);
12
+ var hooks = inject(ModulesToken);
12
13
  var spritesheets = client.spritesheets;
14
+ var playerId = client.playerId;
15
+ var componentsBehind = client.spriteComponentsBehind;
16
+ var componentsInFront = client.spriteComponentsInFront;
17
+ var isMe = computed(function () { return id() === playerId; });
13
18
  var x = object.x;
14
19
  var y = object.y;
15
20
  var tint = object.tint;
@@ -83,7 +88,18 @@ var sheet = function (graphicId) {
83
88
  },
84
89
  };
85
90
  };
86
- let $this = h(Container, { x, y, zIndex: y, viewportFollow: isMe, controls }, [h(Particle, { emit: emitParticleTrigger, settings: particleSettings, zIndex: 1000, name: particleName }), loop(graphics, graphicId => h(Sprite, { sheet: sheet(graphicId), direction, tint }))]);
91
+ mount(function (element) {
92
+ hooks.callHooks("client-sprite-onInit", element.componentInstance);
93
+ hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, element.componentInstance);
94
+ return function () {
95
+ hooks.callHooks("client-sprite-onDestroy", element.componentInstance);
96
+ hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, element.componentInstance);
97
+ };
98
+ });
99
+ tick(function () {
100
+ hooks.callHooks("client-sprite-onUpdate");
101
+ });
102
+ let $this = h(Container, { x, y, zIndex: y, viewportFollow: isMe, controls }, [loop(componentsBehind, component => h(Container, null, h(component, { object }))), h(Particle, { emit: emitParticleTrigger, settings: particleSettings, zIndex: 1000, name: particleName }), h(Container, null, loop(graphics, graphicId => h(Sprite, { sheet: sheet(graphicId), direction, tint }))), loop(componentsInFront, component => h(Container, null, h(component, { object })))]);
87
103
  return $this
88
104
  }
89
105
 
@@ -1 +1 @@
1
- {"version":3,"file":"index14.js","sources":["../src/components/character.ce"],"sourcesContent":["<Container x y zIndex={y} viewportFollow={isMe} controls>\n <Particle emit={@emitParticleTrigger} settings={@particleSettings} zIndex={1000} name={particleName} />\n @for (graphicId of graphics) {\n <Sprite sheet={@sheet(@graphicId)} direction tint />\n }\n <!-- <Ellipse \n x={shadow.@x} \n y={shadow.@y} \n width={shadow.@width} \n height={shadow.@height} \n color=\"black\" \n blur={10} \n alpha={0.5}\n /> -->\n</Container>\n\n<script>\n import { signal, effect, mount, computed } from \"canvasengine\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n\n const { object, id, isMe } = defineProps();\n\n const client = inject(RpgClientEngine);\n\n const spritesheets = client.spritesheets;\n\n const x = object.x;\n const y = object.y;\n const tint = object.tint;\n const direction = object.direction;\n const animationName = object.animationName;\n const emitParticleTrigger = object.emitParticleTrigger;\n const particleSettings = client.particleSettings;\n const particleName = object.particleName;\n const graphics = object.graphics;\n\n const hitbox = object.hitbox;\n const widthShadow = 10;\n const shadow = computed(() => ({\n x: hitbox().w / 2,\n y: hitbox().h - (hitbox().h / 2),\n width: hitbox().w + widthShadow,\n height: hitbox().h,\n }))\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n // particleName.set('hit') \n // emitParticleTrigger.start()\n // object.flash('red')\n }\n },\n },\n });\n\n const sheet = (graphicId) => {\n return {\n definition: spritesheets.get(graphicId),\n playing: animationName,\n params: {\n direction\n },\n };\n }\n</script>"],"names":[],"mappings":";;;;;;AAWqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAW,IAAC,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAAM,EAAE,CAAC,EAAE,CAAC,KAAC,IAAI,GAAG,EAAE,CAAC;AAC1E,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY;AACtC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;AAChB,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;AAChB,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI;AACtB,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS;AAChC,IAAI,aAAa,GAAG,MAAM,CAAC,aAAa;AACxC,IAAI,mBAAmB,GAAG,MAAM,CAAC,mBAAmB;AACpD,IAAI,gBAAgB,GAAG,MAAM,CAAC,gBAAgB;AAC9C,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY;AACtC,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ;AAC9B,IAAI,MAAM,GAAG,MAAM,C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AAI,CAAC,QAAQ,EAAE,SAAS,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACtR,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index14.js","sources":["../src/components/character.ce"],"sourcesContent":["<Container x y zIndex={y} viewportFollow={isMe} controls>\n @for (component of componentsBehind) {\n <Container>\n <component object />\n </Container>\n } \n <Particle emit={@emitParticleTrigger} settings={@particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicId of graphics) {\n <Sprite sheet={@sheet(@graphicId)} direction tint />\n }\n </Container>\n @for (component of componentsInFront) {\n <Container>\n <component object />\n </Container>\n } \n <!-- <Ellipse \n x={shadow.@x} \n y={shadow.@y} \n width={shadow.@width} \n height={shadow.@height} \n color=\"black\" \n blur={10} \n alpha={0.5}\n /> -->\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick } from \"canvasengine\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n\n const { object, id } = defineProps();\n \n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n\n const spritesheets = client.spritesheets;\n const playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\n\n const x = object.x;\n const y = object.y;\n const tint = object.tint;\n const direction = object.direction;\n const animationName = object.animationName;\n const emitParticleTrigger = object.emitParticleTrigger;\n const particleSettings = client.particleSettings;\n const particleName = object.particleName;\n const graphics = object.graphics;\n\n const hitbox = object.hitbox;\n const widthShadow = 10;\n const shadow = computed(() => ({\n x: hitbox().w / 2,\n y: hitbox().h - (hitbox().h / 2),\n width: hitbox().w + widthShadow,\n height: hitbox().h,\n }))\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n // particleName.set('hit') \n // emitParticleTrigger.start()\n // object.flash('red')\n }\n },\n },\n });\n\n const sheet = (graphicId) => {\n return {\n definition: spritesheets.get(graphicId),\n playing: animationName,\n params: {\n direction\n },\n };\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onInit\", element.componentInstance)\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, element.componentInstance)\n\n return () => {\n hooks.callHooks(\"client-sprite-onDestroy\", element.componentInstance)\n hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, element.componentInstance)\n }\n })\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\")\n })\n</script>"],"names":[],"mappings":";;;;;;AAYqB,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,EAAE,GAAG,EAAE,CAAC,EAAE;AAC9D,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG,MAAM,CAAC,Y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AAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AACjd,QAAQ,OAAO;AACf;;;;"}
package/dist/index2.js CHANGED
@@ -10,6 +10,7 @@ import { RpgGui } from './index9.js';
10
10
  import { EffectManager } from './index20.js';
11
11
  import { lastValueFrom } from 'rxjs';
12
12
  import { GlobalConfigToken } from './index8.js';
13
+ import * as PIXI from 'pixi.js';
13
14
 
14
15
  class RpgClientEngine {
15
16
  constructor(context) {
@@ -24,6 +25,9 @@ class RpgClientEngine {
24
25
  this.particleSettings = {
25
26
  emitters: []
26
27
  };
28
+ this.playerIdSignal = signal(null);
29
+ this.spriteComponentsBehind = signal([]);
30
+ this.spriteComponentsInFront = signal([]);
27
31
  this.webSocket = inject(context, WebSocketToken);
28
32
  this.guiService = inject(context, RpgGui);
29
33
  this.loadMapService = inject(context, LoadMapToken);
@@ -32,13 +36,22 @@ class RpgClientEngine {
32
36
  }
33
37
  async start() {
34
38
  this.selector = document.body.querySelector("#rpg");
35
- await bootstrapCanvas(this.selector, component);
39
+ const { app, canvasElement } = await bootstrapCanvas(this.selector, component);
40
+ this.renderer = app.renderer;
41
+ this.tick = canvasElement?.propObservables?.context["tick"].observable;
36
42
  await lastValueFrom(this.hooks.callHooks("client-engine-onStart", this));
43
+ window.addEventListener("resize", () => {
44
+ this.hooks.callHooks("client-engine-onWindowResize", this).subscribe();
45
+ });
46
+ this.tick.subscribe((tick) => {
47
+ this.hooks.callHooks("client-engine-onStep", this, tick).subscribe();
48
+ });
37
49
  this.hooks.callHooks("client-spritesheets-load", this).subscribe();
38
50
  this.hooks.callHooks("client-sounds-load", this).subscribe();
39
51
  this.hooks.callHooks("client-gui-load", this).subscribe();
40
52
  this.hooks.callHooks("client-particles-load", this).subscribe();
41
53
  this.hooks.callHooks("client-effects-load", this).subscribe();
54
+ this.hooks.callHooks("client-sprite-load", this).subscribe();
42
55
  await this.webSocket.connection(() => {
43
56
  this.initListeners();
44
57
  this.guiService._initialize();
@@ -46,6 +59,8 @@ class RpgClientEngine {
46
59
  }
47
60
  initListeners() {
48
61
  this.webSocket.on("sync", (data) => {
62
+ if (data.pId) this.playerIdSignal.set(data.pId);
63
+ this.hooks.callHooks("client-sceneMap-onChanges", this.sceneMap, { partial: data }).subscribe();
49
64
  load(this.sceneMap, data, true);
50
65
  });
51
66
  this.webSocket.on("changeMap", (data) => {
@@ -59,6 +74,15 @@ class RpgClientEngine {
59
74
  const player = this.sceneMap.getObjectById(object);
60
75
  this.getEffect(id).displayEffect(params, player);
61
76
  });
77
+ this.webSocket.on("open", () => {
78
+ this.hooks.callHooks("client-engine-onConnected", this, this.socket).subscribe();
79
+ });
80
+ this.webSocket.on("close", () => {
81
+ this.hooks.callHooks("client-engine-onDisconnected", this, this.socket).subscribe();
82
+ });
83
+ this.webSocket.on("error", (error) => {
84
+ this.hooks.callHooks("client-engine-onConnectError", this, error, this.socket).subscribe();
85
+ });
62
86
  }
63
87
  async loadScene(mapId) {
64
88
  this.webSocket.updateProperties({ room: mapId });
@@ -82,6 +106,40 @@ class RpgClientEngine {
82
106
  this.particleSettings.emitters.push(particle);
83
107
  return particle;
84
108
  }
109
+ /**
110
+ * Add a component to render behind sprites
111
+ * Components added with this method will be displayed with a lower z-index than the sprite
112
+ *
113
+ * @param component - The component to add behind sprites
114
+ * @returns The added component
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // Add a shadow component behind all sprites
119
+ * engine.addSpriteComponentBehind(ShadowComponent);
120
+ * ```
121
+ */
122
+ addSpriteComponentBehind(component) {
123
+ this.spriteComponentsBehind.update((components) => [...components, component]);
124
+ return component;
125
+ }
126
+ /**
127
+ * Add a component to render in front of sprites
128
+ * Components added with this method will be displayed with a higher z-index than the sprite
129
+ *
130
+ * @param component - The component to add in front of sprites
131
+ * @returns The added component
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * // Add a health bar component in front of all sprites
136
+ * engine.addSpriteComponentInFront(HealthBarComponent);
137
+ * ```
138
+ */
139
+ addSpriteComponentInFront(component) {
140
+ this.spriteComponentsInFront.update((components) => [...components, component]);
141
+ return component;
142
+ }
85
143
  addEffect(effect) {
86
144
  const instance = new EffectManager();
87
145
  this.effects.push({
@@ -100,12 +158,23 @@ class RpgClientEngine {
100
158
  return effect.instance;
101
159
  }
102
160
  processInput({ input }) {
161
+ this.hooks.callHooks("client-engine-onInput", this, { input, playerId: this.playerId }).subscribe();
103
162
  this.webSocket.emit("move", { input });
104
163
  }
105
164
  processAction({ action }) {
106
165
  if (this.stopProcessingInput) return;
166
+ this.hooks.callHooks("client-engine-onInput", this, { input: "action", playerId: this.playerId }).subscribe();
107
167
  this.webSocket.emit("action", { action });
108
168
  }
169
+ get PIXI() {
170
+ return PIXI;
171
+ }
172
+ get socket() {
173
+ return this.webSocket;
174
+ }
175
+ get playerId() {
176
+ return this.playerIdSignal();
177
+ }
109
178
  }
110
179
 
111
180
  export { RpgClientEngine };
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","sources":["../src/RpgClientEngine.ts"],"sourcesContent":["import Canvas from \"./components/scenes/canvas.ce\";\nimport { Context, inject } from \"@signe/di\";\nimport { signal, bootstrapCanvas } from \"canvasengine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./services/AbstractSocket\";\nimport { LoadMapService, LoadMapToken } from \"./services/loadMap\";\nimport { Hooks, ModulesToken } from \"@rpgjs/common\";\nimport { load } from \"@signe/sync\";\nimport { RpgClientMap } from \"./Game/Map\"\nimport { RpgGui } from \"./Gui/Gui\";\nimport { EffectManager } from \"./Game/EffectManager\";\nimport { lastValueFrom } from \"rxjs\";\nimport { GlobalConfigToken } from \"./module\";\nimport { ClientIo } from \"@signe/room\";\n\nexport class RpgClientEngine<T = any> {\n private guiService: RpgGui;\n private webSocket: AbstractWebsocket;\n private loadMapService: LoadMapService;\n private hooks: Hooks;\n private sceneMap: RpgClientMap = new RpgClientMap();\n private selector: HTMLElement;\n public globalConfig: T;\n public sceneComponent: any;\n stopProcessingInput = false;\n\n width = signal(\"100%\");\n height = signal(\"100%\");\n spritesheets: Map<string, any> = new Map();\n sounds: Map<string, any> = new Map();\n effects: any[] = [];\n particleSettings: {\n emitters: any[]\n } = {\n emitters: []\n }\n\n constructor(public context: Context) {\n this.webSocket = inject(context, WebSocketToken);\n this.guiService = inject(context, RpgGui);\n this.loadMapService = inject(context, LoadMapToken);\n this.hooks = inject<Hooks>(context, ModulesToken);\n this.globalConfig = inject(context, GlobalConfigToken)\n }\n\n async start() {\n this.selector = document.body.querySelector(\"#rpg\") as HTMLElement;\n\n await bootstrapCanvas(this.selector, Canvas);\n\n await lastValueFrom(this.hooks.callHooks(\"client-engine-onStart\", this));\n\n this.hooks.callHooks(\"client-spritesheets-load\", this).subscribe();\n this.hooks.callHooks(\"client-sounds-load\", this).subscribe();\n this.hooks.callHooks(\"client-gui-load\", this).subscribe();\n this.hooks.callHooks(\"client-particles-load\", this).subscribe();\n this.hooks.callHooks(\"client-effects-load\", this).subscribe();\n\n \n await this.webSocket.connection(() => {\n this.initListeners()\n this.guiService._initialize()\n });\n }\n\n private initListeners() {\n this.webSocket.on(\"sync\", (data) => {\n load(this.sceneMap, data, true);\n });\n\n this.webSocket.on(\"changeMap\", (data) => {\n this.loadScene(data.mapId);\n });\n\n this.webSocket.on(\"showEffect\", (data) => {\n const { params, object, id } = data;\n if (!object) {\n throw new Error(\"Object not found\");\n }\n const player = this.sceneMap.getObjectById(object);\n this.getEffect(id).displayEffect(params, player)\n });\n }\n \n private async loadScene(mapId: string) {\n this.webSocket.updateProperties({ room: mapId })\n await this.webSocket.reconnect(() => {\n this.initListeners()\n this.guiService._initialize()\n })\n const res = await this.loadMapService.load(mapId)\n this.sceneMap.data.set(res)\n this.hooks.callHooks(\"client-sceneMap-onAfterLoading\", this.sceneMap).subscribe();\n //this.sceneMap.loadPhysic()\n }\n\n addSpriteSheet<T = any>(spritesheetClass: any, id?: string): any {\n this.spritesheets.set(id || spritesheetClass.id, spritesheetClass);\n return spritesheetClass as any;\n }\n\n addSound(sound: any, id?: string) {\n this.sounds.set(id || sound.id, sound);\n return sound;\n }\n\n addParticle(particle: any) {\n this.particleSettings.emitters.push(particle)\n return particle;\n }\n\n addEffect(effect: {\n component: any,\n id: string\n }) {\n const instance = new EffectManager()\n this.effects.push({\n id: effect.id,\n component: effect.component,\n instance: instance,\n current: instance.current\n })\n return effect;\n }\n\n getEffect(id: string): EffectManager {\n const effect = this.effects.find((effect) => effect.id === id)\n if (!effect) {\n throw new Error(`Effect with id ${id} not found`)\n }\n return effect.instance\n }\n\n processInput({ input }: { input: number }) {\n this.webSocket.emit('move', { input })\n }\n\n processAction({ action }: { action: number }) {\n if (this.stopProcessingInput) return;\n this.webSocket.emit('action', { action })\n }\n}\n"],"names":["Canvas","effect"],"mappings":";;;;;;;;;;;;;AAcO,MAAM,eAAyB,CAAA;AAAA,EAsBpC,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAjBnB,IAAQ,IAAA,CAAA,QAAA,GAAyB,IAAI,YAAa,EAAA;AAIlD,IAAsB,IAAA,CAAA,mBAAA,GAAA,KAAA;AAEtB,IAAA,IAAA,CAAA,KAAA,GAAQ,OAAO,MAAM,CAAA;AACrB,IAAA,IAAA,CAAA,MAAA,GAAS,O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CAAC,MAAQ,EAAA;AACX,MAAA,MAAM,IAAI,KAAA,CAAM,CAAkB,eAAA,EAAA,EAAE,CAAY,UAAA,CAAA,CAAA;AAAA;AAElD,IAAA,OAAO,MAAO,CAAA,QAAA;AAAA;AAChB,EAEA,YAAA,CAAa,EAAE,KAAA,EAA4B,EAAA;AACzC,IAAA,IAAA,CAAK,SAAU,CAAA,IAAA,CAAK,MAAQ,EAAA,EAAE,OAAO,CAAA;AAAA;AACvC,EAEA,aAAA,CAAc,EAAE,MAAA,EAA8B,EAAA;AAC5C,IAAA,IAAI,KAAK,mBAAqB,EAAA;AAC9B,IAAA,IAAA,CAAK,SAAU,CAAA,IAAA,CAAK,QAAU,EAAA,EAAE,QAAQ,CAAA;AAAA;AAE5C;;;;"}
1
+ {"version":3,"file":"index2.js","sources":["../src/RpgClientEngine.ts"],"sourcesContent":["import Canvas from \"./components/scenes/canvas.ce\";\nimport { Context, inject } from \"@signe/di\";\nimport { signal, bootstrapCanvas } from \"canvasengine\";\nimport { AbstractWebsocket, WebSocketToken } from \"./services/AbstractSocket\";\nimport { LoadMapService, LoadMapToken } from \"./services/loadMap\";\nimport { Hooks, ModulesToken } from \"@rpgjs/common\";\nimport { load } from \"@signe/sync\";\nimport { RpgClientMap } from \"./Game/Map\"\nimport { RpgGui } from \"./Gui/Gui\";\nimport { EffectManager } from \"./Game/EffectManager\";\nimport { lastValueFrom, Observable } from \"rxjs\";\nimport { GlobalConfigToken } from \"./module\";\nimport * as PIXI from \"pixi.js\";\n\nexport class RpgClientEngine<T = any> {\n private guiService: RpgGui;\n private webSocket: AbstractWebsocket;\n private loadMapService: LoadMapService;\n private hooks: Hooks;\n private sceneMap: RpgClientMap = new RpgClientMap();\n private selector: HTMLElement;\n public globalConfig: T;\n public sceneComponent: any;\n stopProcessingInput = false;\n width = signal(\"100%\");\n height = signal(\"100%\");\n spritesheets: Map<string, any> = new Map();\n sounds: Map<string, any> = new Map();\n effects: any[] = [];\n particleSettings: {\n emitters: any[]\n } = {\n emitters: []\n }\n renderer: PIXI.Renderer;\n tick: Observable<number>;\n playerIdSignal = signal<string | null>(null);\n spriteComponentsBehind = signal<any[]>([]);\n spriteComponentsInFront = signal<any[]>([]);\n\n constructor(public context: Context) {\n this.webSocket = inject(context, WebSocketToken);\n this.guiService = inject(context, RpgGui);\n this.loadMapService = inject(context, LoadMapToken);\n this.hooks = inject<Hooks>(context, ModulesToken);\n this.globalConfig = inject(context, GlobalConfigToken)\n }\n\n async start() {\n this.selector = document.body.querySelector(\"#rpg\") as HTMLElement;\n\n const { app, canvasElement } = await bootstrapCanvas(this.selector, Canvas);\n this.renderer = app.renderer as PIXI.Renderer;\n this.tick = canvasElement?.propObservables?.context['tick'].observable\n\n await lastValueFrom(this.hooks.callHooks(\"client-engine-onStart\", this));\n\n // wondow is resize\n window.addEventListener('resize', () => {\n this.hooks.callHooks(\"client-engine-onWindowResize\", this).subscribe();\n })\n\n this.tick.subscribe((tick) => {\n this.hooks.callHooks(\"client-engine-onStep\", this, tick).subscribe();\n })\n\n this.hooks.callHooks(\"client-spritesheets-load\", this).subscribe();\n this.hooks.callHooks(\"client-sounds-load\", this).subscribe();\n this.hooks.callHooks(\"client-gui-load\", this).subscribe();\n this.hooks.callHooks(\"client-particles-load\", this).subscribe();\n this.hooks.callHooks(\"client-effects-load\", this).subscribe();\n this.hooks.callHooks(\"client-sprite-load\", this).subscribe();\n\n \n await this.webSocket.connection(() => {\n this.initListeners()\n this.guiService._initialize()\n });\n }\n\n private initListeners() {\n this.webSocket.on(\"sync\", (data) => {\n if (data.pId) this.playerIdSignal.set(data.pId)\n this.hooks.callHooks(\"client-sceneMap-onChanges\", this.sceneMap, { partial: data }).subscribe();\n load(this.sceneMap, data, true);\n });\n\n this.webSocket.on(\"changeMap\", (data) => {\n this.loadScene(data.mapId);\n });\n\n this.webSocket.on(\"showEffect\", (data) => {\n const { params, object, id } = data;\n if (!object) {\n throw new Error(\"Object not found\");\n }\n const player = this.sceneMap.getObjectById(object);\n this.getEffect(id).displayEffect(params, player)\n });\n\n this.webSocket.on('open', () => {\n this.hooks.callHooks(\"client-engine-onConnected\", this, this.socket).subscribe();\n })\n\n this.webSocket.on('close', () => {\n this.hooks.callHooks(\"client-engine-onDisconnected\", this, this.socket).subscribe();\n })\n\n this.webSocket.on('error', (error) => {\n this.hooks.callHooks(\"client-engine-onConnectError\", this, error, this.socket).subscribe();\n })\n }\n \n private async loadScene(mapId: string) {\n this.webSocket.updateProperties({ room: mapId })\n await this.webSocket.reconnect(() => {\n this.initListeners()\n this.guiService._initialize()\n })\n const res = await this.loadMapService.load(mapId)\n this.sceneMap.data.set(res)\n this.hooks.callHooks(\"client-sceneMap-onAfterLoading\", this.sceneMap).subscribe();\n //this.sceneMap.loadPhysic()\n }\n\n addSpriteSheet<T = any>(spritesheetClass: any, id?: string): any {\n this.spritesheets.set(id || spritesheetClass.id, spritesheetClass);\n return spritesheetClass as any;\n }\n\n addSound(sound: any, id?: string) {\n this.sounds.set(id || sound.id, sound);\n return sound;\n }\n\n addParticle(particle: any) {\n this.particleSettings.emitters.push(particle)\n return particle;\n }\n\n /**\n * Add a component to render behind sprites\n * Components added with this method will be displayed with a lower z-index than the sprite\n * \n * @param component - The component to add behind sprites\n * @returns The added component\n * \n * @example\n * ```ts\n * // Add a shadow component behind all sprites\n * engine.addSpriteComponentBehind(ShadowComponent);\n * ```\n */\n addSpriteComponentBehind(component: any) {\n this.spriteComponentsBehind.update((components: any[]) => [...components, component])\n return component\n }\n\n /**\n * Add a component to render in front of sprites\n * Components added with this method will be displayed with a higher z-index than the sprite\n * \n * @param component - The component to add in front of sprites\n * @returns The added component\n * \n * @example\n * ```ts\n * // Add a health bar component in front of all sprites\n * engine.addSpriteComponentInFront(HealthBarComponent);\n * ```\n */\n addSpriteComponentInFront(component: any) {\n this.spriteComponentsInFront.update((components: any[]) => [...components, component])\n return component\n }\n\n addEffect(effect: {\n component: any,\n id: string\n }) {\n const instance = new EffectManager()\n this.effects.push({\n id: effect.id,\n component: effect.component,\n instance: instance,\n current: instance.current\n })\n return effect;\n }\n\n getEffect(id: string): EffectManager {\n const effect = this.effects.find((effect) => effect.id === id)\n if (!effect) {\n throw new Error(`Effect with id ${id} not found`)\n }\n return effect.instance\n }\n\n processInput({ input }: { input: number }) {\n this.hooks.callHooks(\"client-engine-onInput\", this, { input, playerId: this.playerId }).subscribe();\n this.webSocket.emit('move', { input })\n }\n\n processAction({ action }: { action: number }) {\n if (this.stopProcessingInput) return;\n this.hooks.callHooks(\"client-engine-onInput\", this, { input: 'action', playerId: this.playerId }).subscribe();\n this.webSocket.emit('action', { action })\n }\n\n get PIXI() {\n return PIXI\n }\n\n get socket() {\n return this.webSocket\n }\n \n get playerId() {\n return this.playerIdSignal()\n }\n}\n"],"names":["Canvas","effect"],"mappings":";;;;;;;;;;;;;;AAcO,MAAM,eAAyB,CAAA;AAAA,EA0BpC,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AArBnB,IAAQ,IAAA,CAAA,QAAA,GAAyB,IAAI,YAAa,EAAA;AAIlD,IAAsB,IAAA,CAAA,mBAAA,GAAA,KAAA;AACtB,IAAA,IAAA,CAAA,KAAA,GAAQ,OAAO,MAAM,CAAA;AACrB,IAAA,IAAA,CAAA,MAAA,GAAS,OAAO,MAAM,CAAA;AACtB,IAAA,IAAA,CAAA,YAAA,uBAAqC,GAAI,EAAA;AACzC,IAAA,IAAA,CAAA,MAAA,uBAA+B,GAAI,EAAA;AACnC,IAAA,IAAA,CAAA,OAAA,GAAiB,EAAC;AAClB,IAEI,IAAA,CAAA,gBAAA,GAAA;AAAA,MACF,UAAU;AAAC,KACb;AAGA,IAAA,IAAA,CAAA,cAAA,GAAiB,OAAsB,IAAI,CAAA;AAC3C,IAAyB,IAAA,CAAA,sBAAA,GAAA,MAAA,CAAc,EAAE,CAAA;AACzC,IAA0B,IAAA,CAAA,uBAAA,GAAA,MAAA,CAAc,EAAE,CAAA;AAGxC,IAAK,IAA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AA;AACT,IAAO,OAAA,IAAA;AAAA;AACT,EAEA,IAAI,MAAS,GAAA;AACX,IAAA,OAAO,IAAK,CAAA,SAAA;AAAA;AACd,EAEA,IAAI,QAAW,GAAA;AACb,IAAA,OAAO,KAAK,cAAe,EAAA;AAAA;AAE/B;;;;"}
package/dist/index21.js CHANGED
@@ -1,7 +1,7 @@
1
- import { dset } from './index32.js';
2
- import z from './index33.js';
1
+ import { dset } from './index34.js';
2
+ import z from './index35.js';
3
3
  import { syncClass, generateShortUUID as generateShortUUID$1, createStatesSnapshot, id, sync, persist, load, getByPath, DELETE_TOKEN } from './index18.js';
4
- import { signal } from './index34.js';
4
+ import { signal } from './index36.js';
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
package/dist/index22.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __name } from './index27.js';
2
2
  import { load } from './index18.js';
3
- import { PartySocket } from './index35.js';
4
- import './index36.js';
3
+ import { PartySocket } from './index32.js';
4
+ import './index33.js';
5
5
 
6
6
  function createConnection(options, roomInstance) {
7
7
  const conn = new PartySocket(options);
package/dist/index30.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RpgClientObject } from './index38.js';
1
+ import { RpgClientObject } from './index39.js';
2
2
 
3
3
  class RpgClientPlayer extends RpgClientObject {
4
4
  constructor() {
package/dist/index31.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RpgClientObject } from './index38.js';
1
+ import { RpgClientObject } from './index39.js';
2
2
 
3
3
  class RpgClientEvent extends RpgClientObject {
4
4
  constructor() {