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