@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/LICENSE +19 -0
- package/dist/Game/AnimationManager.d.ts +1 -1
- package/dist/Game/AnimationManager.js +18 -9
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/AnimationManager.spec.d.ts +1 -0
- package/dist/Game/Event.js.map +1 -1
- package/dist/Game/Map.d.ts +9 -1
- package/dist/Game/Map.js +63 -5
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.d.ts +47 -15
- package/dist/Game/Object.js +82 -38
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Player.js.map +1 -1
- package/dist/Game/ProjectileManager.d.ts +89 -0
- package/dist/Game/ProjectileManager.js +179 -0
- package/dist/Game/ProjectileManager.js.map +1 -0
- package/dist/Game/ProjectileManager.spec.d.ts +1 -0
- package/dist/Gui/Gui.d.ts +17 -4
- package/dist/Gui/Gui.js +78 -48
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/Gui.spec.d.ts +1 -0
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/Resource.js +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/RpgClient.d.ts +110 -15
- package/dist/RpgClientEngine.d.ts +86 -10
- package/dist/RpgClientEngine.js +306 -49
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorateMetadata.js +1 -1
- package/dist/components/animations/animation.ce.js +4 -5
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +19 -25
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.js +4 -4
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +422 -240
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +97 -0
- package/dist/components/dynamics/bar.ce.js.map +1 -0
- package/dist/components/dynamics/image.ce.js +24 -0
- package/dist/components/dynamics/image.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +3 -0
- package/dist/components/dynamics/parse-value.js +54 -35
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
- package/dist/components/dynamics/shape-utils.d.ts +16 -0
- package/dist/components/dynamics/shape-utils.js +73 -0
- package/dist/components/dynamics/shape-utils.js.map +1 -0
- package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
- package/dist/components/dynamics/shape.ce.js +84 -0
- package/dist/components/dynamics/shape.ce.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +34 -56
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +6 -8
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +56 -62
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +42 -65
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +21 -30
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +112 -165
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +8 -6
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +52 -69
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +75 -92
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +5 -4
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +12 -17
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/index.js +2 -2
- package/dist/components/gui/mobile/index.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +5 -4
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +22 -24
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +72 -249
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +90 -127
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +45 -70
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1 -0
- package/dist/components/player-components-utils.d.ts +67 -0
- package/dist/components/player-components-utils.js +162 -0
- package/dist/components/player-components-utils.js.map +1 -0
- package/dist/components/player-components-utils.spec.d.ts +1 -0
- package/dist/components/player-components.ce.js +189 -0
- package/dist/components/player-components.ce.js.map +1 -0
- package/dist/components/prebuilt/hp-bar.ce.js +42 -44
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +36 -59
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +165 -21
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +25 -32
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +9 -8
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +1 -1
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.js +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/decorators/spritesheet.d.ts +1 -0
- package/dist/decorators/spritesheet.js +11 -0
- package/dist/decorators/spritesheet.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -21
- package/dist/module.js +15 -1
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.0.1}/node_modules/@signe/di/dist/index.js +7 -117
- package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.0.1}/node_modules/@signe/sync/dist/index.js +57 -141
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
- package/dist/presets/animation.js.map +1 -1
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/icon.js.map +1 -1
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/lpc.js.map +1 -1
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/actionInput.d.ts +12 -0
- package/dist/services/actionInput.js +27 -0
- package/dist/services/actionInput.js.map +1 -0
- package/dist/services/actionInput.spec.d.ts +1 -0
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/loadMap.d.ts +6 -0
- package/dist/services/loadMap.js +1 -1
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mmorpg-connection.d.ts +5 -0
- package/dist/services/mmorpg-connection.js +50 -0
- package/dist/services/mmorpg-connection.js.map +1 -0
- package/dist/services/mmorpg-connection.spec.d.ts +1 -0
- package/dist/services/mmorpg.d.ts +10 -4
- package/dist/services/mmorpg.js +56 -33
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/pointerContext.d.ts +11 -0
- package/dist/services/pointerContext.js +48 -0
- package/dist/services/pointerContext.js.map +1 -0
- package/dist/services/pointerContext.spec.d.ts +1 -0
- package/dist/services/save.js.map +1 -1
- package/dist/services/save.spec.d.ts +1 -0
- package/dist/services/standalone-message.d.ts +1 -0
- package/dist/services/standalone-message.js +9 -0
- package/dist/services/standalone-message.js.map +1 -0
- package/dist/services/standalone.js +4 -3
- package/dist/services/standalone.js.map +1 -1
- package/dist/services/standalone.spec.d.ts +1 -0
- package/dist/utils/getEntityProp.js +4 -3
- package/dist/utils/getEntityProp.js.map +1 -1
- package/dist/utils/getEntityProp.spec.d.ts +1 -0
- package/dist/utils/readPropValue.d.ts +2 -0
- package/dist/utils/readPropValue.js +13 -0
- package/dist/utils/readPropValue.js.map +1 -0
- package/package.json +13 -14
- package/src/Game/AnimationManager.spec.ts +30 -0
- package/src/Game/AnimationManager.ts +22 -10
- package/src/Game/Map.ts +91 -2
- package/src/Game/Object.ts +148 -69
- package/src/Game/ProjectileManager.spec.ts +338 -0
- package/src/Game/ProjectileManager.ts +324 -0
- package/src/Gui/Gui.spec.ts +273 -0
- package/src/Gui/Gui.ts +105 -50
- package/src/Resource.ts +1 -2
- package/src/RpgClient.ts +125 -17
- package/src/RpgClientEngine.ts +457 -87
- package/src/components/character.ce +441 -32
- package/src/components/dynamics/bar.ce +88 -0
- package/src/components/dynamics/image.ce +21 -0
- package/src/components/dynamics/parse-value.spec.ts +83 -0
- package/src/components/dynamics/parse-value.ts +111 -37
- package/src/components/dynamics/shape-utils.spec.ts +46 -0
- package/src/components/dynamics/shape-utils.ts +61 -0
- package/src/components/dynamics/shape.ce +90 -0
- package/src/components/dynamics/text.ce +35 -149
- package/src/components/gui/dialogbox/index.ce +18 -8
- package/src/components/gui/gameover.ce +2 -1
- package/src/components/gui/menu/equip-menu.ce +2 -1
- package/src/components/gui/menu/exit-menu.ce +2 -1
- package/src/components/gui/menu/items-menu.ce +3 -2
- package/src/components/gui/menu/main-menu.ce +2 -1
- package/src/components/gui/save-load.ce +2 -1
- package/src/components/gui/shop/shop.ce +3 -2
- package/src/components/gui/title-screen.ce +2 -1
- package/src/components/index.ts +2 -1
- package/src/components/player-components-utils.spec.ts +109 -0
- package/src/components/player-components-utils.ts +205 -0
- package/src/components/player-components.ce +222 -0
- package/src/components/prebuilt/hp-bar.ce +4 -3
- package/src/components/prebuilt/light-halo.ce +2 -2
- package/src/components/scenes/canvas.ce +175 -8
- package/src/components/scenes/draw-map.ce +18 -17
- package/src/components/scenes/event-layer.ce +1 -2
- package/src/core/setup.ts +2 -2
- package/src/decorators/spritesheet.ts +8 -0
- package/src/index.ts +4 -0
- package/src/module.ts +18 -1
- package/src/services/actionInput.spec.ts +101 -0
- package/src/services/actionInput.ts +53 -0
- package/src/services/loadMap.ts +2 -0
- package/src/services/mmorpg-connection.spec.ts +99 -0
- package/src/services/mmorpg-connection.ts +69 -0
- package/src/services/mmorpg.ts +68 -36
- package/src/services/pointerContext.spec.ts +36 -0
- package/src/services/pointerContext.ts +84 -0
- package/src/services/save.spec.ts +127 -0
- package/src/services/standalone-message.ts +7 -0
- package/src/services/standalone.spec.ts +34 -0
- package/src/services/standalone.ts +3 -2
- package/src/utils/getEntityProp.spec.ts +96 -0
- package/src/utils/getEntityProp.ts +4 -3
- package/src/utils/readPropValue.ts +16 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
|
@@ -1,146 +1,40 @@
|
|
|
1
1
|
import { inject } from "../core/inject.js";
|
|
2
|
+
import { getKeyboardControlBind, resolveKeyboardActionInput } from "../services/actionInput.js";
|
|
3
|
+
import { getCanMoveValue } from "../utils/readPropValue.js";
|
|
2
4
|
import { RpgGui } from "../Gui/Gui.js";
|
|
3
5
|
import { RpgClientEngine } from "../RpgClientEngine.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { Direction, ModulesToken } from "@rpgjs/common";
|
|
6
|
+
import __ce_component$1 from "./player-components.ce.js";
|
|
7
|
+
import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
|
|
8
|
+
import { Animation, Direction, ModulesToken } from "@rpgjs/common";
|
|
7
9
|
import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
|
|
10
|
+
import { Particle } from "@canvasengine/presets";
|
|
11
|
+
import { Assets } from "pixi.js";
|
|
8
12
|
//#region src/components/character.ce
|
|
9
13
|
function component($$props) {
|
|
10
14
|
useProps($$props);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
17
|
-
}
|
|
18
|
-
return t;
|
|
19
|
-
};
|
|
20
|
-
return __assign.apply(this, arguments);
|
|
21
|
-
};
|
|
22
|
-
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
23
|
-
function adopt(value) {
|
|
24
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
25
|
-
resolve(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
29
|
-
function fulfilled(value) {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.next(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function rejected(value) {
|
|
37
|
-
try {
|
|
38
|
-
step(generator["throw"](value));
|
|
39
|
-
} catch (e) {
|
|
40
|
-
reject(e);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function step(result) {
|
|
44
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
45
|
-
}
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
50
|
-
var _ = {
|
|
51
|
-
label: 0,
|
|
52
|
-
sent: function() {
|
|
53
|
-
if (t[0] & 1) throw t[1];
|
|
54
|
-
return t[1];
|
|
55
|
-
},
|
|
56
|
-
trys: [],
|
|
57
|
-
ops: []
|
|
58
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
59
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
60
|
-
return this;
|
|
61
|
-
}), g;
|
|
62
|
-
function verb(n) {
|
|
63
|
-
return function(v) {
|
|
64
|
-
return step([n, v]);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function step(op) {
|
|
68
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
69
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
70
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
71
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
72
|
-
switch (op[0]) {
|
|
73
|
-
case 0:
|
|
74
|
-
case 1:
|
|
75
|
-
t = op;
|
|
76
|
-
break;
|
|
77
|
-
case 4:
|
|
78
|
-
_.label++;
|
|
79
|
-
return {
|
|
80
|
-
value: op[1],
|
|
81
|
-
done: false
|
|
82
|
-
};
|
|
83
|
-
case 5:
|
|
84
|
-
_.label++;
|
|
85
|
-
y = op[1];
|
|
86
|
-
op = [0];
|
|
87
|
-
continue;
|
|
88
|
-
case 7:
|
|
89
|
-
op = _.ops.pop();
|
|
90
|
-
_.trys.pop();
|
|
91
|
-
continue;
|
|
92
|
-
default:
|
|
93
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
94
|
-
_ = 0;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
98
|
-
_.label = op[1];
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
102
|
-
_.label = t[1];
|
|
103
|
-
t = op;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
if (t && _.label < t[2]) {
|
|
107
|
-
_.label = t[2];
|
|
108
|
-
_.ops.push(op);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
if (t[2]) _.ops.pop();
|
|
112
|
-
_.trys.pop();
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
op = body.call(thisArg, _);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
op = [6, e];
|
|
118
|
-
y = 0;
|
|
119
|
-
} finally {
|
|
120
|
-
f = t = 0;
|
|
121
|
-
}
|
|
122
|
-
if (op[0] & 5) throw op[1];
|
|
123
|
-
return {
|
|
124
|
-
value: op[0] ? op[1] : void 0,
|
|
125
|
-
done: true
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var _a = defineProps(), object = _a.object, id = _a.id;
|
|
130
|
-
var client = inject(RpgClientEngine);
|
|
131
|
-
var hooks = inject(ModulesToken);
|
|
132
|
-
var guiService = inject(RpgGui);
|
|
15
|
+
const { object, id } = useDefineProps($$props)();
|
|
16
|
+
const sprite = object();
|
|
17
|
+
const client = inject(RpgClientEngine);
|
|
18
|
+
const hooks = inject(ModulesToken);
|
|
19
|
+
const guiService = inject(RpgGui);
|
|
133
20
|
client.spritesheets;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
21
|
+
const componentsBehind = client.spriteComponentsBehind;
|
|
22
|
+
const componentsInFront = client.spriteComponentsInFront;
|
|
23
|
+
const readProp = (value) => typeof value === "function" ? value() : value;
|
|
24
|
+
const isCurrentPlayer = () => {
|
|
25
|
+
const playerId = client.playerIdSignal();
|
|
26
|
+
const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : void 0;
|
|
27
|
+
return readProp(id) === playerId || readProp(sprite?.id) === playerId || sprite === currentPlayer || sprite === client.sceneMap?.getCurrentPlayer?.();
|
|
28
|
+
};
|
|
29
|
+
const isMe = computed(isCurrentPlayer);
|
|
30
|
+
const shadowsEnabled = computed(() => {
|
|
31
|
+
const lighting = client.sceneMap?.lighting?.();
|
|
32
|
+
return Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);
|
|
139
33
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
34
|
+
const normalizeComponent = (comp) => {
|
|
35
|
+
let componentRef;
|
|
36
|
+
let propsValue;
|
|
37
|
+
let dependenciesFn;
|
|
144
38
|
if (typeof comp === "function" || comp && typeof comp === "object" && !comp.component) {
|
|
145
39
|
componentRef = comp;
|
|
146
40
|
propsValue = void 0;
|
|
@@ -156,40 +50,37 @@ function component($$props) {
|
|
|
156
50
|
}
|
|
157
51
|
return {
|
|
158
52
|
component: componentRef,
|
|
159
|
-
props: typeof propsValue === "function" ? propsValue(
|
|
160
|
-
dependencies: dependenciesFn ? dependenciesFn(
|
|
53
|
+
props: typeof propsValue === "function" ? propsValue(sprite) : propsValue || {},
|
|
54
|
+
dependencies: dependenciesFn ? dependenciesFn(sprite) : []
|
|
161
55
|
};
|
|
162
56
|
};
|
|
163
|
-
|
|
164
|
-
return components.map(
|
|
165
|
-
return normalizeComponent(comp);
|
|
166
|
-
});
|
|
57
|
+
const normalizeComponents = (components) => {
|
|
58
|
+
return components.map((comp) => normalizeComponent(comp));
|
|
167
59
|
};
|
|
168
|
-
|
|
60
|
+
const normalizedComponentsBehind = computed(() => {
|
|
169
61
|
return normalizeComponents(componentsBehind());
|
|
170
62
|
});
|
|
171
|
-
|
|
63
|
+
const normalizedComponentsInFront = computed(() => {
|
|
172
64
|
return normalizeComponents(componentsInFront());
|
|
173
65
|
});
|
|
174
|
-
|
|
175
|
-
|
|
66
|
+
const shouldFollowCamera = computed(() => {
|
|
67
|
+
const cameraTargetId = client.cameraFollowTargetId();
|
|
176
68
|
if (cameraTargetId !== null) return id() === cameraTargetId;
|
|
177
69
|
return isMe();
|
|
178
70
|
});
|
|
179
|
-
|
|
71
|
+
const attachedGuis = computed(() => {
|
|
180
72
|
return guiService.getAttachedGuis();
|
|
181
73
|
});
|
|
182
|
-
|
|
74
|
+
const shouldDisplayAttachedGui = computed(() => {
|
|
183
75
|
return guiService.shouldDisplayAttachedGui(id());
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
on(flashTrigger, function(data) {
|
|
76
|
+
});
|
|
77
|
+
const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = sprite;
|
|
78
|
+
const flashType = signal("alpha");
|
|
79
|
+
const flashDuration = signal(300);
|
|
80
|
+
const flashCycles = signal(1);
|
|
81
|
+
const flashAlpha = signal(.3);
|
|
82
|
+
const flashTint = signal(16777215);
|
|
83
|
+
on(flashTrigger, (data) => {
|
|
193
84
|
if (data && typeof data === "object") {
|
|
194
85
|
if (data.type !== void 0) flashType.set(data.type);
|
|
195
86
|
if (data.duration !== void 0) flashDuration.set(data.duration);
|
|
@@ -198,149 +89,413 @@ function component($$props) {
|
|
|
198
89
|
if (data.tint !== void 0) flashTint.set(data.tint);
|
|
199
90
|
}
|
|
200
91
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
215
|
-
var keyboardControls = client.globalConfig.keyboardControls;
|
|
216
|
-
var visible = computed(function() {
|
|
217
|
-
if (object.isEvent()) return true;
|
|
92
|
+
const flashConfig = computed(() => ({
|
|
93
|
+
trigger: flashTrigger,
|
|
94
|
+
type: flashType(),
|
|
95
|
+
duration: flashDuration(),
|
|
96
|
+
cycles: flashCycles(),
|
|
97
|
+
alpha: flashAlpha(),
|
|
98
|
+
tint: flashTint()
|
|
99
|
+
}));
|
|
100
|
+
const particleSettings = client.particleSettings;
|
|
101
|
+
const canControls = () => isMe() && getCanMoveValue(sprite);
|
|
102
|
+
const keyboardControls = client.globalConfig.keyboardControls;
|
|
103
|
+
const visible = computed(() => {
|
|
104
|
+
if (sprite.isEvent()) return true;
|
|
218
105
|
return isConnected();
|
|
219
106
|
});
|
|
220
|
-
|
|
107
|
+
const controls = {
|
|
221
108
|
down: {
|
|
222
109
|
repeat: true,
|
|
223
110
|
bind: keyboardControls.down,
|
|
224
|
-
keyDown
|
|
111
|
+
keyDown() {
|
|
225
112
|
if (canControls()) client.processInput({ input: Direction.Down });
|
|
226
113
|
}
|
|
227
114
|
},
|
|
228
115
|
up: {
|
|
229
116
|
repeat: true,
|
|
230
117
|
bind: keyboardControls.up,
|
|
231
|
-
keyDown
|
|
118
|
+
keyDown() {
|
|
232
119
|
if (canControls()) client.processInput({ input: Direction.Up });
|
|
233
120
|
}
|
|
234
121
|
},
|
|
235
122
|
left: {
|
|
236
123
|
repeat: true,
|
|
237
124
|
bind: keyboardControls.left,
|
|
238
|
-
keyDown
|
|
125
|
+
keyDown() {
|
|
239
126
|
if (canControls()) client.processInput({ input: Direction.Left });
|
|
240
127
|
}
|
|
241
128
|
},
|
|
242
129
|
right: {
|
|
243
130
|
repeat: true,
|
|
244
131
|
bind: keyboardControls.right,
|
|
245
|
-
keyDown
|
|
132
|
+
keyDown() {
|
|
246
133
|
if (canControls()) client.processInput({ input: Direction.Right });
|
|
247
134
|
}
|
|
248
135
|
},
|
|
249
136
|
action: {
|
|
250
|
-
bind: keyboardControls.action,
|
|
251
|
-
keyDown
|
|
252
|
-
if (canControls()) client.processAction(
|
|
137
|
+
bind: getKeyboardControlBind(keyboardControls.action),
|
|
138
|
+
keyDown() {
|
|
139
|
+
if (canControls()) client.processAction(resolveKeyboardActionInput(keyboardControls.action, client, sprite));
|
|
253
140
|
}
|
|
254
141
|
},
|
|
255
142
|
escape: {
|
|
256
143
|
bind: keyboardControls.escape,
|
|
257
|
-
keyDown
|
|
144
|
+
keyDown() {
|
|
258
145
|
if (canControls()) client.processAction({ action: "escape" });
|
|
259
146
|
}
|
|
260
147
|
},
|
|
261
148
|
gamepad: { enabled: true }
|
|
149
|
+
};
|
|
150
|
+
const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
|
|
151
|
+
const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
|
|
152
|
+
const z = computed(() => {
|
|
153
|
+
return sprite.y() + sprite.z();
|
|
262
154
|
});
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
var z = computed(function() {
|
|
266
|
-
return object.y() + object.z();
|
|
267
|
-
});
|
|
268
|
-
var realAnimationName = signal(animationName());
|
|
269
|
-
var xSubscription = x.observable.subscribe(function(value) {
|
|
155
|
+
const realAnimationName = signal(animationName());
|
|
156
|
+
const xSubscription = x.observable.subscribe((value) => {
|
|
270
157
|
smoothX.set(value);
|
|
271
158
|
});
|
|
272
|
-
|
|
159
|
+
const ySubscription = y.observable.subscribe((value) => {
|
|
273
160
|
smoothY.set(value);
|
|
274
161
|
});
|
|
275
|
-
|
|
162
|
+
const sheet = (graphicObject) => {
|
|
276
163
|
return {
|
|
277
164
|
definition: graphicObject,
|
|
278
165
|
playing: realAnimationName(),
|
|
279
166
|
params: { direction: direction() },
|
|
280
|
-
onFinish
|
|
281
|
-
animationCurrentIndex.update(
|
|
282
|
-
return index + 1;
|
|
283
|
-
});
|
|
167
|
+
onFinish() {
|
|
168
|
+
animationCurrentIndex.update((index) => index + 1);
|
|
284
169
|
}
|
|
285
170
|
};
|
|
286
171
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
172
|
+
const graphicScale = (graphicObject) => {
|
|
173
|
+
const scale = graphicObject?.scale;
|
|
174
|
+
if (Array.isArray(scale)) return scale;
|
|
175
|
+
if (typeof scale === "number") return [scale, scale];
|
|
176
|
+
if (scale && typeof scale === "object") {
|
|
177
|
+
const x = typeof scale.x === "number" ? scale.x : 1;
|
|
178
|
+
return [x, typeof scale.y === "number" ? scale.y : x];
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const shadowCaster = (graphicObject) => {
|
|
182
|
+
const box = hitbox();
|
|
183
|
+
const bounds = graphicBounds();
|
|
184
|
+
const scale = graphicScale(graphicObject);
|
|
185
|
+
const scaleY = Array.isArray(scale) && typeof scale[1] === "number" ? Math.abs(scale[1]) : 1;
|
|
186
|
+
const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;
|
|
187
|
+
return {
|
|
188
|
+
enabled: shadowsEnabled,
|
|
189
|
+
height,
|
|
190
|
+
footAnchor: {
|
|
191
|
+
x: .5,
|
|
192
|
+
y: 1
|
|
193
|
+
},
|
|
194
|
+
footOffset: {
|
|
195
|
+
x: 0,
|
|
196
|
+
y: 2
|
|
197
|
+
},
|
|
198
|
+
alpha: .5,
|
|
199
|
+
blur: 3.5,
|
|
200
|
+
gradientPower: 2,
|
|
201
|
+
hardness: .42,
|
|
202
|
+
minLength: Math.max(6, (box?.h ?? 32) * .25),
|
|
203
|
+
maxLength: Math.max(90, height * 1.8),
|
|
204
|
+
contactAlpha: .3,
|
|
205
|
+
contactScale: .3
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
const imageDimensions = signal({});
|
|
209
|
+
const loadingImageDimensions = /* @__PURE__ */ new Set();
|
|
210
|
+
const toPositiveNumber = (value) => {
|
|
211
|
+
const number = typeof value === "number" ? value : parseFloat(value);
|
|
212
|
+
return Number.isFinite(number) && number > 0 ? number : void 0;
|
|
213
|
+
};
|
|
214
|
+
const toFiniteNumber = (value, fallback = 0) => {
|
|
215
|
+
const number = typeof value === "number" ? value : parseFloat(value);
|
|
216
|
+
return Number.isFinite(number) ? number : fallback;
|
|
217
|
+
};
|
|
218
|
+
const clampRatio = (value) => Math.min(1, Math.max(0, value));
|
|
219
|
+
const normalizePair = (value, fallback = [1, 1]) => {
|
|
220
|
+
if (Array.isArray(value)) {
|
|
221
|
+
const x = toFiniteNumber(value[0], fallback[0]);
|
|
222
|
+
return [x, toFiniteNumber(value[1] ?? value[0], x)];
|
|
223
|
+
}
|
|
224
|
+
if (typeof value === "number") return [value, value];
|
|
225
|
+
if (value && typeof value === "object") {
|
|
226
|
+
const x = toFiniteNumber(value.x, fallback[0]);
|
|
227
|
+
return [x, toFiniteNumber(value.y ?? value.x, x)];
|
|
228
|
+
}
|
|
229
|
+
return fallback;
|
|
230
|
+
};
|
|
231
|
+
const normalizeAnchor = (value) => {
|
|
232
|
+
if (!Array.isArray(value)) return void 0;
|
|
233
|
+
const [x, y] = normalizePair(value, [0, 0]);
|
|
234
|
+
return [clampRatio(x), clampRatio(y)];
|
|
235
|
+
};
|
|
236
|
+
const resolveImageSource = (image) => {
|
|
237
|
+
if (typeof image === "string") return image;
|
|
238
|
+
if (typeof image?.default === "string") return image.default;
|
|
239
|
+
};
|
|
240
|
+
const parentTextureOptions = (graphicObject) => {
|
|
241
|
+
return [
|
|
242
|
+
"width",
|
|
243
|
+
"height",
|
|
244
|
+
"framesHeight",
|
|
245
|
+
"framesWidth",
|
|
246
|
+
"rectWidth",
|
|
247
|
+
"rectHeight",
|
|
248
|
+
"offset",
|
|
249
|
+
"image",
|
|
250
|
+
"sound",
|
|
251
|
+
"spriteRealSize",
|
|
252
|
+
"scale",
|
|
253
|
+
"anchor",
|
|
254
|
+
"pivot",
|
|
255
|
+
"x",
|
|
256
|
+
"y",
|
|
257
|
+
"opacity"
|
|
258
|
+
].reduce((options, prop) => {
|
|
259
|
+
if (graphicObject?.[prop] !== void 0) options[prop] = graphicObject[prop];
|
|
260
|
+
return options;
|
|
261
|
+
}, {});
|
|
262
|
+
};
|
|
263
|
+
const resolveTextureOptions = (graphicObject) => {
|
|
264
|
+
const textures = graphicObject?.textures ?? {};
|
|
265
|
+
const texture = textures[realAnimationName()] ?? textures[Animation.Stand] ?? Object.values(textures)[0] ?? {};
|
|
266
|
+
return {
|
|
267
|
+
...parentTextureOptions(graphicObject),
|
|
268
|
+
...texture
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
const resolveFirstAnimationFrame = (textureOptions) => {
|
|
272
|
+
const animations = textureOptions?.animations;
|
|
273
|
+
if (!animations) return {};
|
|
274
|
+
try {
|
|
275
|
+
const frames = typeof animations === "function" ? animations({ direction: direction() }) : animations;
|
|
276
|
+
if (!Array.isArray(frames)) return {};
|
|
277
|
+
const firstGroup = frames[0];
|
|
278
|
+
return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};
|
|
279
|
+
} catch {
|
|
280
|
+
return {};
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const optionValue = (prop, frame, textureOptions, graphicObject) => {
|
|
284
|
+
return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];
|
|
285
|
+
};
|
|
286
|
+
const resolveFrameSize = (textureOptions, dimensions) => {
|
|
287
|
+
const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;
|
|
288
|
+
const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;
|
|
289
|
+
const imageSource = resolveImageSource(textureOptions?.image);
|
|
290
|
+
const loadedSize = imageSource ? dimensions[imageSource] : void 0;
|
|
291
|
+
const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;
|
|
292
|
+
const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;
|
|
293
|
+
return {
|
|
294
|
+
width: toPositiveNumber(textureOptions?.rectWidth) ?? toPositiveNumber(textureOptions?.spriteWidth) ?? (fullWidth ? fullWidth / framesWidth : void 0),
|
|
295
|
+
height: toPositiveNumber(textureOptions?.rectHeight) ?? toPositiveNumber(textureOptions?.spriteHeight) ?? (fullHeight ? fullHeight / framesHeight : void 0)
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
|
|
299
|
+
if (!spriteWidth || !spriteHeight || !box) return [0, 0];
|
|
300
|
+
const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
|
|
301
|
+
const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
|
|
302
|
+
const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
|
|
303
|
+
const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
|
|
304
|
+
const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
|
|
305
|
+
const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
|
|
306
|
+
const footY = clampRatio((spriteHeight - gap) / spriteHeight);
|
|
307
|
+
switch (box.anchorMode ?? "top-left") {
|
|
308
|
+
case "center": return [hitboxCenterX, hitboxCenterY];
|
|
309
|
+
case "foot": return [hitboxCenterX, footY];
|
|
310
|
+
default: return [hitboxTopLeftX, hitboxTopLeftY];
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const loadImageDimensions = (image) => {
|
|
314
|
+
const source = resolveImageSource(image);
|
|
315
|
+
if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) return;
|
|
316
|
+
loadingImageDimensions.add(source);
|
|
317
|
+
Assets.load(source).then((texture) => {
|
|
318
|
+
const width = toPositiveNumber(texture?.width);
|
|
319
|
+
const height = toPositiveNumber(texture?.height);
|
|
320
|
+
if (!width || !height) return;
|
|
321
|
+
imageDimensions.update((dimensions) => ({
|
|
322
|
+
...dimensions,
|
|
323
|
+
[source]: {
|
|
324
|
+
width,
|
|
325
|
+
height
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
}).catch(() => {}).finally(() => {
|
|
329
|
+
loadingImageDimensions.delete(source);
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
effect(() => {
|
|
333
|
+
const sources = /* @__PURE__ */ new Set();
|
|
334
|
+
graphicsSignals().forEach((graphicObject) => {
|
|
335
|
+
const baseImage = resolveImageSource(graphicObject?.image);
|
|
336
|
+
if (baseImage) sources.add(baseImage);
|
|
337
|
+
Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {
|
|
338
|
+
const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);
|
|
339
|
+
if (image) sources.add(image);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
sources.forEach((source) => loadImageDimensions(source));
|
|
343
|
+
});
|
|
344
|
+
const hitboxBounds = computed(() => {
|
|
345
|
+
const box = hitbox();
|
|
346
|
+
const width = box?.w ?? 0;
|
|
347
|
+
const height = box?.h ?? 0;
|
|
348
|
+
return {
|
|
349
|
+
left: 0,
|
|
350
|
+
top: 0,
|
|
351
|
+
right: width,
|
|
352
|
+
bottom: height,
|
|
353
|
+
width,
|
|
354
|
+
height,
|
|
355
|
+
centerX: width / 2,
|
|
356
|
+
centerY: height / 2
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
const graphicBounds = computed(() => {
|
|
360
|
+
const box = hitbox();
|
|
361
|
+
const fallback = hitboxBounds();
|
|
362
|
+
const dimensions = imageDimensions();
|
|
363
|
+
const graphics = graphicsSignals();
|
|
364
|
+
let bounds = null;
|
|
365
|
+
graphics.forEach((graphicObject) => {
|
|
366
|
+
const textureOptions = resolveTextureOptions(graphicObject);
|
|
367
|
+
const frame = resolveFirstAnimationFrame(textureOptions);
|
|
368
|
+
const size = resolveFrameSize(textureOptions, dimensions);
|
|
369
|
+
const spriteWidth = size.width ?? box?.w;
|
|
370
|
+
const spriteHeight = size.height ?? box?.h;
|
|
371
|
+
if (!spriteWidth || !spriteHeight) return;
|
|
372
|
+
const anchor = normalizeAnchor(optionValue("anchor", frame, textureOptions, graphicObject)) ?? resolveHitboxAnchor(spriteWidth, spriteHeight, optionValue("spriteRealSize", frame, textureOptions, graphicObject), box);
|
|
373
|
+
const scale = normalizePair(optionValue("scale", frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));
|
|
374
|
+
const x = toFiniteNumber(optionValue("x", frame, textureOptions, graphicObject), 0);
|
|
375
|
+
const y = toFiniteNumber(optionValue("y", frame, textureOptions, graphicObject), 0);
|
|
376
|
+
const leftEdge = -anchor[0] * spriteWidth * scale[0];
|
|
377
|
+
const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];
|
|
378
|
+
const topEdge = -anchor[1] * spriteHeight * scale[1];
|
|
379
|
+
const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];
|
|
380
|
+
const graphic = {
|
|
381
|
+
left: x + Math.min(leftEdge, rightEdge),
|
|
382
|
+
top: y + Math.min(topEdge, bottomEdge),
|
|
383
|
+
right: x + Math.max(leftEdge, rightEdge),
|
|
384
|
+
bottom: y + Math.max(topEdge, bottomEdge)
|
|
385
|
+
};
|
|
386
|
+
bounds = bounds ? {
|
|
387
|
+
left: Math.min(bounds.left, graphic.left),
|
|
388
|
+
top: Math.min(bounds.top, graphic.top),
|
|
389
|
+
right: Math.max(bounds.right, graphic.right),
|
|
390
|
+
bottom: Math.max(bounds.bottom, graphic.bottom)
|
|
391
|
+
} : graphic;
|
|
392
|
+
});
|
|
393
|
+
if (!bounds) return fallback;
|
|
394
|
+
const width = bounds.right - bounds.left;
|
|
395
|
+
const height = bounds.bottom - bounds.top;
|
|
396
|
+
return {
|
|
397
|
+
...bounds,
|
|
398
|
+
width,
|
|
399
|
+
height,
|
|
400
|
+
centerX: bounds.left + width / 2,
|
|
401
|
+
centerY: bounds.top + height / 2
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
const movementAnimations = ["walk", "stand"];
|
|
405
|
+
const epsilon = 0;
|
|
406
|
+
const stateX$ = smoothX.animatedState.observable;
|
|
407
|
+
const stateY$ = smoothY.animatedState.observable;
|
|
408
|
+
const animationName$ = animationName.observable;
|
|
409
|
+
const moving$ = combineLatest([stateX$, stateY$]).pipe(map(([sx, sy]) => {
|
|
410
|
+
const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
|
|
411
|
+
const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
|
|
296
412
|
return !xFinished || !yFinished;
|
|
297
413
|
}), startWith(false));
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
414
|
+
const animationChange$ = animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr));
|
|
415
|
+
let beforeRemovePromise = null;
|
|
416
|
+
let beforeRemoveTransitionValue = null;
|
|
417
|
+
const resolveRemoveContext = () => {
|
|
418
|
+
if (!sprite._removeTransition) return null;
|
|
419
|
+
const value = sprite._removeTransition();
|
|
420
|
+
if (!value || typeof value !== "string") return null;
|
|
421
|
+
try {
|
|
422
|
+
const context = JSON.parse(value);
|
|
423
|
+
if (!context || typeof context !== "object" || !context.active) return null;
|
|
424
|
+
context.__transitionValue = value;
|
|
425
|
+
return context;
|
|
426
|
+
} catch {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const withTimeout = (promise, timeoutMs = 0) => {
|
|
431
|
+
if (!timeoutMs || timeoutMs <= 0) return promise;
|
|
432
|
+
return Promise.race([promise, new Promise((resolve) => setTimeout(resolve, timeoutMs))]);
|
|
433
|
+
};
|
|
434
|
+
const runBeforeRemove = () => {
|
|
435
|
+
const context = resolveRemoveContext();
|
|
436
|
+
if (!context) return Promise.resolve();
|
|
437
|
+
if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
|
|
438
|
+
beforeRemoveTransitionValue = context.__transitionValue;
|
|
439
|
+
beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", sprite, context)), context.timeoutMs);
|
|
440
|
+
return beforeRemovePromise;
|
|
441
|
+
};
|
|
442
|
+
const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {
|
|
443
|
+
if (resolveRemoveContext()) runBeforeRemove();
|
|
444
|
+
});
|
|
445
|
+
const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
|
|
304
446
|
if (curr == "stand" && !isMoving) realAnimationName.set(curr);
|
|
305
447
|
else if (curr == "walk" && isMoving) realAnimationName.set(curr);
|
|
306
448
|
else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
|
|
307
|
-
if (!isMoving &&
|
|
449
|
+
if (!isMoving && sprite.animationIsPlaying && sprite.animationIsPlaying()) {
|
|
308
450
|
if (movementAnimations.includes(curr)) {
|
|
309
|
-
if (typeof
|
|
451
|
+
if (typeof sprite.resetAnimationState === "function") sprite.resetAnimationState();
|
|
310
452
|
}
|
|
311
453
|
}
|
|
312
454
|
});
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
455
|
+
const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
|
|
456
|
+
if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) return Promise.resolve();
|
|
457
|
+
return new Promise((resolve) => {
|
|
458
|
+
let finished = false;
|
|
459
|
+
let timeout;
|
|
460
|
+
let subscription;
|
|
461
|
+
const finish = () => {
|
|
462
|
+
if (finished) return;
|
|
463
|
+
finished = true;
|
|
464
|
+
clearTimeout(timeout);
|
|
465
|
+
subscription?.unsubscribe();
|
|
466
|
+
resolve();
|
|
467
|
+
};
|
|
468
|
+
timeout = setTimeout(finish, maxDuration);
|
|
469
|
+
subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {
|
|
470
|
+
if (!isPlaying) finish();
|
|
329
471
|
});
|
|
472
|
+
if (finished) subscription.unsubscribe();
|
|
330
473
|
});
|
|
331
474
|
};
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
475
|
+
const onBeforeDestroy = async () => {
|
|
476
|
+
await runBeforeRemove();
|
|
477
|
+
await waitForTemporaryAnimationEnd();
|
|
478
|
+
removeTransitionSubscription?.unsubscribe();
|
|
479
|
+
animationMovementSubscription.unsubscribe();
|
|
480
|
+
xSubscription.unsubscribe();
|
|
481
|
+
ySubscription.unsubscribe();
|
|
482
|
+
await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", sprite));
|
|
483
|
+
await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, sprite));
|
|
484
|
+
};
|
|
485
|
+
mount((element) => {
|
|
486
|
+
hooks.callHooks("client-sprite-onAdd", sprite).subscribe();
|
|
487
|
+
hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, sprite).subscribe();
|
|
488
|
+
effect(() => {
|
|
489
|
+
if (isCurrentPlayer()) client.setKeyboardControls(element.directives.controls);
|
|
490
|
+
});
|
|
336
491
|
});
|
|
337
|
-
|
|
492
|
+
const onAttachedGuiFinish = (gui, data) => {
|
|
338
493
|
guiService.guiClose(gui.name, data);
|
|
339
494
|
};
|
|
340
|
-
|
|
495
|
+
const onAttachedGuiInteraction = (gui, name, data) => {
|
|
341
496
|
guiService.guiInteraction(gui.name, name, data);
|
|
342
497
|
};
|
|
343
|
-
tick(
|
|
498
|
+
tick(() => {
|
|
344
499
|
hooks.callHooks("client-sprite-onUpdate").subscribe();
|
|
345
500
|
});
|
|
346
501
|
return h(Container, {
|
|
@@ -353,30 +508,56 @@ function component($$props) {
|
|
|
353
508
|
visible
|
|
354
509
|
}, [
|
|
355
510
|
loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
|
|
356
|
-
object,
|
|
511
|
+
object: sprite,
|
|
357
512
|
...compConfig.props
|
|
358
513
|
}))),
|
|
514
|
+
h(__ce_component$1, {
|
|
515
|
+
object: sprite,
|
|
516
|
+
position: "bottom",
|
|
517
|
+
graphicBounds
|
|
518
|
+
}),
|
|
519
|
+
h(__ce_component$1, {
|
|
520
|
+
object: sprite,
|
|
521
|
+
position: "left",
|
|
522
|
+
graphicBounds
|
|
523
|
+
}),
|
|
359
524
|
h(Particle, {
|
|
360
525
|
emit: emitParticleTrigger,
|
|
361
526
|
settings: particleSettings,
|
|
362
527
|
zIndex: 1e3,
|
|
363
528
|
name: particleName
|
|
364
529
|
}),
|
|
365
|
-
h(Container, null, loop(graphicsSignals, (graphicObj) => h(Sprite, {
|
|
530
|
+
h(Container, null, loop(graphicsSignals, (graphicObj) => h(Container, { scale: computed(() => graphicScale(graphicObj)) }, h(Sprite, {
|
|
366
531
|
sheet: computed(() => sheet(graphicObj)),
|
|
367
532
|
direction,
|
|
368
533
|
tint,
|
|
369
534
|
hitbox,
|
|
535
|
+
shadowCaster: computed(() => shadowCaster(graphicObj)),
|
|
370
536
|
flash: flashConfig
|
|
371
|
-
}))),
|
|
537
|
+
})))),
|
|
538
|
+
h(__ce_component$1, {
|
|
539
|
+
object: sprite,
|
|
540
|
+
position: "center",
|
|
541
|
+
graphicBounds
|
|
542
|
+
}),
|
|
543
|
+
h(__ce_component$1, {
|
|
544
|
+
object: sprite,
|
|
545
|
+
position: "right",
|
|
546
|
+
graphicBounds
|
|
547
|
+
}),
|
|
548
|
+
h(__ce_component$1, {
|
|
549
|
+
object: sprite,
|
|
550
|
+
position: "top",
|
|
551
|
+
graphicBounds
|
|
552
|
+
}),
|
|
372
553
|
loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
|
|
373
|
-
object,
|
|
554
|
+
object: sprite,
|
|
374
555
|
...compConfig.props
|
|
375
556
|
}))),
|
|
376
557
|
loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
|
|
377
558
|
...attachedGui.data(),
|
|
378
559
|
dependencies: attachedGui.dependencies,
|
|
379
|
-
object,
|
|
560
|
+
object: sprite,
|
|
380
561
|
onFinish: (data) => {
|
|
381
562
|
onAttachedGuiFinish(attachedGui, data);
|
|
382
563
|
},
|
|
@@ -386,7 +567,8 @@ function component($$props) {
|
|
|
386
567
|
}))))
|
|
387
568
|
]);
|
|
388
569
|
}
|
|
570
|
+
var __ce_component = component;
|
|
389
571
|
//#endregion
|
|
390
|
-
export {
|
|
572
|
+
export { __ce_component as default };
|
|
391
573
|
|
|
392
574
|
//# sourceMappingURL=character.ce.js.map
|