@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.21
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/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/Game/Map.d.ts +7 -1
- package/dist/Gui/Gui.d.ts +170 -5
- package/dist/Resource.d.ts +97 -0
- package/dist/RpgClient.d.ts +259 -59
- package/dist/RpgClientEngine.d.ts +379 -6
- package/dist/Sound.d.ts +199 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/gui/index.d.ts +3 -3
- package/dist/components/index.d.ts +3 -1
- package/dist/components/prebuilt/index.d.ts +18 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/index10.js +149 -4
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +22 -7
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -4
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +11 -14
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +8 -40
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +217 -180
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +104 -7
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +82 -372
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +110 -27
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +360 -18
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +726 -32
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +5 -2416
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +47 -109
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +7 -107
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +394 -65
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +40 -15
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +20 -36
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +2629 -1
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +102 -310
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +63 -17
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +18 -8
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +70 -8
- package/dist/index3.js.map +1 -1
- package/dist/index30.js +24 -8
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +88 -167
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +34 -494
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +22 -10
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +3 -4401
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +20 -1
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +18 -82
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +8 -58
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +4 -13
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +10 -18
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +25 -5
- package/dist/index4.js.map +1 -1
- package/dist/index40.js +7 -0
- package/dist/index40.js.map +1 -0
- package/dist/index41.js +3690 -0
- package/dist/index41.js.map +1 -0
- package/dist/index42.js +187 -0
- package/dist/index42.js.map +1 -0
- package/dist/index43.js +504 -0
- package/dist/index43.js.map +1 -0
- package/dist/index44.js +77 -0
- package/dist/index44.js.map +1 -0
- package/dist/index45.js +6 -0
- package/dist/index45.js.map +1 -0
- package/dist/index46.js +20 -0
- package/dist/index46.js.map +1 -0
- package/dist/index47.js +146 -0
- package/dist/index47.js.map +1 -0
- package/dist/index48.js +12 -0
- package/dist/index48.js.map +1 -0
- package/dist/index49.js +113 -0
- package/dist/index49.js.map +1 -0
- package/dist/index5.js +2 -1
- package/dist/index5.js.map +1 -1
- package/dist/index50.js +136 -0
- package/dist/index50.js.map +1 -0
- package/dist/index51.js +137 -0
- package/dist/index51.js.map +1 -0
- package/dist/index52.js +112 -0
- package/dist/index52.js.map +1 -0
- package/dist/index53.js +141 -0
- package/dist/index53.js.map +1 -0
- package/dist/index54.js +9 -0
- package/dist/index54.js.map +1 -0
- package/dist/index55.js +54 -0
- package/dist/index55.js.map +1 -0
- package/dist/index6.js +1 -1
- package/dist/index6.js.map +1 -1
- package/dist/index7.js +11 -3
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +68 -7
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +278 -15
- package/dist/index9.js.map +1 -1
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/index.d.ts +103 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/services/keyboardControls.d.ts +5 -0
- package/dist/services/loadMap.d.ts +123 -2
- package/dist/services/mmorpg.d.ts +12 -4
- package/dist/services/standalone.d.ts +54 -2
- package/package.json +22 -18
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Map.ts +20 -2
- package/src/Game/Object.ts +163 -9
- package/src/Gui/Gui.ts +362 -17
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +264 -58
- package/src/RpgClientEngine.ts +848 -36
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +193 -36
- package/src/components/dynamics/parse-value.ts +80 -0
- package/src/components/dynamics/text.ce +183 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +73 -35
- package/src/components/gui/dialogbox/selection.ce +16 -1
- package/src/components/gui/index.ts +3 -4
- package/src/components/index.ts +5 -1
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +22 -0
- package/src/components/scenes/canvas.ce +12 -10
- package/src/components/scenes/draw-map.ce +6 -23
- package/src/components/scenes/event-layer.ce +9 -3
- package/src/core/setup.ts +2 -0
- package/src/index.ts +7 -2
- package/src/module.ts +72 -6
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/index.ts +7 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/keyboardControls.ts +8 -0
- package/src/services/loadMap.ts +132 -3
- package/src/services/mmorpg.ts +29 -5
- package/src/services/standalone.ts +70 -6
- package/tsconfig.json +1 -1
- package/vite.config.ts +1 -1
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/src/components/scenes/element-map.ce +0 -23
- /package/src/components/{effects → animations}/hit.ce +0 -0
package/dist/index15.js
CHANGED
|
@@ -1,191 +1,228 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { useProps, useDefineProps, computed, signal, animatedSignal, mount, tick, h, Container, loop, Sprite, cond } from 'canvasengine';
|
|
2
|
+
import { combineLatest, map, startWith, pairwise, filter, lastValueFrom } from 'rxjs';
|
|
3
|
+
import { Particle } from '@canvasengine/presets';
|
|
4
|
+
import { Direction, ModulesToken } from '@rpgjs/common';
|
|
5
|
+
import { RpgClientEngine } from './index2.js';
|
|
6
|
+
import { inject } from './index6.js';
|
|
7
|
+
import { RpgGui } from './index9.js';
|
|
3
8
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
function component($$props) {
|
|
10
|
+
useProps($$props);
|
|
11
|
+
const defineProps = useDefineProps($$props);
|
|
12
|
+
var __assign = (this && this.__assign) || function () {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
34
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
39
|
+
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;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
57
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
};
|
|
59
|
+
var _a = defineProps(), object = _a.object, id = _a.id;
|
|
60
|
+
var client = inject(RpgClientEngine);
|
|
61
|
+
var hooks = inject(ModulesToken);
|
|
62
|
+
var guiService = inject(RpgGui);
|
|
63
|
+
client.spritesheets;
|
|
64
|
+
var playerId = client.playerId;
|
|
65
|
+
var componentsBehind = client.spriteComponentsBehind;
|
|
66
|
+
var componentsInFront = client.spriteComponentsInFront;
|
|
67
|
+
var isMe = computed(function () { return id() === playerId; });
|
|
68
|
+
var attachedGuis = computed(function () {
|
|
69
|
+
return guiService.getAttachedGuis();
|
|
70
|
+
});
|
|
71
|
+
var shouldDisplayAttachedGui = computed(function () {
|
|
72
|
+
return guiService.shouldDisplayAttachedGui(id());
|
|
73
|
+
});
|
|
74
|
+
var x = object.x, y = object.y, tint = object.tint, direction = object.direction, animationName = object.animationName, animationCurrentIndex = object.animationCurrentIndex, emitParticleTrigger = object.emitParticleTrigger, particleName = object.particleName; object.graphics; var hitbox = object.hitbox, isConnected = object.isConnected, graphicsSignals = object.graphicsSignals;
|
|
75
|
+
var particleSettings = client.particleSettings;
|
|
76
|
+
var canControls = function () { return isMe() && object.canMove(); };
|
|
77
|
+
var keyboardControls = client.globalConfig.keyboardControls;
|
|
78
|
+
var visible = computed(function () {
|
|
79
|
+
if (object.type === 'event') {
|
|
80
|
+
return true;
|
|
64
81
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
return isConnected();
|
|
83
|
+
});
|
|
84
|
+
var controls = signal({
|
|
85
|
+
down: {
|
|
86
|
+
repeat: true,
|
|
87
|
+
bind: keyboardControls.down,
|
|
88
|
+
keyDown: function () {
|
|
89
|
+
if (canControls())
|
|
90
|
+
client.processInput({ input: Direction.Down });
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
up: {
|
|
94
|
+
repeat: true,
|
|
95
|
+
bind: keyboardControls.up,
|
|
96
|
+
keyDown: function () {
|
|
97
|
+
if (canControls())
|
|
98
|
+
client.processInput({ input: Direction.Up });
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
left: {
|
|
102
|
+
repeat: true,
|
|
103
|
+
bind: keyboardControls.left,
|
|
104
|
+
keyDown: function () {
|
|
105
|
+
if (canControls())
|
|
106
|
+
client.processInput({ input: Direction.Left });
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
right: {
|
|
110
|
+
repeat: true,
|
|
111
|
+
bind: keyboardControls.right,
|
|
112
|
+
keyDown: function () {
|
|
113
|
+
if (canControls())
|
|
114
|
+
client.processInput({ input: Direction.Right });
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
action: {
|
|
118
|
+
bind: keyboardControls.action,
|
|
119
|
+
keyDown: function () {
|
|
120
|
+
if (canControls()) {
|
|
121
|
+
client.processAction({ action: 'action' });
|
|
122
|
+
// particleName.set('hit')
|
|
123
|
+
// emitParticleTrigger.start()
|
|
124
|
+
// object.flash('red')
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
var smoothX = animatedSignal(x(), {
|
|
130
|
+
duration: isMe() ? 0 : 0
|
|
131
|
+
});
|
|
132
|
+
var smoothY = animatedSignal(y(), {
|
|
133
|
+
duration: isMe() ? 0 : 0,
|
|
134
|
+
});
|
|
135
|
+
var realAnimationName = signal(animationName());
|
|
136
|
+
var xSubscription = x.observable.subscribe(function (value) {
|
|
137
|
+
smoothX.set(value);
|
|
138
|
+
});
|
|
139
|
+
var ySubscription = y.observable.subscribe(function (value) {
|
|
140
|
+
smoothY.set(value);
|
|
141
|
+
});
|
|
142
|
+
var sheet = function (graphicObject) {
|
|
143
|
+
return {
|
|
144
|
+
definition: graphicObject,
|
|
145
|
+
playing: realAnimationName,
|
|
146
|
+
params: {
|
|
147
|
+
direction: direction
|
|
148
|
+
},
|
|
149
|
+
onFinish: function () {
|
|
150
|
+
animationCurrentIndex.update(function (index) { return index + 1; });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
var movementAnimations = ['walk', 'stand'];
|
|
155
|
+
var epsilon = 0;
|
|
156
|
+
var stateX$ = smoothX.animatedState.observable;
|
|
157
|
+
var stateY$ = smoothY.animatedState.observable;
|
|
158
|
+
var animationName$ = animationName.observable;
|
|
159
|
+
var moving$ = combineLatest([stateX$, stateY$]).pipe(map(function (_a) {
|
|
160
|
+
var sx = _a[0], sy = _a[1];
|
|
161
|
+
var xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
|
|
162
|
+
var yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
|
|
163
|
+
return !xFinished || !yFinished; // moving if X or Y is not finished
|
|
164
|
+
}), startWith(false));
|
|
165
|
+
var animationChange$ = animationName$.pipe(startWith(animationName()), pairwise(), filter(function (_a) {
|
|
166
|
+
var prev = _a[0], curr = _a[1];
|
|
167
|
+
return prev !== curr;
|
|
168
|
+
}));
|
|
169
|
+
var animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(function (_a) {
|
|
170
|
+
var _b = _a[0]; _b[0]; var curr = _b[1], isMoving = _a[1];
|
|
171
|
+
if (curr == 'stand' && !isMoving) {
|
|
172
|
+
realAnimationName.set(curr);
|
|
79
173
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
for (const provider of providers) {
|
|
83
|
-
if (Array.isArray(provider)) {
|
|
84
|
-
const found = findProvider(provider, name);
|
|
85
|
-
if (found) return found;
|
|
86
|
-
continue;
|
|
174
|
+
else if (curr == 'walk' && isMoving) {
|
|
175
|
+
realAnimationName.set(curr);
|
|
87
176
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
if (name instanceof RegExp) {
|
|
91
|
-
if (name.test(providerName)) return provider;
|
|
92
|
-
} else {
|
|
93
|
-
if (providerName === name) return provider;
|
|
94
|
-
}
|
|
177
|
+
else if (!movementAnimations.includes(curr)) {
|
|
178
|
+
realAnimationName.set(curr);
|
|
95
179
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// src/merge-config.ts
|
|
102
|
-
function processProvider(mergedConfig, baseConfig, provider) {
|
|
103
|
-
if (Array.isArray(provider)) {
|
|
104
|
-
for (const nestedProvider of provider) {
|
|
105
|
-
processProvider(mergedConfig, baseConfig, nestedProvider);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const existingProvider = findProvider(baseConfig.providers, provider.provide);
|
|
110
|
-
if (existingProvider) {
|
|
111
|
-
mergedConfig.providers = override(mergedConfig.providers, provider);
|
|
112
|
-
} else {
|
|
113
|
-
mergedConfig.providers.push(provider);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
__name(processProvider, "processProvider");
|
|
117
|
-
function mergeConfig(baseConfig, config) {
|
|
118
|
-
const mergedConfig = {
|
|
119
|
-
...baseConfig,
|
|
120
|
-
...config,
|
|
121
|
-
providers: [
|
|
122
|
-
...baseConfig.providers
|
|
123
|
-
]
|
|
124
|
-
// Start with a copy of base providers
|
|
125
|
-
};
|
|
126
|
-
for (const provider of config.providers) {
|
|
127
|
-
processProvider(mergedConfig, baseConfig, provider);
|
|
128
|
-
}
|
|
129
|
-
return mergedConfig;
|
|
130
|
-
}
|
|
131
|
-
__name(mergeConfig, "mergeConfig");
|
|
132
|
-
|
|
133
|
-
// src/provider.ts
|
|
134
|
-
async function injector(context, providers) {
|
|
135
|
-
providers = providers.flat();
|
|
136
|
-
for (const provider of providers) {
|
|
137
|
-
let token;
|
|
138
|
-
let instance;
|
|
139
|
-
if (typeof provider === "function") {
|
|
140
|
-
token = provider;
|
|
141
|
-
instance = new provider(context);
|
|
142
|
-
} else {
|
|
143
|
-
token = provider.provide;
|
|
144
|
-
const provideUserClass = provider.useClass;
|
|
145
|
-
const isClass = typeof provideUserClass === "function";
|
|
146
|
-
if (isClass) {
|
|
147
|
-
instance = new provideUserClass(context);
|
|
148
|
-
} else if ("useValue" in provider) {
|
|
149
|
-
instance = provider.useValue;
|
|
150
|
-
} else if ("useFactory" in provider) {
|
|
151
|
-
instance = provider.useFactory?.(context);
|
|
152
|
-
if (instance instanceof Promise) {
|
|
153
|
-
instance = await instance;
|
|
180
|
+
if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
|
|
181
|
+
if (movementAnimations.includes(curr)) {
|
|
182
|
+
if (typeof object.resetAnimationState === 'function') {
|
|
183
|
+
object.resetAnimationState();
|
|
184
|
+
}
|
|
154
185
|
}
|
|
155
|
-
} else if ("useExisting" in provider) {
|
|
156
|
-
instance = inject(context, provider.useExisting);
|
|
157
|
-
}
|
|
158
186
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*/
|
|
185
|
-
get(key) {
|
|
186
|
-
return this.values[key];
|
|
187
|
-
}
|
|
187
|
+
});
|
|
188
|
+
var onBeforeDestroy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0:
|
|
192
|
+
animationMovementSubscription.unsubscribe();
|
|
193
|
+
xSubscription.unsubscribe();
|
|
194
|
+
ySubscription.unsubscribe();
|
|
195
|
+
return [4 /*yield*/, lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object))];
|
|
196
|
+
case 1:
|
|
197
|
+
_a.sent();
|
|
198
|
+
return [4 /*yield*/, lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object))];
|
|
199
|
+
case 2:
|
|
200
|
+
_a.sent();
|
|
201
|
+
return [2 /*return*/];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}); };
|
|
205
|
+
mount(function (element) {
|
|
206
|
+
hooks.callHooks("client-sprite-onAdd", object).subscribe();
|
|
207
|
+
hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
|
|
208
|
+
client.setKeyboardControls(element.directives.controls);
|
|
209
|
+
});
|
|
210
|
+
var onAttachedGuiFinish = function (gui, data) {
|
|
211
|
+
guiService.guiClose(gui.name, data);
|
|
188
212
|
};
|
|
213
|
+
var onAttachedGuiInteraction = function (gui, name, data) {
|
|
214
|
+
guiService.guiInteraction(gui.name, name, data);
|
|
215
|
+
};
|
|
216
|
+
tick(function () {
|
|
217
|
+
hooks.callHooks("client-sprite-onUpdate").subscribe();
|
|
218
|
+
});
|
|
219
|
+
let $this = h(Container, { x: smoothX, y: smoothY, zIndex: y, viewportFollow: isMe, controls, onBeforeDestroy, visible }, [loop(componentsBehind, component => h(Container, null, h(component, { object }))), h(Particle, { emit: emitParticleTrigger, settings: particleSettings, zIndex: 1000, name: particleName }), h(Container, null, loop(graphicsSignals, graphicObj => h(Sprite, { sheet: sheet(graphicObj), direction, tint, hitbox }))), loop(componentsInFront, component => h(Container, null, h(component, { object }))), loop(attachedGuis, attachedGui => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, { ...attachedGui.data(), object: object, onFinish: (data) => {
|
|
220
|
+
onAttachedGuiFinish(attachedGui, data);
|
|
221
|
+
}, onInteraction: (name, data) => {
|
|
222
|
+
onAttachedGuiInteraction(attachedGui, name, data);
|
|
223
|
+
} }))))]);
|
|
224
|
+
return $this
|
|
225
|
+
}
|
|
189
226
|
|
|
190
|
-
export {
|
|
227
|
+
export { component as default };
|
|
191
228
|
//# sourceMappingURL=index15.js.map
|
package/dist/index15.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index15.js","sources":["../../../node_modules/.pnpm/@signe+di@2.3.3/node_modules/@signe/di/dist/index.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\n\n// src/inject.ts\nfunction provide(context, name, value) {\n context.set(\"inject:\" + name, value);\n return value;\n}\n__name(provide, \"provide\");\nfunction isInjected(context, name) {\n return context.get(\"injected:\" + name) === true;\n}\n__name(isInjected, \"isInjected\");\nfunction isProvided(context, name) {\n return context.get(\"inject:\" + name) !== void 0;\n}\n__name(isProvided, \"isProvided\");\nfunction inject(context, service, args = []) {\n const isClass = typeof service === \"function\";\n const name = isClass ? service.name : service;\n const value = context.get(\"inject:\" + name);\n if (value) {\n context.set(\"injected:\" + name, true);\n return value;\n }\n throw new Error(`Injection provider ${name} not found`);\n}\n__name(inject, \"inject\");\nfunction override(providers, newProvider, options) {\n let { upsert = false, key } = options ?? {};\n if (!key) {\n key = typeof newProvider === \"function\" ? newProvider.name : newProvider.provide;\n }\n const flatProviders = providers.flat();\n const exists = flatProviders.some((provider) => {\n if (typeof provider === \"function\") {\n return provider.name === key;\n } else if (typeof provider === \"object\") {\n return provider.provide === key;\n }\n return false;\n });\n const mappedProviders = flatProviders.map((provider) => {\n if (typeof provider === \"function\" && provider.name === key) {\n return newProvider;\n } else if (typeof provider === \"object\" && provider.provide === key) {\n return newProvider;\n }\n return provider;\n });\n if (upsert && !exists) {\n mappedProviders.push(newProvider);\n }\n return mappedProviders;\n}\n__name(override, \"override\");\nfunction findProviders(providers, name) {\n const results = [];\n for (const provider of providers) {\n if (Array.isArray(provider)) {\n results.push(...findProviders(provider, name));\n } else if (findProvider(provider, name)) {\n results.push(provider);\n }\n }\n return results;\n}\n__name(findProviders, \"findProviders\");\nfunction findProvider(providers, name) {\n if (!Array.isArray(providers)) {\n if (typeof providers === \"object\" && \"provide\" in providers) {\n const provider = providers;\n const providerName = typeof provider.provide === \"function\" ? provider.provide.name : provider.provide;\n if (name instanceof RegExp) {\n if (name.test(providerName)) return providers;\n } else {\n if (providerName === name) return providers;\n }\n }\n return null;\n }\n for (const provider of providers) {\n if (Array.isArray(provider)) {\n const found = findProvider(provider, name);\n if (found) return found;\n continue;\n }\n if (typeof provider === \"object\" && \"provide\" in provider) {\n const providerName = typeof provider.provide === \"function\" ? provider.provide.name : provider.provide;\n if (name instanceof RegExp) {\n if (name.test(providerName)) return provider;\n } else {\n if (providerName === name) return provider;\n }\n }\n }\n return null;\n}\n__name(findProvider, \"findProvider\");\n\n// src/merge-config.ts\nfunction processProvider(mergedConfig, baseConfig, provider) {\n if (Array.isArray(provider)) {\n for (const nestedProvider of provider) {\n processProvider(mergedConfig, baseConfig, nestedProvider);\n }\n return;\n }\n const existingProvider = findProvider(baseConfig.providers, provider.provide);\n if (existingProvider) {\n mergedConfig.providers = override(mergedConfig.providers, provider);\n } else {\n mergedConfig.providers.push(provider);\n }\n}\n__name(processProvider, \"processProvider\");\nfunction mergeConfig(baseConfig, config) {\n const mergedConfig = {\n ...baseConfig,\n ...config,\n providers: [\n ...baseConfig.providers\n ]\n // Start with a copy of base providers\n };\n for (const provider of config.providers) {\n processProvider(mergedConfig, baseConfig, provider);\n }\n return mergedConfig;\n}\n__name(mergeConfig, \"mergeConfig\");\n\n// src/provider.ts\nasync function injector(context, providers) {\n providers = providers.flat();\n for (const provider of providers) {\n let token;\n let instance;\n if (typeof provider === \"function\") {\n token = provider;\n instance = new provider(context);\n } else {\n token = provider.provide;\n const provideUserClass = provider.useClass;\n const isClass = typeof provideUserClass === \"function\";\n if (isClass) {\n instance = new provideUserClass(context);\n } else if (\"useValue\" in provider) {\n instance = provider.useValue;\n } else if (\"useFactory\" in provider) {\n instance = provider.useFactory?.(context);\n if (instance instanceof Promise) {\n instance = await instance;\n }\n } else if (\"useExisting\" in provider) {\n instance = inject(context, provider.useExisting);\n }\n }\n const name = typeof token === \"function\" ? token.name : token;\n provide(context, name, instance);\n }\n}\n__name(injector, \"injector\");\n\n// src/context.ts\nvar Context = class {\n static {\n __name(this, \"Context\");\n }\n /** Internal storage for injected values */\n values = {};\n /**\n * Sets a value in the context\n * @param key - Unique identifier for the value\n * @param value - Value to store\n */\n set(key, value) {\n this.values[key] = value;\n }\n /**\n * Retrieves a value from the context\n * @param key - Unique identifier for the value\n * @returns The stored value or undefined if not found\n */\n get(key) {\n return this.values[key];\n }\n};\nexport {\n Context,\n findProvider,\n findProviders,\n inject,\n injector,\n isInjected,\n isProvided,\n mergeConfig,\n override,\n provide\n};\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc;AACrC,IAAI,MAAM,GAAG,CAAC,MAAM,EAAE,KAAK,KAAK,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;;AAExF;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AACvC,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC;AACtC,EAAE,OAAO,KAAK;AACd;AACA,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;AAC1B,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI;AACjD;AACA,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;AAChC,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,MAAM;AACjD;AACA,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;AAChC,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;AAC7C,EAAE,MAAM,OAAO,GAAG,OAAO,OAAO,KAAK,UAAU;AAC/C,EAAE,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO;AAC/C,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;AAC7C,EAAE,IAAI,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ACpC,OAAO,MAAM,IAAI,YAAY,IAAI,QAAQ,EAAE;AAC3C,QAAQ,QAAQ,GAAG,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC;AACjD,QAAQ,IAAI,QAAQ,YAAY,OAAO,EAAE;AACzC,UAAU,QAAQ,GAAG,MAAM,QAAQ;AACnC;AACA,OAAO,MAAM,IAAI,aAAa,IAAI,QAAQ,EAAE;AAC5C,QAAQ,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC;AACxD;AACA;AACA,IAAI,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,UAAU,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK;AACjE,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC;AACpC;AACA;AACA,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;;AAE5B;AACG,IAAC,OAAO,GAAG,MAAM;AACpB,EAAE;AACF,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC;AAC3B;AACA;AACA,EAAE,MAAM,GAAG,EAAE;AACb;AACA;AACA;AACA;AACA;AACA,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,GAAG,CAAC,GAAG,EAAE;AACX,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAC3B;AACA;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index15.js","sources":["../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={y} viewportFollow={isMe} controls onBeforeDestroy visible>\n @for (component of componentsBehind) {\n <Container>\n <component object />\n </Container>\n } \n <Particle emit={@emitParticleTrigger} settings={@particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Sprite sheet={@sheet(@graphicObj)} direction tint hitbox />\n }\n </Container>\n @for (component of componentsInFront) {\n <Container>\n <component object />\n </Container>\n } \n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() object={object} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal } from \"canvasengine\";\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n\n const { object, id } = defineProps();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals\n } = object;\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const visible = computed(() => {\n if (object.type === 'event') {\n return true\n }\n return isConnected()\n });\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n // particleName.set('hit') \n // emitParticleTrigger.start()\n // object.flash('red')\n }\n },\n },\n });\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName,\n params: {\n direction\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\n });\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const onBeforeDestroy = async () => {\n animationMovementSubscription.unsubscribe();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", object)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, object))\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onAdd\", object).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, object).subscribe()\n client.setKeyboardControls(element.directives.controls)\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>"],"names":[],"mappings":";;;;;;;;AAcqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AAC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E,CAAC,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,KAAK;AAC/rB,UAAU,mBAAmB,CAAC,WAAW,EAAE,IAAI;AAC/C,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK;AAC1C,UAAU,wBAAwB,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI;AAC1D,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChB,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index16.js
CHANGED
|
@@ -1,9 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
class AbstractWebsocket {
|
|
3
|
-
constructor(context) {
|
|
4
|
-
this.context = context;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
import { useProps, useDefineProps, computed, animatedSignal, effect, h, Container, Graphics } from 'canvasengine';
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
function component($$props) {
|
|
4
|
+
useProps($$props);
|
|
5
|
+
const defineProps = useDefineProps($$props);
|
|
6
|
+
var object = defineProps().object;
|
|
7
|
+
var barWidth = 50;
|
|
8
|
+
var barHeight = 8;
|
|
9
|
+
var borderRadius = 4;
|
|
10
|
+
var innerRadius = 3;
|
|
11
|
+
var padding = 1;
|
|
12
|
+
var bgColor = 0x16213e;
|
|
13
|
+
var shadowColor = 0x000000;
|
|
14
|
+
var borderColor = 0x4a5568;
|
|
15
|
+
var maxFillWidth = barWidth - (padding * 2);
|
|
16
|
+
var fillHeight = barHeight - (padding * 2);
|
|
17
|
+
var highlightHeight = Math.floor(fillHeight / 2);
|
|
18
|
+
var hitbox = object.hitbox;
|
|
19
|
+
var currentHp = computed(function () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = object.hpSignal) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : 0;
|
|
22
|
+
});
|
|
23
|
+
var maxHp = computed(function () {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
var params = (_b = (_a = object._param) === null || _a === void 0 ? void 0 : _a.call(object)) !== null && _b !== void 0 ? _b : {};
|
|
26
|
+
return (_c = params.maxHp) !== null && _c !== void 0 ? _c : 100;
|
|
27
|
+
});
|
|
28
|
+
var hpPercent = computed(function () {
|
|
29
|
+
var max = maxHp();
|
|
30
|
+
if (max <= 0)
|
|
31
|
+
return 0;
|
|
32
|
+
var percent = currentHp() / max;
|
|
33
|
+
return Math.max(0, Math.min(1, percent));
|
|
34
|
+
});
|
|
35
|
+
var animatedPercent = animatedSignal(hpPercent(), {
|
|
36
|
+
duration: 300,
|
|
37
|
+
easing: 'easeOutCubic'
|
|
38
|
+
});
|
|
39
|
+
effect(function () {
|
|
40
|
+
var newPercent = hpPercent();
|
|
41
|
+
animatedPercent.set(newPercent);
|
|
42
|
+
});
|
|
43
|
+
var position = computed(function () { return ({
|
|
44
|
+
x: (hitbox().w / 2) - (barWidth / 2),
|
|
45
|
+
y: -barHeight - 8
|
|
46
|
+
}); });
|
|
47
|
+
var fillWidth = computed(function () {
|
|
48
|
+
var percent = animatedPercent();
|
|
49
|
+
var width = maxFillWidth * percent;
|
|
50
|
+
// Ensure minimum visible width when HP > 0
|
|
51
|
+
if (percent > 0 && width < innerRadius * 2) {
|
|
52
|
+
return innerRadius * 2;
|
|
53
|
+
}
|
|
54
|
+
return Math.max(0, width);
|
|
55
|
+
});
|
|
56
|
+
var hpColorHex = computed(function () {
|
|
57
|
+
var percent = hpPercent();
|
|
58
|
+
if (percent > 0.6) {
|
|
59
|
+
return 0x4ade80; // Green - healthy
|
|
60
|
+
}
|
|
61
|
+
else if (percent > 0.3) {
|
|
62
|
+
return 0xfacc15; // Yellow - caution
|
|
63
|
+
}
|
|
64
|
+
else if (percent > 0.15) {
|
|
65
|
+
return 0xfb923c; // Orange - danger
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return 0xef4444; // Red - critical
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var drawShadow = function (g) {
|
|
72
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
73
|
+
g.fill({ color: shadowColor, alpha: 0.3 });
|
|
74
|
+
};
|
|
75
|
+
var drawBackground = function (g) {
|
|
76
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
77
|
+
g.fill({ color: bgColor, alpha: 0.9 });
|
|
78
|
+
};
|
|
79
|
+
var drawFill = function (g) {
|
|
80
|
+
var width = fillWidth();
|
|
81
|
+
if (width > 0) {
|
|
82
|
+
g.roundRect(padding, padding, width, fillHeight, innerRadius);
|
|
83
|
+
g.fill({ color: hpColorHex() });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var drawHighlight = function (g) {
|
|
87
|
+
var width = fillWidth();
|
|
88
|
+
if (width > 0) {
|
|
89
|
+
g.roundRect(padding, padding, width, highlightHeight, innerRadius);
|
|
90
|
+
g.fill({ color: 0xffffff, alpha: 0.25 });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var drawBorder = function (g) {
|
|
94
|
+
g.roundRect(0, 0, barWidth, barHeight, borderRadius);
|
|
95
|
+
g.stroke({
|
|
96
|
+
color: borderColor,
|
|
97
|
+
width: 1,
|
|
98
|
+
alpha: 0.7
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
let $this = [,h(Container, { x: computed(() => position().x), y: computed(() => position().y) }, [h(Graphics, { draw: drawShadow, x: 1, y: 1 }), h(Graphics, { draw: drawBackground }), h(Graphics, { draw: drawFill }), h(Graphics, { draw: drawHighlight }), h(Graphics, { draw: drawBorder })])];
|
|
102
|
+
return $this
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { component as default };
|
|
9
106
|
//# sourceMappingURL=index16.js.map
|
package/dist/index16.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index16.js","sources":["../src/services/AbstractSocket.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\n\nexport const WebSocketToken = \"websocket\";\n\nexport abstract class AbstractWebsocket {\n constructor(protected context: Context) {}\n\n abstract connection(listeners?: (data: any) => void): Promise<void>;\n abstract emit(event: string, data: any): void;\n abstract on(event: string, callback: (data: any) => void): void;\n abstract off(event: string, callback: (data: any) => void): void;\n abstract updateProperties(params: { room: string, host?: string }): void;\n abstract reconnect(listeners?: (data: any) => void): void;\n}\n"],"names":[],"mappings":"AAEO,MAAM,cAAiB,GAAA;AAEvB,MAAe,iBAAkB,CAAA;AAAA,EACtC,YAAsB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAQxB;;;;"}
|
|
1
|
+
{"version":3,"file":"index16.js","sources":["../src/components/prebuilt/hp-bar.ce"],"sourcesContent":["<!-- \n HP Bar Component\n \n A beautiful, animated health bar component for displaying player HP above sprites.\n Features a gradient color based on HP level, smooth animations, and modern styling.\n \n ## Design\n \n The bar changes color dynamically based on HP percentage:\n - Green (#4ade80) when HP > 60% - Healthy state\n - Yellow (#facc15) when HP 30-60% - Caution state \n - Orange (#fb923c) when HP 15-30% - Danger state\n - Red (#ef4444) when HP < 15% - Critical state\n \n @example\n ```ts\n import HpBar from './hp-bar.ce';\n \n // In module configuration\n export default defineModule<RpgClient>({\n sprite: {\n componentsInFront: [HpBar]\n }\n })\n ```\n-->\n\n<Container x={position.@x} y={position.@y}>\n <!-- Background shadow for depth effect -->\n <Graphics draw={drawShadow} x={1} y={1} />\n \n <!-- Main background -->\n <Graphics draw={drawBackground} />\n \n <!-- HP fill bar -->\n <Graphics draw={drawFill} />\n \n <!-- Highlight overlay for 3D effect -->\n <Graphics draw={drawHighlight} />\n \n <!-- Border frame -->\n <Graphics draw={drawBorder} />\n</Container>\n\n<script>\nimport { computed, animatedSignal, effect } from \"canvasengine\";\n\nconst { object } = defineProps();\n\n// ====================\n// Configuration\n// ====================\n\n/** Total width of the HP bar in pixels */\nconst barWidth = 50;\n\n/** Total height of the HP bar in pixels */\nconst barHeight = 8;\n\n/** Border radius for rounded corners */\nconst borderRadius = 4;\n\n/** Inner border radius for the fill bar */\nconst innerRadius = 3;\n\n/** Padding between background and fill */\nconst padding = 1;\n\n/** Background color (dark theme) */\nconst bgColor = 0x16213e;\n\n/** Shadow color */\nconst shadowColor = 0x000000;\n\n/** Border color */\nconst borderColor = 0x4a5568;\n\n// ====================\n// Calculated dimensions\n// ====================\n\n/** Maximum fill width */\nconst maxFillWidth = barWidth - (padding * 2);\n\n/** Fill height */\nconst fillHeight = barHeight - (padding * 2);\n\n/** Highlight height (half of fill) */\nconst highlightHeight = Math.floor(fillHeight / 2);\n\n// ====================\n// Reactive HP values\n// ====================\n\n/** Gets hitbox dimensions for positioning */\nconst hitbox = object.hitbox;\n\n/**\n * Gets the current HP value from the player object\n * Uses hpSignal which is synchronized from the server\n */\nconst currentHp = computed(() => {\n return object.hpSignal?.() ?? 0;\n});\n\n/**\n * Gets the maximum HP value from player parameters\n * Reads from _param.maxHp which contains calculated stats\n */\nconst maxHp = computed(() => {\n const params = object._param?.() ?? {};\n return params.maxHp ?? 100;\n});\n\n/**\n * Calculates HP percentage (0 to 1)\n */\nconst hpPercent = computed(() => {\n const max = maxHp();\n if (max <= 0) return 0;\n const percent = currentHp() / max;\n return Math.max(0, Math.min(1, percent));\n});\n\n// ====================\n// Animated values\n// ====================\n\n/**\n * Animated percentage for smooth bar transitions\n */\nconst animatedPercent = animatedSignal(hpPercent(), {\n duration: 300,\n easing: 'easeOutCubic'\n});\n\n// Update animated value when HP changes\neffect(() => {\n const newPercent = hpPercent();\n animatedPercent.set(newPercent);\n});\n\n// ====================\n// Visual calculations\n// ====================\n\n/**\n * Position of the bar relative to the sprite\n */\nconst position = computed(() => ({\n x: (hitbox().w / 2) - (barWidth / 2),\n y: -barHeight - 8\n}));\n\n/**\n * Current width of the HP fill based on animated percentage\n */\nconst fillWidth = computed(() => {\n const percent = animatedPercent();\n const width = maxFillWidth * percent;\n // Ensure minimum visible width when HP > 0\n if (percent > 0 && width < innerRadius * 2) {\n return innerRadius * 2;\n }\n return Math.max(0, width);\n});\n\n/**\n * Determines HP bar color based on current HP percentage\n * Returns hex color number for PixiJS\n * \n * ## Color Thresholds\n * - Green (0x4ade80): HP > 60% - Healthy\n * - Yellow (0xfacc15): HP 30-60% - Caution\n * - Orange (0xfb923c): HP 15-30% - Danger\n * - Red (0xef4444): HP < 15% - Critical\n */\nconst hpColorHex = computed(() => {\n const percent = hpPercent();\n \n if (percent > 0.6) {\n return 0x4ade80; // Green - healthy\n } else if (percent > 0.3) {\n return 0xfacc15; // Yellow - caution\n } else if (percent > 0.15) {\n return 0xfb923c; // Orange - danger\n } else {\n return 0xef4444; // Red - critical\n }\n});\n\n// ====================\n// Drawing functions\n// ====================\n\n/**\n * Draws the shadow behind the HP bar for depth effect\n */\nconst drawShadow = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: shadowColor, alpha: 0.3 });\n};\n\n/**\n * Draws the main background of the HP bar\n */\nconst drawBackground = (g) => {\n g.roundRect(0, 0, barWidth, barHeight, borderRadius);\n g.fill({ color: bgColor, alpha: 0.9 });\n};\n\n/**\n * Draws the HP fill bar with dynamic color\n */\nconst drawFill = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, fillHeight, innerRadius);\n g.fill({ color: hpColorHex() });\n }\n};\n\n/**\n * Draws the highlight overlay for 3D effect\n */\nconst drawHighlight = (g) => {\n const width = fillWidth();\n if (width > 0) {\n g.roundRect(padding, padding, width, highlightHeight, innerRadius);\n g.fill({ color: 0xffffff, alpha: 0.25 });\n }\n};\n\n/**\n * Draws the border frame around the HP bar\n * \n * Uses PixiJS Graphics API to create a rounded rectangle stroke\n * that serves as a visual border for the bar.\n * \n * @param g - PixiJS Graphics object\n * \n * @example\n * ```html\n * <Graphics draw={drawBorder} />\n * ```\n */\nconst drawBor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