vue-phaserjs 4.1.1 → 4.2.0

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 (3) hide show
  1. package/package.json +5 -5
  2. package/dist/index.d.ts +0 -11293
  3. package/dist/index.js +0 -1876
package/dist/index.js DELETED
@@ -1,1876 +0,0 @@
1
- import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, inject, nextTick, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, shallowRef, toValue, useTemplateRef, watch } from "vue";
2
- import { ID_SEPARATOR, InvalidOperationError, NotFoundError, NotInitializedError, Operation, getOrCreate, takeOne, toKebabCase } from "@esposter/shared";
3
- import ClickOutside from "phaser4-rex-plugins/plugins/clickoutside.js";
4
- import { Cameras, Core, Game, Loader, Scene, Scenes, Tilemaps, Tweens, Utils } from "phaser";
5
- import { defineStore, storeToRefs } from "pinia";
6
- import { parseTileset } from "parse-tmx";
7
- //#region src/services/emit/constants.ts
8
- const EVENT_PREFIX = "on";
9
- //#endregion
10
- //#region src/services/emit/checkIsEvent.ts
11
- const checkIsEvent = (property) => property.startsWith("on");
12
- //#endregion
13
- //#region src/services/emit/GameObjectEventMap.ts
14
- const GameObjectEventMap = {
15
- clickoutside: {},
16
- drag: { drag: true },
17
- dragend: { drag: true },
18
- dragenter: { drag: true },
19
- dragleave: { drag: true },
20
- dragover: { drag: true },
21
- dragstart: { drag: true },
22
- drop: { drag: true },
23
- pointerdown: { eventIndex: 3 },
24
- pointermove: { eventIndex: 3 },
25
- pointerout: { eventIndex: 1 },
26
- pointerover: { eventIndex: 3 },
27
- pointerup: { eventIndex: 3 },
28
- wheel: { eventIndex: 4 }
29
- };
30
- //#endregion
31
- //#region src/services/emit/getEventName.ts
32
- const getEventName = (event) => {
33
- if (!event.startsWith("on") || event.length <= 2) throw new InvalidOperationError(Operation.Read, getEventName.name, event);
34
- return event.slice(2).toLowerCase();
35
- };
36
- //#endregion
37
- //#region src/composables/useInitializeGameObjectEvents.ts
38
- const useInitializeGameObjectEvents = () => {
39
- const currentInstance = getCurrentInstance();
40
- const events = new Set(Object.keys(currentInstance?.attrs ?? {}).filter((key) => checkIsEvent(key)).map((key) => getEventName(key)));
41
- const gameObjectEvents = Object.keys(GameObjectEventMap).filter((key) => events.has(key));
42
- const eventStopHandles = [];
43
- const initializeGameObjectEvents = (gameObject, emit, scene) => {
44
- if (gameObjectEvents.length === 0) return;
45
- if (!gameObject.input) gameObject.setInteractive();
46
- if (gameObjectEvents.some((key) => "drag" in GameObjectEventMap[key])) scene.input.setDraggable(gameObject);
47
- for (const gameObjectEvent of gameObjectEvents) {
48
- const context = GameObjectEventMap[gameObjectEvent];
49
- const eventListener = (...args) => {
50
- if ("eventIndex" in context) takeOne(args).stopPropagation = takeOne(args, context.eventIndex).stopPropagation;
51
- emit(gameObjectEvent, ...args);
52
- };
53
- const emitter = gameObjectEvent === "clickoutside" ? new ClickOutside(gameObject) : gameObject;
54
- emitter.on(gameObjectEvent, eventListener);
55
- eventStopHandles.push(() => {
56
- emitter.off(gameObjectEvent, eventListener);
57
- });
58
- }
59
- };
60
- return {
61
- eventStopHandles,
62
- initializeGameObjectEvents
63
- };
64
- };
65
- //#endregion
66
- //#region src/services/shared/InjectionKeyMap.ts
67
- const InjectionKeyMap = {
68
- ParentContainer: Symbol("ParentContainer"),
69
- SceneKey: Symbol("SceneKey")
70
- };
71
- //#endregion
72
- //#region src/composables/useInjectSceneKey.ts
73
- const useInjectSceneKey = () => {
74
- const sceneKey = inject(InjectionKeyMap.SceneKey);
75
- if (!sceneKey) throw new NotInitializedError(InjectionKeyMap.SceneKey.description ?? "");
76
- return sceneKey;
77
- };
78
- //#endregion
79
- //#region src/models/lifecycle/Lifecycle.ts
80
- let Lifecycle = /* @__PURE__ */ function(Lifecycle) {
81
- Lifecycle["Create"] = "Create";
82
- Lifecycle["Init"] = "Init";
83
- Lifecycle["NextTick"] = "NextTick";
84
- Lifecycle["Preload"] = "Preload";
85
- Lifecycle["Shutdown"] = "Shutdown";
86
- Lifecycle["Update"] = "Update";
87
- return Lifecycle;
88
- }({});
89
- //#endregion
90
- //#region src/store/ExternalSceneStore.ts
91
- const ExternalSceneStore = {
92
- lifecycleListenersMap: /* @__PURE__ */ new Map(),
93
- sceneReadyMap: /* @__PURE__ */ new Map()
94
- };
95
- //#endregion
96
- //#region src/services/hooks/pushListener.ts
97
- const pushListener = (lifecycle, listener, key) => {
98
- const sceneKey = key ?? useInjectSceneKey();
99
- const listenersMap = getOrCreate(ExternalSceneStore.lifecycleListenersMap, lifecycle, () => /* @__PURE__ */ new Map());
100
- getOrCreate(listenersMap, sceneKey, () => []).push(listener);
101
- };
102
- //#endregion
103
- //#region src/hooks/onNextTick.ts
104
- const onNextTick = (...args) => {
105
- pushListener("NextTick", ...args);
106
- };
107
- //#endregion
108
- //#region src/services/emit/getUpdateEvent.ts
109
- const getUpdateEvent = (property) => `update:${toKebabCase(property)}`;
110
- //#endregion
111
- //#region src/composables/useInitializeGameObjectSetters.ts
112
- const useInitializeGameObjectSetters = (gameObject, configuration, emit, setterMap, immediate) => {
113
- const sceneKey = useInjectSceneKey();
114
- const setters = [];
115
- const setterWatchHandles = [];
116
- for (const [key, value] of Object.entries(toValue(configuration))) {
117
- const setter = setterMap[key];
118
- if (!setter) continue;
119
- const updateEvent = getUpdateEvent(key);
120
- setters.push((targetGameObject) => {
121
- setter(targetGameObject, emit)(value);
122
- if (value !== void 0) emit(updateEvent, value);
123
- else if (key in targetGameObject) emit(updateEvent, targetGameObject[key]);
124
- });
125
- setterWatchHandles.push(watch(() => toValue(configuration)[key], (newValue, oldValue) => {
126
- if (newValue === oldValue && (newValue === null || typeof newValue !== "object")) return;
127
- const updater = () => {
128
- setter(toValue(gameObject), emit)(newValue);
129
- emit(updateEvent, newValue);
130
- };
131
- if (immediate) updater();
132
- else onNextTick(() => {
133
- updater();
134
- }, sceneKey);
135
- }, { deep: true }));
136
- }
137
- const initializeGameObjectSetters = (targetGameObject) => {
138
- for (const setter of setters) setter(targetGameObject);
139
- };
140
- return {
141
- initializeGameObjectSetters,
142
- setterWatchHandles
143
- };
144
- };
145
- //#endregion
146
- //#region src/hooks/onCreate.ts
147
- const onCreate = (...args) => {
148
- pushListener("Create", ...args);
149
- };
150
- //#endregion
151
- //#region src/services/hooks/getInitializeGameObjectLifecycleHook.ts
152
- const getInitializeGameObjectLifecycleHook = (sceneKey) => ExternalSceneStore.sceneReadyMap.get(sceneKey) ? onNextTick : onCreate;
153
- //#endregion
154
- //#region src/store/index.ts
155
- const usePhaserStore = defineStore("phaser", () => {
156
- let baseGame;
157
- const game = computed({
158
- get: () => baseGame,
159
- set: (newGame) => {
160
- baseGame = newGame;
161
- }
162
- });
163
- const sceneKey = ref();
164
- const isSameScene = (newSceneKey) => newSceneKey === sceneKey.value;
165
- const switchToScene = async (newSceneKey) => {
166
- if (isSameScene(newSceneKey)) return;
167
- const activeGame = game.value;
168
- if (!activeGame) throw new NotInitializedError(Game.name);
169
- const oldSceneKey = sceneKey.value;
170
- sceneKey.value = newSceneKey;
171
- await nextTick();
172
- if (oldSceneKey && activeGame.scene.isActive(oldSceneKey)) activeGame.scene.stop(oldSceneKey);
173
- activeGame.scene.start(newSceneKey);
174
- };
175
- const parallelSceneKeys = ref([]);
176
- const prioritizedParallelSceneKeys = ref([]);
177
- const launchParallelScene = (scene, targetSceneKey) => {
178
- if (parallelSceneKeys.value.includes(targetSceneKey)) return;
179
- scene.scene.bringToTop(targetSceneKey);
180
- for (const prioritizedParallelSceneKey of prioritizedParallelSceneKeys.value) if (parallelSceneKeys.value.includes(prioritizedParallelSceneKey)) scene.scene.bringToTop(prioritizedParallelSceneKey);
181
- scene.scene.launch(targetSceneKey);
182
- parallelSceneKeys.value.push(targetSceneKey);
183
- };
184
- const removeParallelScene = (scene, targetSceneKey) => {
185
- const index = parallelSceneKeys.value.indexOf(targetSceneKey);
186
- if (index === -1) return;
187
- parallelSceneKeys.value = parallelSceneKeys.value.toSpliced(index, 1);
188
- scene.scene.stop(targetSceneKey);
189
- };
190
- return {
191
- game,
192
- isSameScene,
193
- launchParallelScene,
194
- parallelSceneKeys,
195
- prioritizedParallelSceneKeys,
196
- removeParallelScene,
197
- rootSceneKey: sceneKey,
198
- switchToScene
199
- };
200
- });
201
- //#endregion
202
- //#region src/composables/useGame.ts
203
- const useGame = () => {
204
- const phaserStore = usePhaserStore();
205
- const { game } = storeToRefs(phaserStore);
206
- if (!game.value) throw new NotInitializedError(Game.name);
207
- return game.value;
208
- };
209
- //#endregion
210
- //#region src/services/shared/getScene.ts
211
- const getScene = (sceneKey) => {
212
- return useGame().scene.getScene(sceneKey);
213
- };
214
- //#endregion
215
- //#region src/services/shared/getDepthInsertIndex.ts
216
- const getDepthInsertIndex = (list, depth) => typeof depth === "number" ? list.findIndex((gameObject) => "depth" in gameObject && typeof gameObject.depth === "number" && gameObject.depth > depth) : -1;
217
- //#endregion
218
- //#region src/services/shared/pushGameObject.ts
219
- const pushGameObject = (parentContainer, configuration, gameObject) => {
220
- const depthInsertIndex = getDepthInsertIndex(parentContainer.list, "depth" in configuration ? configuration.depth : void 0);
221
- if (depthInsertIndex === -1) parentContainer.add(gameObject);
222
- else parentContainer.addAt(gameObject, depthInsertIndex);
223
- };
224
- //#endregion
225
- //#region src/composables/useInitializeGameObject.ts
226
- const useInitializeGameObject = (create, configuration, emit, setterMap, immediate) => {
227
- let gameObject;
228
- const { initializeGameObjectSetters, setterWatchHandles } = useInitializeGameObjectSetters(() => gameObject, configuration, emit, setterMap, immediate);
229
- const { eventStopHandles, initializeGameObjectEvents } = useInitializeGameObjectEvents();
230
- const parentContainer = inject(InjectionKeyMap.ParentContainer, void 0);
231
- const sceneKey = useInjectSceneKey();
232
- const lifecycleHook = getInitializeGameObjectLifecycleHook(sceneKey);
233
- const initializeGameObject = (scene) => {
234
- gameObject = create(scene);
235
- initializeGameObjectSetters(gameObject);
236
- initializeGameObjectEvents(gameObject, emit, scene);
237
- };
238
- const pushToParentContainer = () => {
239
- if (!parentContainer?.value) return;
240
- pushGameObject(parentContainer.value, toValue(configuration), gameObject);
241
- };
242
- if (immediate) {
243
- initializeGameObject(getScene(sceneKey));
244
- lifecycleHook(() => {
245
- pushToParentContainer();
246
- });
247
- } else lifecycleHook((scene) => {
248
- initializeGameObject(scene);
249
- pushToParentContainer();
250
- });
251
- onUnmounted(() => {
252
- for (const setterWatchHandle of setterWatchHandles) setterWatchHandle();
253
- for (const eventStopHandle of eventStopHandles) eventStopHandle();
254
- gameObject.destroy();
255
- });
256
- };
257
- //#endregion
258
- //#region src/services/setterMap/global/GameObjectSetterMap.ts
259
- const GameObjectSetterMap = { active: (gameObject) => (value) => {
260
- if (value === void 0) return;
261
- gameObject.setActive(value);
262
- } };
263
- //#endregion
264
- //#region src/services/setterMap/global/TweenSetterMap.ts
265
- const TweenSetterMap = {
266
- tween: (gameObject, emit) => (value) => {
267
- if (!value) return;
268
- gameObject.scene.add.tween({
269
- ...value,
270
- targets: gameObject
271
- }).on(Tweens.Events.TWEEN_COMPLETE, () => {
272
- emit("update:tween", void 0);
273
- });
274
- },
275
- tweenchain: (gameObject, emit) => (value) => {
276
- if (!value) return;
277
- gameObject.scene.add.tweenchain(value.map((configuration) => ({
278
- ...configuration,
279
- targets: gameObject
280
- }))).on(Tweens.Events.TWEEN_COMPLETE, () => {
281
- emit("update:tweenchain", void 0);
282
- });
283
- }
284
- };
285
- //#endregion
286
- //#region src/services/setterMap/global/GlobalSetterMap.ts
287
- const GlobalSetterMap = {
288
- ...TweenSetterMap,
289
- ...GameObjectSetterMap
290
- };
291
- //#endregion
292
- //#region src/services/setterMap/components/AlphaSingleSetterMap.ts
293
- const AlphaSingleSetterMap = { alpha: (gameObject) => (value) => {
294
- if (value === void 0) return;
295
- gameObject.setAlpha(value);
296
- } };
297
- //#endregion
298
- //#region src/services/setterMap/components/BlendModeSetterMap.ts
299
- const BlendModeSetterMap = { blendMode: (gameObject) => (value) => {
300
- if (value === void 0) return;
301
- gameObject.setBlendMode(value);
302
- } };
303
- //#endregion
304
- //#region src/services/setterMap/components/DepthSetterMap.ts
305
- const DepthSetterMap = { depth: (gameObject) => (value) => {
306
- if (value === void 0) return;
307
- gameObject.setDepth(value);
308
- if (!gameObject.parentContainer) return;
309
- const { list } = gameObject.parentContainer;
310
- const depthInsertIndex = getDepthInsertIndex(list, gameObject.depth);
311
- if (depthInsertIndex === -1) gameObject.parentContainer.bringToTop(gameObject);
312
- else {
313
- const currentIndex = list.indexOf(gameObject);
314
- gameObject.parentContainer.moveTo(gameObject, currentIndex < depthInsertIndex ? depthInsertIndex - 1 : depthInsertIndex);
315
- }
316
- } };
317
- //#endregion
318
- //#region src/services/setterMap/components/DisplaySizeSetterMap.ts
319
- const DisplaySizeSetterMap = {
320
- displayHeight: (gameObject) => (value) => {
321
- if (value === void 0) return;
322
- gameObject.setDisplaySize(gameObject.displayWidth, value);
323
- },
324
- displayWidth: (gameObject) => (value) => {
325
- if (value === void 0) return;
326
- gameObject.setDisplaySize(value, gameObject.displayHeight);
327
- }
328
- };
329
- //#endregion
330
- //#region src/services/setterMap/components/MaskSetterMap.ts
331
- const MaskSetterMap = { mask: (gameObject) => (value) => {
332
- if (!value) return;
333
- gameObject.setMask(value);
334
- } };
335
- //#endregion
336
- //#region src/services/setterMap/components/OriginSetterMap.ts
337
- const OriginSetterMap = {
338
- displayOriginX: (gameObject) => (value) => {
339
- if (value === void 0) return;
340
- gameObject.setDisplayOrigin(value, gameObject.displayOriginY);
341
- },
342
- displayOriginY: (gameObject) => (value) => {
343
- if (value === void 0) return;
344
- gameObject.setDisplayOrigin(gameObject.displayOriginX, value);
345
- },
346
- origin: (gameObject) => (value) => {
347
- if (value === void 0) return;
348
- gameObject.setOrigin(value, value);
349
- },
350
- originX: (gameObject) => (value) => {
351
- if (value === void 0) return;
352
- gameObject.setOrigin(value, gameObject.originY);
353
- },
354
- originY: (gameObject) => (value) => {
355
- if (value === void 0) return;
356
- gameObject.setOrigin(gameObject.originX, value);
357
- }
358
- };
359
- //#endregion
360
- //#region src/services/setterMap/components/RenderNodesSetterMap.ts
361
- const RenderNodesSetterMap = {};
362
- //#endregion
363
- //#region src/services/setterMap/components/ScrollFactorSetterMap.ts
364
- const ScrollFactorSetterMap = {
365
- scrollFactor: (gameObject) => (value) => {
366
- if (value === void 0) return;
367
- gameObject.setScrollFactor(value, value);
368
- },
369
- scrollFactorX: (gameObject) => (value) => {
370
- if (value === void 0) return;
371
- gameObject.setScrollFactor(value, gameObject.scrollFactorY);
372
- },
373
- scrollFactorY: (gameObject) => (value) => {
374
- if (value === void 0) return;
375
- gameObject.setScrollFactor(gameObject.scrollFactorX, value);
376
- }
377
- };
378
- //#endregion
379
- //#region src/services/setterMap/components/TransformSetterMap.ts
380
- const TransformSetterMap = {
381
- angle: (gameObject) => (value) => {
382
- if (value === void 0) return;
383
- gameObject.setAngle(value);
384
- },
385
- rotation: (gameObject) => (value) => {
386
- if (value === void 0) return;
387
- gameObject.setRotation(value);
388
- },
389
- scale: (gameObject) => (value) => {
390
- if (value === void 0) return;
391
- gameObject.setScale(value, value);
392
- },
393
- scaleX: (gameObject) => (value) => {
394
- if (value === void 0) return;
395
- gameObject.setScale(value, gameObject.scaleY);
396
- },
397
- scaleY: (gameObject) => (value) => {
398
- if (value === void 0) return;
399
- gameObject.setScale(gameObject.scaleX, value);
400
- },
401
- w: (gameObject) => (value) => {
402
- if (value === void 0) return;
403
- gameObject.setW(value);
404
- },
405
- x: (gameObject) => (value) => {
406
- if (value === void 0) return;
407
- gameObject.setX(value);
408
- },
409
- y: (gameObject) => (value) => {
410
- if (value === void 0) return;
411
- gameObject.setY(value);
412
- },
413
- z: (gameObject) => (value) => {
414
- if (value === void 0) return;
415
- gameObject.setZ(value);
416
- }
417
- };
418
- //#endregion
419
- //#region src/services/setterMap/components/VisibleSetterMap.ts
420
- const VisibleSetterMap = { visible: (gameObject) => (value) => {
421
- if (value === void 0) return;
422
- gameObject.setVisible(value);
423
- } };
424
- //#endregion
425
- //#region src/services/setterMap/shared/ShapeSetterMap.ts
426
- const ShapeSetterMap = {
427
- ...AlphaSingleSetterMap,
428
- ...BlendModeSetterMap,
429
- ...DepthSetterMap,
430
- ...DisplaySizeSetterMap,
431
- ...GameObjectSetterMap,
432
- ...MaskSetterMap,
433
- ...OriginSetterMap,
434
- ...RenderNodesSetterMap,
435
- ...ScrollFactorSetterMap,
436
- ...TransformSetterMap,
437
- ...VisibleSetterMap,
438
- fillAlpha: (gameObject) => (value) => {
439
- gameObject.setFillStyle(gameObject.fillColor, value);
440
- },
441
- fillColor: (gameObject) => (value) => {
442
- gameObject.setFillStyle(value, gameObject.fillAlpha);
443
- },
444
- strokeStyle: (gameObject) => (value) => {
445
- if (!value) return;
446
- gameObject.setStrokeStyle(...value);
447
- }
448
- };
449
- //#endregion
450
- //#region src/services/setterMap/ArcSetterMap.ts
451
- const ArcSetterMap = {
452
- closePath: (gameObject) => (value) => {
453
- if (value === void 0) return;
454
- gameObject.setClosePath(value);
455
- },
456
- endAngle: (gameObject) => (value) => {
457
- if (value === void 0) return;
458
- gameObject.setEndAngle(value);
459
- },
460
- radius: (gameObject) => (value) => {
461
- if (value === void 0) return;
462
- gameObject.setRadius(value);
463
- },
464
- startAngle: (gameObject) => (value) => {
465
- if (value === void 0) return;
466
- gameObject.setStartAngle(value);
467
- },
468
- ...ShapeSetterMap,
469
- ...GlobalSetterMap
470
- };
471
- //#endregion
472
- //#region src/components/Arc.vue
473
- const _sfc_main = /*@__PURE__*/ defineComponent({
474
- __name: "Arc",
475
- props: {
476
- configuration: {},
477
- immediate: { type: Boolean },
478
- onComplete: { type: Function }
479
- },
480
- setup(__props, { emit: __emit }) {
481
- useInitializeGameObject((scene) => {
482
- const { alpha, endAngle, fillColor, radius, startAngle, x, y } = __props.configuration;
483
- const arc = scene.add.arc(x, y, radius, startAngle, endAngle, void 0, fillColor, alpha);
484
- __props.onComplete?.(scene, arc);
485
- return arc;
486
- }, () => __props.configuration, __emit, ArcSetterMap, __props.immediate);
487
- return (_ctx, _cache) => {
488
- return null;
489
- };
490
- }
491
- });
492
- //#endregion
493
- //#region src/services/setterMap/components/AlphaSetterMap.ts
494
- const AlphaSetterMap = {
495
- alpha: (gameObject) => (value) => {
496
- if (value === void 0) return;
497
- gameObject.setAlpha(value, value, value, value);
498
- },
499
- alphaBottomLeft: (gameObject) => (value) => {
500
- if (value === void 0) return;
501
- gameObject.setAlpha(gameObject.alphaTopLeft, gameObject.alphaTopRight, value, gameObject.alphaBottomRight);
502
- },
503
- alphaBottomRight: (gameObject) => (value) => {
504
- if (value === void 0) return;
505
- gameObject.setAlpha(gameObject.alphaTopLeft, gameObject.alphaTopRight, gameObject.alphaBottomLeft, value);
506
- },
507
- alphaTopLeft: (gameObject) => (value) => {
508
- if (value === void 0) return;
509
- gameObject.setAlpha(value, gameObject.alphaTopRight, gameObject.alphaBottomLeft, gameObject.alphaBottomRight);
510
- },
511
- alphaTopRight: (gameObject) => (value) => {
512
- if (value === void 0) return;
513
- gameObject.setAlpha(gameObject.alphaTopLeft, value, gameObject.alphaBottomLeft, gameObject.alphaBottomRight);
514
- }
515
- };
516
- //#endregion
517
- //#region src/services/setterMap/components/TintSetterMap.ts
518
- const TintSetterMap = {
519
- tint: (gameObject) => (value) => {
520
- if (value === void 0) return;
521
- gameObject.setTint(value, value, value, value);
522
- },
523
- tintBottomLeft: (gameObject) => (value) => {
524
- if (value === void 0) return;
525
- gameObject.setTint(gameObject.tintTopLeft, gameObject.tintTopRight, value, gameObject.tintBottomRight);
526
- },
527
- tintBottomRight: (gameObject) => (value) => {
528
- if (value === void 0) return;
529
- gameObject.setTint(gameObject.tintTopLeft, gameObject.tintTopRight, gameObject.tintBottomLeft, value);
530
- },
531
- tintTopLeft: (gameObject) => (value) => {
532
- if (value === void 0) return;
533
- gameObject.setTint(value, gameObject.tintTopRight, gameObject.tintBottomLeft, gameObject.tintBottomRight);
534
- },
535
- tintTopRight: (gameObject) => (value) => {
536
- if (value === void 0) return;
537
- gameObject.setTint(gameObject.tintTopLeft, value, gameObject.tintBottomLeft, gameObject.tintBottomRight);
538
- }
539
- };
540
- //#endregion
541
- //#region src/services/setterMap/shared/RenderableSetterMap.ts
542
- const RenderableSetterMap = {
543
- ...AlphaSetterMap,
544
- ...BlendModeSetterMap,
545
- ...DepthSetterMap,
546
- ...MaskSetterMap,
547
- ...OriginSetterMap,
548
- ...RenderNodesSetterMap,
549
- ...ScrollFactorSetterMap,
550
- ...TintSetterMap,
551
- ...TransformSetterMap,
552
- ...VisibleSetterMap,
553
- ...GlobalSetterMap
554
- };
555
- //#endregion
556
- //#region src/services/setterMap/BitmapTextSetterMap.ts
557
- const BitmapTextSetterMap = {
558
- align: (gameObject) => (value) => {
559
- if (value === void 0) return;
560
- gameObject.align = value;
561
- },
562
- dropShadow: (gameObject) => (value) => {
563
- if (!value) return;
564
- gameObject.setDropShadow(...value);
565
- },
566
- font: (gameObject) => (value) => {
567
- if (!value) return;
568
- gameObject.setFont(value);
569
- },
570
- fontSize: (gameObject) => (value) => {
571
- if (value === void 0) return;
572
- gameObject.setFontSize(value);
573
- },
574
- letterSpacing: (gameObject) => (value) => {
575
- if (value === void 0) return;
576
- gameObject.setLetterSpacing(value);
577
- },
578
- lineSpacing: (gameObject) => (value) => {
579
- if (value === void 0) return;
580
- gameObject.setLineSpacing(value);
581
- },
582
- maxWidth: (gameObject) => (value) => {
583
- if (value === void 0) return;
584
- gameObject.setMaxWidth(value);
585
- },
586
- text: (gameObject) => (value) => {
587
- if (value === void 0) return;
588
- gameObject.setText(value);
589
- },
590
- wordWrapCharCode: (gameObject) => (value) => {
591
- if (value === void 0) return;
592
- gameObject.wordWrapCharCode = value;
593
- },
594
- ...RenderableSetterMap
595
- };
596
- //#endregion
597
- //#region src/components/BitmapText.vue
598
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
599
- __name: "BitmapText",
600
- props: {
601
- configuration: {},
602
- immediate: { type: Boolean },
603
- onComplete: { type: Function }
604
- },
605
- setup(__props, { emit: __emit }) {
606
- useInitializeGameObject((scene) => {
607
- const { align, font, fontSize, text, x, y } = __props.configuration;
608
- const bitmapText = scene.add.bitmapText(x ?? 0, y ?? 0, font, text, fontSize, align);
609
- __props.onComplete?.(scene, bitmapText);
610
- return bitmapText;
611
- }, () => __props.configuration, __emit, BitmapTextSetterMap, __props.immediate);
612
- return (_ctx, _cache) => {
613
- return null;
614
- };
615
- }
616
- });
617
- //#endregion
618
- //#region src/components/Circle.vue
619
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
620
- __name: "Circle",
621
- props: {
622
- configuration: {},
623
- immediate: { type: Boolean },
624
- onComplete: { type: Function }
625
- },
626
- setup(__props, { emit: __emit }) {
627
- useInitializeGameObject((scene) => {
628
- const { alpha, fillColor, radius, x, y } = __props.configuration;
629
- const circle = scene.add.circle(x, y, radius, fillColor, alpha);
630
- __props.onComplete?.(scene, circle);
631
- return circle;
632
- }, () => __props.configuration, __emit, ArcSetterMap, __props.immediate);
633
- return (_ctx, _cache) => {
634
- return null;
635
- };
636
- }
637
- });
638
- //#endregion
639
- //#region src/services/setterMap/ContainerSetterMap.ts
640
- const ContainerSetterMap = {
641
- ...AlphaSingleSetterMap,
642
- ...BlendModeSetterMap,
643
- ...DepthSetterMap,
644
- ...MaskSetterMap,
645
- ...ScrollFactorSetterMap,
646
- ...TransformSetterMap,
647
- ...VisibleSetterMap,
648
- ...GlobalSetterMap
649
- };
650
- //#endregion
651
- //#region src/components/Container.vue
652
- const _sfc_main$3 = /*@__PURE__*/ defineComponent({
653
- __name: "Container",
654
- props: {
655
- configuration: { default: () => ({}) },
656
- onComplete: { type: Function }
657
- },
658
- setup(__props, { emit: __emit }) {
659
- const emit = __emit;
660
- const container = shallowRef();
661
- useInitializeGameObject((scene) => {
662
- const { children, x, y } = __props.configuration;
663
- container.value = scene.add.container(x, y, children);
664
- __props.onComplete?.(scene, container.value);
665
- return container.value;
666
- }, () => __props.configuration, emit, ContainerSetterMap);
667
- provide(InjectionKeyMap.ParentContainer, container);
668
- return (_ctx, _cache) => {
669
- return renderSlot(_ctx.$slots, "default");
670
- };
671
- }
672
- });
673
- //#endregion
674
- //#region src/services/setterMap/CurveSetterMap.ts
675
- const CurveSetterMap = {
676
- smoothness: (gameObject) => (value) => {
677
- if (value === void 0) return;
678
- gameObject.setSmoothness(value);
679
- },
680
- ...ShapeSetterMap,
681
- ...GlobalSetterMap
682
- };
683
- //#endregion
684
- //#region src/components/Curve.vue
685
- const _sfc_main$4 = /*@__PURE__*/ defineComponent({
686
- __name: "Curve",
687
- props: {
688
- configuration: {},
689
- immediate: { type: Boolean },
690
- onComplete: { type: Function }
691
- },
692
- setup(__props, { emit: __emit }) {
693
- useInitializeGameObject((scene) => {
694
- const { alpha, curve, fillColor, x, y } = __props.configuration;
695
- const curveObject = scene.add.curve(x, y, curve, fillColor, alpha);
696
- __props.onComplete?.(scene, curveObject);
697
- return curveObject;
698
- }, () => __props.configuration, __emit, CurveSetterMap, __props.immediate);
699
- return (_ctx, _cache) => {
700
- return null;
701
- };
702
- }
703
- });
704
- //#endregion
705
- //#region src/services/setterMap/components/ComputedSizeSetterMap.ts
706
- const ComputedSizeSetterMap = {
707
- ...DisplaySizeSetterMap,
708
- height: (gameObject) => (value) => {
709
- if (value === void 0) return;
710
- gameObject.setSize(gameObject.width, value);
711
- },
712
- width: (gameObject) => (value) => {
713
- if (value === void 0) return;
714
- gameObject.setSize(value, gameObject.height);
715
- }
716
- };
717
- //#endregion
718
- //#region src/services/setterMap/EllipseSetterMap.ts
719
- const EllipseSetterMap = {
720
- height: ComputedSizeSetterMap.height,
721
- smoothness: (gameObject) => (value) => {
722
- if (value === void 0) return;
723
- gameObject.setSmoothness(value);
724
- },
725
- width: ComputedSizeSetterMap.width,
726
- ...ShapeSetterMap,
727
- ...GlobalSetterMap
728
- };
729
- //#endregion
730
- //#region src/components/Ellipse.vue
731
- const _sfc_main$5 = /*@__PURE__*/ defineComponent({
732
- __name: "Ellipse",
733
- props: {
734
- configuration: {},
735
- immediate: { type: Boolean },
736
- onComplete: { type: Function }
737
- },
738
- setup(__props, { emit: __emit }) {
739
- useInitializeGameObject((scene) => {
740
- const { alpha, fillColor, height, width, x, y } = __props.configuration;
741
- const ellipse = scene.add.ellipse(x, y, width, height, fillColor, alpha);
742
- __props.onComplete?.(scene, ellipse);
743
- return ellipse;
744
- }, () => __props.configuration, __emit, EllipseSetterMap, __props.immediate);
745
- return (_ctx, _cache) => {
746
- return null;
747
- };
748
- }
749
- });
750
- //#endregion
751
- //#region src/models/plugins/TilesetFile.ts
752
- const XMLFile = Loader.FileTypes.XMLFile;
753
- var TilesetFile = class extends XMLFile {
754
- tilesetIndex;
755
- constructor(tilesetIndex, ...args) {
756
- super(...args);
757
- this.tilesetIndex = tilesetIndex;
758
- }
759
- };
760
- //#endregion
761
- //#region src/models/plugins/TiledJSONExternalFile.ts
762
- const GetFastValue = Utils.Objects.GetFastValue;
763
- const JSONFile$1 = Loader.FileTypes.JSONFile;
764
- const MultiFile = Loader.MultiFile;
765
- const PUBLIC_FOLDER = "public";
766
- var TiledJSONExternalFile = class extends MultiFile {
767
- constructor(loader, key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings) {
768
- if (typeof key !== "string") {
769
- const configuration = key;
770
- key = GetFastValue(configuration, "key");
771
- tilemapURL = GetFastValue(configuration, "url");
772
- tilemapXhrSettings = GetFastValue(configuration, "xhrSettings");
773
- path = GetFastValue(configuration, "path");
774
- baseURL = GetFastValue(configuration, "baseURL");
775
- tilesetXhrSettings = GetFastValue(configuration, "tilesetXhrSettings");
776
- }
777
- const tilemapFile = new JSONFile$1(loader, key, tilemapURL, tilemapXhrSettings);
778
- super(loader, "tilemapJSON", key, [tilemapFile]);
779
- this.config.path = path;
780
- this.config.baseURL = baseURL;
781
- this.config.tilesetXhrSettings = tilesetXhrSettings;
782
- }
783
- addToCache() {
784
- if (!this.isReadyToProcess()) return;
785
- const [tilemapFile, ...tilesetFiles] = this.files;
786
- if (!(tilemapFile.type === "json" && Object.hasOwn(tilemapFile.data, "tilesets"))) return;
787
- const tilemapData = tilemapFile.data;
788
- const tilemapKey = tilemapFile.key;
789
- const loader = this.loader;
790
- const files = this.files;
791
- this.complete = true;
792
- for (const tilesetFile of tilesetFiles) {
793
- const responseText = tilesetFile.xhrLoader?.responseText;
794
- if (!responseText) throw new InvalidOperationError(Operation.Read, this.addToCache.name, tilesetFile.key);
795
- const tilesetData = parseTileset(responseText).match((parsedTileset) => parsedTileset, (error) => {
796
- throw error;
797
- });
798
- const index = tilesetFile.tilesetIndex;
799
- Object.assign(tilemapData.tilesets[index], tilesetData, {
800
- imageheight: tilesetData.image?.height,
801
- imagewidth: tilesetData.image?.width,
802
- source: void 0
803
- });
804
- }
805
- loader.cacheManager.tilemap.add(tilemapKey, {
806
- data: tilemapData,
807
- format: Tilemaps.Formats.TILED_JSON
808
- });
809
- for (const file of files) file.pendingDestroy();
810
- }
811
- onFileComplete(file) {
812
- if (this.files.indexOf(file) === -1) return;
813
- this.pending--;
814
- if (!(file.type === "json" && Object.hasOwn(file.data, "tilesets"))) return;
815
- const tilesets = file.data.tilesets;
816
- const config = this.config;
817
- const loader = this.loader;
818
- const currentBaseURL = loader.baseURL;
819
- const currentPath = loader.path;
820
- const currentPrefix = loader.prefix;
821
- const baseURL = GetFastValue(config, "baseURL", currentBaseURL);
822
- const path = GetFastValue(config, "path", currentPath);
823
- const prefix = GetFastValue(config, "prefix", currentPrefix);
824
- const tilesetXhrSettings = GetFastValue(config, "tilesetXhrSettings");
825
- loader.setBaseURL(baseURL);
826
- loader.setPath(path);
827
- loader.setPrefix(prefix);
828
- for (const [tilesetIndex, tileset] of tilesets.entries()) {
829
- const pathIndex = tileset.source.indexOf(PUBLIC_FOLDER);
830
- if (pathIndex === -1) throw new NotFoundError(this.onFileComplete.name, tileset.source);
831
- const relativePath = tileset.source.slice(pathIndex + 6);
832
- const tilesetFile = new TilesetFile(tilesetIndex, loader, `${file.key}${ID_SEPARATOR}Tileset${ID_SEPARATOR}${relativePath}`, relativePath, tilesetXhrSettings);
833
- this.addToMultiFile(tilesetFile);
834
- loader.addFile(tilesetFile);
835
- }
836
- loader.setBaseURL(currentBaseURL);
837
- loader.setPath(currentPath);
838
- loader.setPrefix(currentPrefix);
839
- }
840
- };
841
- //#endregion
842
- //#region src/services/shared/constants.ts
843
- const TILEMAP_TILED_JSON_EXTERNAL_KEY = "tilemapTiledJSONExternal";
844
- const ANIMATION_COMPLETE_EVENT_PREFIX = "animationcomplete-";
845
- //#endregion
846
- //#region src/plugins/registerTiledJSONExternalLoader.ts
847
- const FileTypesManager = Loader.FileTypesManager;
848
- const registerTiledJSONExternalLoader = () => {
849
- FileTypesManager.register(TILEMAP_TILED_JSON_EXTERNAL_KEY, function(...[key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings]) {
850
- if (Array.isArray(key)) for (const keyElement of key) {
851
- const multifile = new TiledJSONExternalFile(this, keyElement);
852
- this.addFile(multifile.files);
853
- }
854
- else {
855
- const multifile = new TiledJSONExternalFile(this, key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings);
856
- this.addFile(multifile.files);
857
- }
858
- return this;
859
- });
860
- };
861
- //#endregion
862
- //#region src/components/Game.vue
863
- const _sfc_main$6 = /*@__PURE__*/ defineComponent({
864
- __name: "Game",
865
- props: { configuration: {} },
866
- setup(__props) {
867
- const phaserStore = usePhaserStore();
868
- const { game: storeGame } = storeToRefs(phaserStore);
869
- const canvasRoot = useTemplateRef("canvasRoot");
870
- const isReady = ref(false);
871
- const readyListener = () => {
872
- isReady.value = true;
873
- };
874
- onMounted(() => {
875
- registerTiledJSONExternalLoader();
876
- storeGame.value = new Game({
877
- ...__props.configuration,
878
- parent: canvasRoot.value
879
- });
880
- storeGame.value.events.on(Core.Events.READY, readyListener);
881
- });
882
- onUnmounted(() => {
883
- const game = useGame();
884
- game.events.off(Core.Events.READY, readyListener);
885
- game.destroy(true);
886
- storeGame.value = void 0;
887
- });
888
- return (_ctx, _cache) => {
889
- return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", {
890
- ref_key: "canvasRoot",
891
- ref: canvasRoot
892
- }, null, 512), isReady.value ? renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 0) : createCommentVNode("v-if", true)], 64);
893
- };
894
- }
895
- });
896
- //#endregion
897
- //#region src/services/setterMap/GraphicsSetterMap.ts
898
- const GraphicsSetterMap = {
899
- ...AlphaSingleSetterMap,
900
- ...BlendModeSetterMap,
901
- ...DepthSetterMap,
902
- ...MaskSetterMap,
903
- ...RenderNodesSetterMap,
904
- ...ScrollFactorSetterMap,
905
- ...TransformSetterMap,
906
- ...VisibleSetterMap,
907
- ...GlobalSetterMap
908
- };
909
- //#endregion
910
- //#region src/components/Graphics.vue
911
- const _sfc_main$7 = /*@__PURE__*/ defineComponent({
912
- __name: "Graphics",
913
- props: {
914
- configuration: { default: () => ({}) },
915
- immediate: { type: Boolean },
916
- onComplete: { type: Function }
917
- },
918
- setup(__props, { emit: __emit }) {
919
- useInitializeGameObject((scene) => {
920
- const { x, y } = __props.configuration;
921
- const graphics = scene.add.graphics({
922
- x,
923
- y
924
- });
925
- __props.onComplete?.(scene, graphics);
926
- return graphics;
927
- }, () => __props.configuration, __emit, GraphicsSetterMap, __props.immediate);
928
- return (_ctx, _cache) => {
929
- return null;
930
- };
931
- }
932
- });
933
- //#endregion
934
- //#region src/services/setterMap/components/FlipSetterMap.ts
935
- const FlipSetterMap = {
936
- flipX: (gameObject) => (value) => {
937
- if (value === void 0) return;
938
- gameObject.setFlipX(value);
939
- },
940
- flipY: (gameObject) => (value) => {
941
- if (value === void 0) return;
942
- gameObject.setFlipY(value);
943
- }
944
- };
945
- //#endregion
946
- //#region src/services/setterMap/components/SizeSetterMap.ts
947
- const SizeSetterMap = { ...ComputedSizeSetterMap };
948
- //#endregion
949
- //#region src/services/setterMap/components/BaseTextureSetterMap.ts
950
- const BaseTextureSetterMap = {
951
- frame: (gameObject) => (value) => {
952
- if (value === void 0) return;
953
- gameObject.setFrame(value);
954
- },
955
- texture: (gameObject) => (value) => {
956
- if (!value) return;
957
- gameObject.setTexture(value);
958
- }
959
- };
960
- //#endregion
961
- //#region src/services/setterMap/components/TextureCropSetterMap.ts
962
- const TextureCropSetterMap = { ...BaseTextureSetterMap };
963
- //#endregion
964
- //#region src/services/setterMap/ImageSetterMap.ts
965
- const ImageSetterMap = {
966
- ...RenderableSetterMap,
967
- ...FlipSetterMap,
968
- ...SizeSetterMap,
969
- ...TextureCropSetterMap
970
- };
971
- //#endregion
972
- //#region src/components/Image.vue
973
- const _sfc_main$8 = /*@__PURE__*/ defineComponent({
974
- __name: "Image",
975
- props: {
976
- configuration: {},
977
- onComplete: { type: Function }
978
- },
979
- setup(__props, { emit: __emit }) {
980
- useInitializeGameObject((scene) => {
981
- const { frame, texture, x, y } = __props.configuration;
982
- const image = scene.add.image(x ?? 0, y ?? 0, texture, frame);
983
- __props.onComplete?.(scene, image);
984
- return image;
985
- }, () => __props.configuration, __emit, ImageSetterMap);
986
- return (_ctx, _cache) => {
987
- return null;
988
- };
989
- }
990
- });
991
- //#endregion
992
- //#region src/services/setterMap/shared/IsoSetterMap.ts
993
- const IsoSetterMap = {
994
- fillLeft: (gameObject) => (value) => {
995
- if (value === void 0) return;
996
- gameObject.setFillStyle(gameObject.fillTop, value, gameObject.fillRight);
997
- },
998
- fillRight: (gameObject) => (value) => {
999
- if (value === void 0) return;
1000
- gameObject.setFillStyle(gameObject.fillTop, gameObject.fillLeft, value);
1001
- },
1002
- fillTop: (gameObject) => (value) => {
1003
- if (value === void 0) return;
1004
- gameObject.setFillStyle(value, gameObject.fillLeft, gameObject.fillRight);
1005
- },
1006
- projection: (gameObject) => (value) => {
1007
- if (value === void 0) return;
1008
- gameObject.setProjection(value);
1009
- },
1010
- showLeft: (gameObject) => (value) => {
1011
- if (value === void 0) return;
1012
- gameObject.setFaces(gameObject.showTop, value, gameObject.showRight);
1013
- },
1014
- showRight: (gameObject) => (value) => {
1015
- if (value === void 0) return;
1016
- gameObject.setFaces(gameObject.showTop, gameObject.showLeft, value);
1017
- },
1018
- showTop: (gameObject) => (value) => {
1019
- if (value === void 0) return;
1020
- gameObject.setFaces(value, gameObject.showLeft, gameObject.showRight);
1021
- }
1022
- };
1023
- //#endregion
1024
- //#region src/services/setterMap/IsoBoxSetterMap.ts
1025
- const IsoBoxSetterMap = {
1026
- ...IsoSetterMap,
1027
- ...ShapeSetterMap,
1028
- ...GlobalSetterMap
1029
- };
1030
- //#endregion
1031
- //#region src/components/IsoBox.vue
1032
- const _sfc_main$9 = /*@__PURE__*/ defineComponent({
1033
- __name: "IsoBox",
1034
- props: {
1035
- configuration: {},
1036
- immediate: { type: Boolean },
1037
- onComplete: { type: Function }
1038
- },
1039
- setup(__props, { emit: __emit }) {
1040
- useInitializeGameObject((scene) => {
1041
- const { fillLeft, fillRight, fillTop, height, size, x, y } = __props.configuration;
1042
- const isoBox = scene.add.isobox(x, y, size, height, fillTop, fillLeft, fillRight);
1043
- __props.onComplete?.(scene, isoBox);
1044
- return isoBox;
1045
- }, () => __props.configuration, __emit, IsoBoxSetterMap, __props.immediate);
1046
- return (_ctx, _cache) => {
1047
- return null;
1048
- };
1049
- }
1050
- });
1051
- //#endregion
1052
- //#region src/services/setterMap/IsoTriangleSetterMap.ts
1053
- const IsoTriangleSetterMap = {
1054
- isReversed: (gameObject) => (value) => {
1055
- if (value === void 0) return;
1056
- gameObject.setReversed(value);
1057
- },
1058
- ...IsoSetterMap,
1059
- ...ShapeSetterMap,
1060
- ...GlobalSetterMap
1061
- };
1062
- //#endregion
1063
- //#region src/components/IsoTriangle.vue
1064
- const _sfc_main$10 = /*@__PURE__*/ defineComponent({
1065
- __name: "IsoTriangle",
1066
- props: {
1067
- configuration: {},
1068
- immediate: { type: Boolean },
1069
- onComplete: { type: Function }
1070
- },
1071
- setup(__props, { emit: __emit }) {
1072
- useInitializeGameObject((scene) => {
1073
- const { fillLeft, fillRight, fillTop, height, isReversed, size, x, y } = __props.configuration;
1074
- const isoTriangle = scene.add.isotriangle(x, y, size, height, isReversed, fillTop, fillLeft, fillRight);
1075
- __props.onComplete?.(scene, isoTriangle);
1076
- return isoTriangle;
1077
- }, () => __props.configuration, __emit, IsoTriangleSetterMap, __props.immediate);
1078
- return (_ctx, _cache) => {
1079
- return null;
1080
- };
1081
- }
1082
- });
1083
- //#endregion
1084
- //#region src/services/setterMap/LineSetterMap.ts
1085
- const LineSetterMap = {
1086
- lineWidth: (gameObject) => (value) => {
1087
- if (value === void 0) return;
1088
- gameObject.setLineWidth(value);
1089
- },
1090
- to: (gameObject) => (value) => {
1091
- if (!value) return;
1092
- gameObject.setTo(...value);
1093
- },
1094
- ...ShapeSetterMap,
1095
- ...GlobalSetterMap
1096
- };
1097
- //#endregion
1098
- //#region src/components/Line.vue
1099
- const _sfc_main$11 = /*@__PURE__*/ defineComponent({
1100
- __name: "Line",
1101
- props: {
1102
- configuration: {},
1103
- immediate: { type: Boolean },
1104
- onComplete: { type: Function }
1105
- },
1106
- setup(__props, { emit: __emit }) {
1107
- useInitializeGameObject((scene) => {
1108
- const { to, x, y } = __props.configuration;
1109
- const line = scene.add.line(x, y, to?.[0], to?.[1], to?.[2], to?.[3]);
1110
- __props.onComplete?.(scene, line);
1111
- return line;
1112
- }, () => __props.configuration, __emit, LineSetterMap, __props.immediate);
1113
- return (_ctx, _cache) => {
1114
- return null;
1115
- };
1116
- }
1117
- });
1118
- //#endregion
1119
- //#region src/services/setterMap/components/TextureSetterMap.ts
1120
- const TextureSetterMap = { ...BaseTextureSetterMap };
1121
- //#endregion
1122
- //#region src/services/setterMap/NinesliceSetterMap.ts
1123
- const NinesliceSetterMap = {
1124
- height: ComputedSizeSetterMap.height,
1125
- width: ComputedSizeSetterMap.width,
1126
- ...AlphaSingleSetterMap,
1127
- ...BlendModeSetterMap,
1128
- ...DepthSetterMap,
1129
- ...MaskSetterMap,
1130
- ...OriginSetterMap,
1131
- ...RenderNodesSetterMap,
1132
- ...ScrollFactorSetterMap,
1133
- ...TextureSetterMap,
1134
- ...TransformSetterMap,
1135
- ...VisibleSetterMap,
1136
- ...GlobalSetterMap
1137
- };
1138
- //#endregion
1139
- //#region src/components/Nineslice.vue
1140
- const _sfc_main$12 = /*@__PURE__*/ defineComponent({
1141
- __name: "Nineslice",
1142
- props: {
1143
- configuration: {},
1144
- immediate: { type: Boolean },
1145
- onComplete: { type: Function }
1146
- },
1147
- setup(__props, { emit: __emit }) {
1148
- useInitializeGameObject((scene) => {
1149
- const { bottomHeight, frame, height, leftWidth, rightWidth, texture, topHeight, width, x, y } = __props.configuration;
1150
- const nineSlice = scene.add.nineslice(x ?? 0, y ?? 0, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight);
1151
- __props.onComplete?.(scene, nineSlice);
1152
- return nineSlice;
1153
- }, () => __props.configuration, __emit, NinesliceSetterMap, __props.immediate);
1154
- return (_ctx, _cache) => {
1155
- return null;
1156
- };
1157
- }
1158
- });
1159
- //#endregion
1160
- //#region src/services/setterMap/ParticlesSetterMap.ts
1161
- const ParticlesSetterMap = {
1162
- config: (gameObject) => (value) => {
1163
- if (!value) return;
1164
- gameObject.setConfig(value);
1165
- },
1166
- ...AlphaSingleSetterMap,
1167
- ...BlendModeSetterMap,
1168
- ...DepthSetterMap,
1169
- ...MaskSetterMap,
1170
- ...RenderNodesSetterMap,
1171
- ...ScrollFactorSetterMap,
1172
- ...TextureSetterMap,
1173
- ...TransformSetterMap,
1174
- ...VisibleSetterMap,
1175
- ...GlobalSetterMap
1176
- };
1177
- //#endregion
1178
- //#region src/components/Particles.vue
1179
- const _sfc_main$13 = /*@__PURE__*/ defineComponent({
1180
- __name: "Particles",
1181
- props: {
1182
- configuration: {},
1183
- immediate: { type: Boolean },
1184
- onComplete: { type: Function }
1185
- },
1186
- setup(__props, { emit: __emit }) {
1187
- useInitializeGameObject((scene) => {
1188
- const { config, texture, x, y } = __props.configuration;
1189
- const particles = scene.add.particles(x ?? 0, y ?? 0, texture, config);
1190
- __props.onComplete?.(scene, particles);
1191
- return particles;
1192
- }, () => __props.configuration, __emit, ParticlesSetterMap, __props.immediate);
1193
- return (_ctx, _cache) => {
1194
- return null;
1195
- };
1196
- }
1197
- });
1198
- //#endregion
1199
- //#region src/services/setterMap/components/PathFollowerComponentSetterMap.ts
1200
- const PathFollowerComponentSetterMap = { path: (gameObject) => (value) => {
1201
- if (!value) return;
1202
- gameObject.setPath(value);
1203
- } };
1204
- //#endregion
1205
- //#region src/services/setterMap/PathFollowerSetterMap.ts
1206
- const PathFollowerSetterMap = {
1207
- ...RenderableSetterMap,
1208
- ...FlipSetterMap,
1209
- ...PathFollowerComponentSetterMap,
1210
- ...SizeSetterMap,
1211
- ...TextureSetterMap
1212
- };
1213
- //#endregion
1214
- //#region src/components/PathFollower.vue
1215
- const _sfc_main$14 = /*@__PURE__*/ defineComponent({
1216
- __name: "PathFollower",
1217
- props: {
1218
- configuration: {},
1219
- onComplete: { type: Function }
1220
- },
1221
- setup(__props, { emit: __emit }) {
1222
- useInitializeGameObject((scene) => {
1223
- const { frame, path, texture, x, y } = __props.configuration;
1224
- const pathFollower = scene.add.follower(path, x ?? 0, y ?? 0, texture, frame);
1225
- __props.onComplete?.(scene, pathFollower);
1226
- return pathFollower;
1227
- }, () => __props.configuration, __emit, PathFollowerSetterMap);
1228
- return (_ctx, _cache) => {
1229
- return null;
1230
- };
1231
- }
1232
- });
1233
- //#endregion
1234
- //#region src/services/setterMap/PolygonSetterMap.ts
1235
- const PolygonSetterMap = {
1236
- points: (gameObject) => (value) => {
1237
- if (!value) return;
1238
- gameObject.setTo(value);
1239
- },
1240
- ...ShapeSetterMap,
1241
- ...GlobalSetterMap
1242
- };
1243
- //#endregion
1244
- //#region src/components/Polygon.vue
1245
- const _sfc_main$15 = /*@__PURE__*/ defineComponent({
1246
- __name: "Polygon",
1247
- props: {
1248
- configuration: {},
1249
- immediate: { type: Boolean },
1250
- onComplete: { type: Function }
1251
- },
1252
- setup(__props, { emit: __emit }) {
1253
- useInitializeGameObject((scene) => {
1254
- const { alpha, fillColor, points, x, y } = __props.configuration;
1255
- const polygon = scene.add.polygon(x, y, points, fillColor, alpha);
1256
- __props.onComplete?.(scene, polygon);
1257
- return polygon;
1258
- }, () => __props.configuration, __emit, PolygonSetterMap, __props.immediate);
1259
- return (_ctx, _cache) => {
1260
- return null;
1261
- };
1262
- }
1263
- });
1264
- //#endregion
1265
- //#region src/services/setterMap/RectangleSetterMap.ts
1266
- const RectangleSetterMap = {
1267
- height: ComputedSizeSetterMap.height,
1268
- width: ComputedSizeSetterMap.width,
1269
- ...ShapeSetterMap,
1270
- ...GlobalSetterMap
1271
- };
1272
- //#endregion
1273
- //#region src/components/Rectangle.vue
1274
- const _sfc_main$16 = /*@__PURE__*/ defineComponent({
1275
- __name: "Rectangle",
1276
- props: {
1277
- configuration: {},
1278
- immediate: { type: Boolean },
1279
- onComplete: { type: Function }
1280
- },
1281
- setup(__props, { emit: __emit }) {
1282
- useInitializeGameObject((scene) => {
1283
- const { alpha, fillColor, height, width, x, y } = __props.configuration;
1284
- const rectangle = scene.add.rectangle(x, y, width, height, fillColor, alpha);
1285
- __props.onComplete?.(scene, rectangle);
1286
- return rectangle;
1287
- }, () => __props.configuration, __emit, RectangleSetterMap, __props.immediate);
1288
- return (_ctx, _cache) => {
1289
- return null;
1290
- };
1291
- }
1292
- });
1293
- //#endregion
1294
- //#region src/services/setterMap/RenderTextureSetterMap.ts
1295
- const RenderTextureSetterMap = {
1296
- ...AlphaSetterMap,
1297
- ...BlendModeSetterMap,
1298
- ...DepthSetterMap,
1299
- ...FlipSetterMap,
1300
- ...MaskSetterMap,
1301
- ...OriginSetterMap,
1302
- ...RenderNodesSetterMap,
1303
- ...ScrollFactorSetterMap,
1304
- ...SizeSetterMap,
1305
- ...TintSetterMap,
1306
- ...TransformSetterMap,
1307
- ...VisibleSetterMap,
1308
- ...GlobalSetterMap
1309
- };
1310
- //#endregion
1311
- //#region src/components/RenderTexture.vue
1312
- const _sfc_main$17 = /*@__PURE__*/ defineComponent({
1313
- __name: "RenderTexture",
1314
- props: {
1315
- configuration: {},
1316
- immediate: { type: Boolean },
1317
- onComplete: { type: Function }
1318
- },
1319
- setup(__props, { emit: __emit }) {
1320
- useInitializeGameObject((scene) => {
1321
- const { height, width, x, y } = __props.configuration;
1322
- const renderTexture = scene.add.renderTexture(x ?? 0, y ?? 0, width, height);
1323
- __props.onComplete?.(scene, renderTexture);
1324
- return renderTexture;
1325
- }, () => __props.configuration, __emit, RenderTextureSetterMap, __props.immediate);
1326
- return (_ctx, _cache) => {
1327
- return null;
1328
- };
1329
- }
1330
- });
1331
- //#endregion
1332
- //#region src/services/hooks/resetLifecycleListeners.ts
1333
- const resetLifecycleListeners = (scene, lifecycle) => {
1334
- const listenersMap = ExternalSceneStore.lifecycleListenersMap.get(lifecycle);
1335
- if (!listenersMap?.has(scene.scene.key)) return;
1336
- listenersMap.set(scene.scene.key, []);
1337
- };
1338
- //#endregion
1339
- //#region src/services/hooks/runLifecycleListeners.ts
1340
- const runLifecycleListeners = (scene, lifecycle, isReset = true) => {
1341
- const listenersMap = ExternalSceneStore.lifecycleListenersMap.get(lifecycle);
1342
- if (!listenersMap) return;
1343
- const listeners = listenersMap.get(scene.scene.key);
1344
- if (!listeners) return;
1345
- for (const listener of listeners) listener(scene);
1346
- if (isReset) resetLifecycleListeners(scene, lifecycle);
1347
- };
1348
- //#endregion
1349
- //#region src/services/hooks/runSceneShutdown.ts
1350
- const runSceneShutdown = (scene) => {
1351
- resetLifecycleListeners(scene, "Update");
1352
- resetLifecycleListeners(scene, "NextTick");
1353
- runLifecycleListeners(scene, "Shutdown");
1354
- ExternalSceneStore.sceneReadyMap.set(scene.scene.key, false);
1355
- };
1356
- //#endregion
1357
- //#region src/services/shared/createSceneClass.ts
1358
- const createSceneClass = (key, hooks = {}) => class extends Scene {
1359
- constructor() {
1360
- super({ key });
1361
- }
1362
- create() {
1363
- hooks.onCreate?.(this);
1364
- runLifecycleListeners(this, "Create");
1365
- }
1366
- init() {
1367
- hooks.onInit?.(this);
1368
- runLifecycleListeners(this, "Init");
1369
- }
1370
- preload() {
1371
- hooks.onPreload?.(this);
1372
- runLifecycleListeners(this, "Preload");
1373
- }
1374
- update(time, delta) {
1375
- hooks.onUpdate?.(this, time, delta);
1376
- runLifecycleListeners(this, "Update", false);
1377
- runLifecycleListeners(this, "NextTick");
1378
- }
1379
- };
1380
- //#endregion
1381
- //#region src/store/camera.ts
1382
- const useCameraStore = defineStore("phaser/camera", () => {
1383
- const isFading = ref(false);
1384
- const fadeIn = (scene, ...args) => {
1385
- isFading.value = true;
1386
- scene.cameras.main.fadeIn(...args);
1387
- };
1388
- const fadeOut = (scene, ...args) => {
1389
- isFading.value = true;
1390
- scene.cameras.main.fadeOut(...args);
1391
- };
1392
- return {
1393
- fadeIn,
1394
- fadeOut,
1395
- isFading
1396
- };
1397
- });
1398
- //#endregion
1399
- //#region src/store/input.ts
1400
- const useInputStore = defineStore("phaser/input", () => {
1401
- return { isInputActive: ref(false) };
1402
- });
1403
- //#endregion
1404
- //#region src/components/Scene.vue
1405
- const _sfc_main$18 = /*@__PURE__*/ defineComponent({
1406
- __name: "Scene",
1407
- props: {
1408
- autoStart: { type: Boolean },
1409
- sceneKey: {}
1410
- },
1411
- emits: [
1412
- "create",
1413
- "init",
1414
- "preload",
1415
- "shutdown",
1416
- "update"
1417
- ],
1418
- setup(__props, { emit: __emit }) {
1419
- const emit = __emit;
1420
- const phaserStore = usePhaserStore();
1421
- const { isSameScene, switchToScene } = phaserStore;
1422
- const cameraStore = useCameraStore();
1423
- const { isFading } = storeToRefs(cameraStore);
1424
- const inputStore = useInputStore();
1425
- const { isInputActive } = storeToRefs(inputStore);
1426
- const { parallelSceneKeys } = storeToRefs(phaserStore);
1427
- const isActive = computed(() => isSameScene(__props.sceneKey) || parallelSceneKeys.value.includes(__props.sceneKey));
1428
- const fadeStartListener = () => {
1429
- isInputActive.value = false;
1430
- };
1431
- const fadeInCompleteListener = () => {
1432
- isFading.value = false;
1433
- isInputActive.value = true;
1434
- };
1435
- const fadeOutCompleteListener = () => {
1436
- isFading.value = false;
1437
- };
1438
- const cameraFadeListeners = [
1439
- [Cameras.Scene2D.Events.FADE_IN_START, fadeStartListener],
1440
- [Cameras.Scene2D.Events.FADE_IN_COMPLETE, fadeInCompleteListener],
1441
- [Cameras.Scene2D.Events.FADE_OUT_START, fadeStartListener],
1442
- [Cameras.Scene2D.Events.FADE_OUT_COMPLETE, fadeOutCompleteListener]
1443
- ];
1444
- const NewScene = createSceneClass(__props.sceneKey, {
1445
- onCreate: (scene) => {
1446
- emit("create", scene);
1447
- for (const [event, listener] of cameraFadeListeners) scene.cameras.main.on(event, listener);
1448
- isInputActive.value = true;
1449
- },
1450
- onInit: (scene) => emit("init", scene),
1451
- onPreload: (scene) => emit("preload", scene),
1452
- onUpdate: (scene, time, delta) => emit("update", scene, time, delta)
1453
- });
1454
- const readyListener = () => {
1455
- ExternalSceneStore.sceneReadyMap.set(__props.sceneKey, true);
1456
- };
1457
- const shutdownListener = () => {
1458
- const scene = getScene(__props.sceneKey);
1459
- runSceneShutdown(scene);
1460
- for (const [event, listener] of cameraFadeListeners) scene.cameras.main.off(event, listener);
1461
- emit("shutdown", scene);
1462
- };
1463
- onMounted(async () => {
1464
- const scene = useGame().scene.add(__props.sceneKey, NewScene);
1465
- if (!scene) {
1466
- console.error(`Failed to add scene: ${__props.sceneKey}`);
1467
- return;
1468
- }
1469
- scene.events.on(Scenes.Events.READY, readyListener);
1470
- scene.events.on(Scenes.Events.SHUTDOWN, shutdownListener);
1471
- if (__props.autoStart) await switchToScene(__props.sceneKey);
1472
- });
1473
- onUnmounted(() => {
1474
- const game = useGame();
1475
- const scene = getScene(__props.sceneKey);
1476
- scene.events.off(Scenes.Events.READY, readyListener);
1477
- scene.events.off(Scenes.Events.SHUTDOWN, shutdownListener);
1478
- game.scene.remove(__props.sceneKey);
1479
- });
1480
- provide(InjectionKeyMap.SceneKey, __props.sceneKey);
1481
- return (_ctx, _cache) => {
1482
- return isActive.value ? renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 0) : createCommentVNode("v-if", true);
1483
- };
1484
- }
1485
- });
1486
- //#endregion
1487
- //#region src/services/setterMap/shared/AnimationSetterMap.ts
1488
- const completionListeners = /* @__PURE__ */ new WeakMap();
1489
- const AnimationSetterMap = {
1490
- animations: (gameObject, emit) => (configurations) => {
1491
- if (!(configurations && configurations.length > 0)) return;
1492
- const listeners = completionListeners.get(gameObject) ?? /* @__PURE__ */ new Map();
1493
- completionListeners.set(gameObject, listeners);
1494
- for (const configuration of configurations) {
1495
- if (!configuration.key) continue;
1496
- const event = `${ANIMATION_COMPLETE_EVENT_PREFIX}${configuration.key}`;
1497
- const previousListener = listeners.get(event);
1498
- if (previousListener) gameObject.off(event, previousListener);
1499
- const listener = () => {
1500
- emit(event);
1501
- };
1502
- listeners.set(event, listener);
1503
- gameObject.once(event, listener);
1504
- if (gameObject.scene.anims.exists(configuration.key)) continue;
1505
- if (!gameObject.scene.anims.create(configuration)) throw new InvalidOperationError(Operation.Create, "Animation", configuration.key);
1506
- }
1507
- },
1508
- playAnimationKey: (gameObject) => (value) => {
1509
- if (value === void 0) {
1510
- gameObject.stop();
1511
- return;
1512
- }
1513
- gameObject.play(value);
1514
- }
1515
- };
1516
- //#endregion
1517
- //#region src/services/setterMap/SpriteSetterMap.ts
1518
- const SpriteSetterMap = {
1519
- ...AlphaSetterMap,
1520
- ...BlendModeSetterMap,
1521
- ...DepthSetterMap,
1522
- ...FlipSetterMap,
1523
- ...MaskSetterMap,
1524
- ...OriginSetterMap,
1525
- ...RenderNodesSetterMap,
1526
- ...ScrollFactorSetterMap,
1527
- ...SizeSetterMap,
1528
- ...TextureSetterMap,
1529
- ...TintSetterMap,
1530
- ...TransformSetterMap,
1531
- ...VisibleSetterMap,
1532
- ...AnimationSetterMap,
1533
- ...GlobalSetterMap
1534
- };
1535
- //#endregion
1536
- //#region src/components/Sprite.vue
1537
- const _sfc_main$19 = /*@__PURE__*/ defineComponent({
1538
- __name: "Sprite",
1539
- props: {
1540
- configuration: {},
1541
- immediate: { type: Boolean },
1542
- onComplete: { type: Function }
1543
- },
1544
- setup(__props, { emit: __emit }) {
1545
- useInitializeGameObject((scene) => {
1546
- const { frame, texture, x, y } = __props.configuration;
1547
- const sprite = scene.add.sprite(x ?? 0, y ?? 0, texture, frame);
1548
- __props.onComplete?.(scene, sprite);
1549
- return sprite;
1550
- }, () => __props.configuration, __emit, SpriteSetterMap, __props.immediate);
1551
- return (_ctx, _cache) => {
1552
- return null;
1553
- };
1554
- }
1555
- });
1556
- //#endregion
1557
- //#region src/services/setterMap/StarSetterMap.ts
1558
- const StarSetterMap = {
1559
- innerRadius: (gameObject) => (value) => {
1560
- if (value === void 0) return;
1561
- gameObject.setInnerRadius(value);
1562
- },
1563
- outerRadius: (gameObject) => (value) => {
1564
- if (value === void 0) return;
1565
- gameObject.setOuterRadius(value);
1566
- },
1567
- points: (gameObject) => (value) => {
1568
- if (value === void 0) return;
1569
- gameObject.setPoints(value);
1570
- },
1571
- ...ShapeSetterMap,
1572
- ...GlobalSetterMap
1573
- };
1574
- //#endregion
1575
- //#region src/components/Star.vue
1576
- const _sfc_main$20 = /*@__PURE__*/ defineComponent({
1577
- __name: "Star",
1578
- props: {
1579
- configuration: {},
1580
- immediate: { type: Boolean },
1581
- onComplete: { type: Function }
1582
- },
1583
- setup(__props, { emit: __emit }) {
1584
- useInitializeGameObject((scene) => {
1585
- const { alpha, fillColor, innerRadius, outerRadius, points, x, y } = __props.configuration;
1586
- const star = scene.add.star(x, y, points, innerRadius, outerRadius, fillColor, alpha);
1587
- __props.onComplete?.(scene, star);
1588
- return star;
1589
- }, () => __props.configuration, __emit, StarSetterMap, __props.immediate);
1590
- return (_ctx, _cache) => {
1591
- return null;
1592
- };
1593
- }
1594
- });
1595
- //#endregion
1596
- //#region src/services/setterMap/TextSetterMap.ts
1597
- const TextSetterMap = {
1598
- padding: (gameObject) => (value) => {
1599
- if (!value) return;
1600
- gameObject.setPadding(value);
1601
- },
1602
- style: (gameObject) => (value) => {
1603
- if (!value) return;
1604
- gameObject.setStyle(value);
1605
- },
1606
- text: (gameObject, emit) => (value) => {
1607
- if (value === void 0) return;
1608
- gameObject.setText(value);
1609
- emit("update:width", gameObject.width);
1610
- emit("update:displayWidth", gameObject.displayWidth);
1611
- },
1612
- ...RenderableSetterMap,
1613
- ...ComputedSizeSetterMap,
1614
- ...FlipSetterMap
1615
- };
1616
- //#endregion
1617
- //#region src/store/text.ts
1618
- const useTextStore = defineStore("phaser/text", () => {
1619
- return { defaultTextStyle: ref() };
1620
- });
1621
- //#endregion
1622
- //#region src/components/Text.vue
1623
- const _sfc_main$21 = /*@__PURE__*/ defineComponent({
1624
- __name: "Text",
1625
- props: {
1626
- configuration: {},
1627
- immediate: { type: Boolean }
1628
- },
1629
- setup(__props, { emit: __emit }) {
1630
- const emit = __emit;
1631
- const textStore = useTextStore();
1632
- const { defaultTextStyle } = storeToRefs(textStore);
1633
- useInitializeGameObject((scene) => {
1634
- const { style, text, x, y } = __props.configuration;
1635
- return scene.add.text(x ?? 0, y ?? 0, text, {
1636
- ...defaultTextStyle.value,
1637
- ...style
1638
- });
1639
- }, () => __props.configuration, emit, TextSetterMap, __props.immediate);
1640
- return (_ctx, _cache) => {
1641
- return null;
1642
- };
1643
- }
1644
- });
1645
- //#endregion
1646
- //#region src/services/setterMap/TileSpriteSetterMap.ts
1647
- const TileSpriteSetterMap = {
1648
- ...RenderableSetterMap,
1649
- ...ComputedSizeSetterMap,
1650
- ...FlipSetterMap,
1651
- ...TextureSetterMap
1652
- };
1653
- //#endregion
1654
- //#region src/components/TileSprite.vue
1655
- const _sfc_main$22 = /*@__PURE__*/ defineComponent({
1656
- __name: "TileSprite",
1657
- props: {
1658
- configuration: {},
1659
- immediate: { type: Boolean },
1660
- onComplete: { type: Function }
1661
- },
1662
- setup(__props, { emit: __emit }) {
1663
- useInitializeGameObject((scene) => {
1664
- const { frame, height, texture, width, x, y } = __props.configuration;
1665
- const tileSprite = scene.add.tileSprite(x ?? 0, y ?? 0, width ?? 0, height ?? 0, texture, frame);
1666
- __props.onComplete?.(scene, tileSprite);
1667
- return tileSprite;
1668
- }, () => __props.configuration, __emit, TileSpriteSetterMap, __props.immediate);
1669
- return (_ctx, _cache) => {
1670
- return null;
1671
- };
1672
- }
1673
- });
1674
- //#endregion
1675
- //#region src/components/Tilemap.vue
1676
- const _sfc_main$23 = /*@__PURE__*/ defineComponent({
1677
- __name: "Tilemap",
1678
- props: {
1679
- configuration: {},
1680
- onComplete: { type: Function }
1681
- },
1682
- setup(__props) {
1683
- const sceneKey = useInjectSceneKey();
1684
- const tilemap = shallowRef();
1685
- onCreate((newScene) => {
1686
- tilemap.value = newScene.make.tilemap(__props.configuration);
1687
- __props.onComplete?.(newScene, tilemap.value);
1688
- });
1689
- watch(() => __props.configuration.key, (newKey) => {
1690
- const scene = getScene(sceneKey);
1691
- const oldTilemap = tilemap.value;
1692
- if (newKey) {
1693
- tilemap.value = scene.make.tilemap(__props.configuration);
1694
- __props.onComplete?.(scene, tilemap.value);
1695
- } else tilemap.value = void 0;
1696
- if (oldTilemap) oldTilemap.destroy();
1697
- });
1698
- onUnmounted(() => {
1699
- if (!tilemap.value) return;
1700
- tilemap.value.destroy();
1701
- });
1702
- return (_ctx, _cache) => {
1703
- return renderSlot(_ctx.$slots, "default");
1704
- };
1705
- }
1706
- });
1707
- //#endregion
1708
- //#region src/services/setterMap/TriangleSetterMap.ts
1709
- const TriangleSetterMap = {
1710
- to: (gameObject) => (value) => {
1711
- if (!value) return;
1712
- gameObject.setTo(...value);
1713
- },
1714
- ...ShapeSetterMap,
1715
- ...GlobalSetterMap
1716
- };
1717
- //#endregion
1718
- //#region src/components/Triangle.vue
1719
- const _sfc_main$24 = /*@__PURE__*/ defineComponent({
1720
- __name: "Triangle",
1721
- props: {
1722
- configuration: {},
1723
- immediate: { type: Boolean },
1724
- onComplete: { type: Function }
1725
- },
1726
- setup(__props, { emit: __emit }) {
1727
- useInitializeGameObject((scene) => {
1728
- const { alpha, fillColor, to, x, y } = __props.configuration;
1729
- const triangle = scene.add.triangle(x, y, to?.[0], to?.[1], to?.[2], to?.[3], to?.[4], to?.[5], fillColor, alpha);
1730
- __props.onComplete?.(scene, triangle);
1731
- return triangle;
1732
- }, () => __props.configuration, __emit, TriangleSetterMap, __props.immediate);
1733
- return (_ctx, _cache) => {
1734
- return null;
1735
- };
1736
- }
1737
- });
1738
- //#endregion
1739
- //#region src/services/setterMap/VideoSetterMap.ts
1740
- const VideoSetterMap = {
1741
- key: (gameObject) => (value) => {
1742
- if (!value) return;
1743
- gameObject.changeSource(value);
1744
- },
1745
- muted: (gameObject) => (value) => {
1746
- gameObject.setMute(value);
1747
- },
1748
- volume: (gameObject) => (value) => {
1749
- gameObject.setVolume(value);
1750
- },
1751
- ...AlphaSetterMap,
1752
- ...BlendModeSetterMap,
1753
- ...DepthSetterMap,
1754
- ...FlipSetterMap,
1755
- ...MaskSetterMap,
1756
- ...OriginSetterMap,
1757
- ...RenderNodesSetterMap,
1758
- ...ScrollFactorSetterMap,
1759
- ...TextureCropSetterMap,
1760
- ...TintSetterMap,
1761
- ...TransformSetterMap,
1762
- ...VisibleSetterMap,
1763
- ...GlobalSetterMap
1764
- };
1765
- //#endregion
1766
- //#region src/components/Video.vue
1767
- const _sfc_main$25 = /*@__PURE__*/ defineComponent({
1768
- __name: "Video",
1769
- props: {
1770
- configuration: {},
1771
- immediate: { type: Boolean },
1772
- onComplete: { type: Function }
1773
- },
1774
- setup(__props, { emit: __emit }) {
1775
- useInitializeGameObject((scene) => {
1776
- const { key, x, y } = __props.configuration;
1777
- const video = scene.add.video(x ?? 0, y ?? 0, key);
1778
- __props.onComplete?.(scene, video);
1779
- return video;
1780
- }, () => __props.configuration, __emit, VideoSetterMap, __props.immediate);
1781
- return (_ctx, _cache) => {
1782
- return null;
1783
- };
1784
- }
1785
- });
1786
- //#endregion
1787
- //#region src/services/setterMap/ZoneSetterMap.ts
1788
- const ZoneSetterMap = {
1789
- ...ComputedSizeSetterMap,
1790
- ...DepthSetterMap,
1791
- ...OriginSetterMap,
1792
- ...ScrollFactorSetterMap,
1793
- ...TransformSetterMap,
1794
- ...VisibleSetterMap,
1795
- ...GlobalSetterMap
1796
- };
1797
- //#endregion
1798
- //#region src/components/Zone.vue
1799
- const _sfc_main$26 = /*@__PURE__*/ defineComponent({
1800
- __name: "Zone",
1801
- props: { configuration: {} },
1802
- setup(__props, { emit: __emit }) {
1803
- useInitializeGameObject((scene) => {
1804
- const { height, width, x, y } = __props.configuration;
1805
- return scene.add.zone(x, y, width, height);
1806
- }, () => __props.configuration, __emit, ZoneSetterMap);
1807
- return (_ctx, _cache) => {
1808
- return null;
1809
- };
1810
- }
1811
- });
1812
- //#endregion
1813
- //#region src/hooks/onShutdown.ts
1814
- const onShutdown = (...args) => {
1815
- pushListener("Shutdown", ...args);
1816
- };
1817
- //#endregion
1818
- //#region src/composables/useAnimations.ts
1819
- const useAnimations = (createConfigurations, immediate) => {
1820
- const animations = ref([]);
1821
- if (immediate) {
1822
- const sceneKey = useInjectSceneKey();
1823
- animations.value = createConfigurations(getScene(sceneKey));
1824
- } else onNextTick((scene) => {
1825
- animations.value = createConfigurations(scene);
1826
- });
1827
- onShutdown((scene) => {
1828
- for (const { key } of animations.value) {
1829
- if (!key) continue;
1830
- scene.anims.remove(key);
1831
- }
1832
- });
1833
- return animations;
1834
- };
1835
- //#endregion
1836
- //#region src/composables/useTween.ts
1837
- const useTween = (tween, newTween) => {
1838
- tween.value = {
1839
- ...newTween,
1840
- onComplete: (...args) => {
1841
- tween.value = void 0;
1842
- newTween.onComplete?.(...args);
1843
- }
1844
- };
1845
- };
1846
- //#endregion
1847
- //#region src/hooks/onInit.ts
1848
- const onInit = (...args) => {
1849
- pushListener("Init", ...args);
1850
- };
1851
- //#endregion
1852
- //#region src/hooks/onPreload.ts
1853
- const onPreload = (...args) => {
1854
- pushListener("Preload", ...args);
1855
- };
1856
- //#endregion
1857
- //#region src/hooks/onUpdate.ts
1858
- const onUpdate = (...args) => {
1859
- pushListener("Update", ...args);
1860
- };
1861
- //#endregion
1862
- //#region src/models/plugins/TilemapFile.ts
1863
- const JSONFile = Loader.FileTypes.JSONFile;
1864
- var TilemapFile = class extends JSONFile {};
1865
- //#endregion
1866
- //#region src/services/shared/sleepScene.ts
1867
- const sleepScene = (scene, durationMs) => new Promise((resolve) => {
1868
- const settle = () => {
1869
- scene.events.off(Scenes.Events.SHUTDOWN, settle);
1870
- resolve();
1871
- };
1872
- scene.time.delayedCall(durationMs, settle);
1873
- scene.events.once(Scenes.Events.SHUTDOWN, settle);
1874
- });
1875
- //#endregion
1876
- export { ANIMATION_COMPLETE_EVENT_PREFIX, AlphaSetterMap, AlphaSingleSetterMap, AnimationSetterMap, _sfc_main as Arc, ArcSetterMap, BaseTextureSetterMap, _sfc_main$1 as BitmapText, BitmapTextSetterMap, BlendModeSetterMap, _sfc_main$2 as Circle, ComputedSizeSetterMap, _sfc_main$3 as Container, ContainerSetterMap, _sfc_main$4 as Curve, CurveSetterMap, DepthSetterMap, DisplaySizeSetterMap, EVENT_PREFIX, _sfc_main$5 as Ellipse, EllipseSetterMap, ExternalSceneStore, FlipSetterMap, _sfc_main$6 as Game, GameObjectEventMap, GameObjectSetterMap, GlobalSetterMap, _sfc_main$7 as Graphics, GraphicsSetterMap, _sfc_main$8 as Image, ImageSetterMap, InjectionKeyMap, _sfc_main$9 as IsoBox, IsoBoxSetterMap, IsoSetterMap, _sfc_main$10 as IsoTriangle, IsoTriangleSetterMap, Lifecycle, _sfc_main$11 as Line, LineSetterMap, MaskSetterMap, _sfc_main$12 as Nineslice, NinesliceSetterMap, OriginSetterMap, _sfc_main$13 as Particles, ParticlesSetterMap, _sfc_main$14 as PathFollower, PathFollowerComponentSetterMap, PathFollowerSetterMap, _sfc_main$15 as Polygon, PolygonSetterMap, _sfc_main$16 as Rectangle, RectangleSetterMap, RenderNodesSetterMap, _sfc_main$17 as RenderTexture, RenderTextureSetterMap, RenderableSetterMap, _sfc_main$18 as Scene, ScrollFactorSetterMap, ShapeSetterMap, SizeSetterMap, _sfc_main$19 as Sprite, SpriteSetterMap, _sfc_main$20 as Star, StarSetterMap, TILEMAP_TILED_JSON_EXTERNAL_KEY, _sfc_main$21 as Text, TextSetterMap, TextureCropSetterMap, TextureSetterMap, _sfc_main$22 as TileSprite, TileSpriteSetterMap, TiledJSONExternalFile, _sfc_main$23 as Tilemap, TilemapFile, TilesetFile, TintSetterMap, TransformSetterMap, _sfc_main$24 as Triangle, TriangleSetterMap, TweenSetterMap, _sfc_main$25 as Video, VideoSetterMap, VisibleSetterMap, _sfc_main$26 as Zone, ZoneSetterMap, checkIsEvent, createSceneClass, getDepthInsertIndex, getEventName, getInitializeGameObjectLifecycleHook, getScene, getUpdateEvent, onCreate, onInit, onNextTick, onPreload, onShutdown, onUpdate, pushGameObject, pushListener, registerTiledJSONExternalLoader, resetLifecycleListeners, runLifecycleListeners, runSceneShutdown, sleepScene, useAnimations, useCameraStore, useGame, useInitializeGameObject, useInitializeGameObjectEvents, useInitializeGameObjectSetters, useInjectSceneKey, useInputStore, usePhaserStore, useTextStore, useTween };