@rpgjs/server 5.0.0-beta.5 → 5.0.0-beta.7
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/Player/Player.d.ts +34 -1
- package/dist/index.js +1584 -914
- package/dist/index.js.map +1 -1
- package/dist/{module-BmvXIvlE.js → module-5HOX9Ovu.js} +520 -935
- package/dist/module-5HOX9Ovu.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +12 -12
- package/src/Player/Player.ts +53 -4
- package/src/rooms/map.ts +21 -15
- package/tests/action-interaction.spec.ts +97 -0
- package/tests/item.spec.ts +72 -1
- package/tests/move.spec.ts +65 -1
- package/tests/world-maps.spec.ts +4 -0
- package/dist/module-BmvXIvlE.js.map +0 -1
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@signe+sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js
|
|
2
|
-
var __defProp$2 = Object.defineProperty;
|
|
3
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", {
|
|
4
|
-
value,
|
|
5
|
-
configurable: true
|
|
6
|
-
});
|
|
7
|
-
//#endregion
|
|
8
1
|
//#region ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
9
2
|
/******************************************************************************
|
|
10
3
|
Copyright (c) Microsoft Corporation.
|
|
@@ -254,7 +247,7 @@ function __asyncValues(o) {
|
|
|
254
247
|
}
|
|
255
248
|
//#endregion
|
|
256
249
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isFunction.js
|
|
257
|
-
function isFunction$
|
|
250
|
+
function isFunction$1(value) {
|
|
258
251
|
return typeof value === "function";
|
|
259
252
|
}
|
|
260
253
|
//#endregion
|
|
@@ -320,7 +313,7 @@ var Subscription = function() {
|
|
|
320
313
|
else _parentage.remove(this);
|
|
321
314
|
}
|
|
322
315
|
var initialFinalizer = this.initialTeardown;
|
|
323
|
-
if (isFunction$
|
|
316
|
+
if (isFunction$1(initialFinalizer)) try {
|
|
324
317
|
initialFinalizer();
|
|
325
318
|
} catch (e) {
|
|
326
319
|
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
@@ -390,10 +383,10 @@ var Subscription = function() {
|
|
|
390
383
|
}();
|
|
391
384
|
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
392
385
|
function isSubscription(value) {
|
|
393
|
-
return value instanceof Subscription || value && "closed" in value && isFunction$
|
|
386
|
+
return value instanceof Subscription || value && "closed" in value && isFunction$1(value.remove) && isFunction$1(value.add) && isFunction$1(value.unsubscribe);
|
|
394
387
|
}
|
|
395
388
|
function execFinalizer(finalizer) {
|
|
396
|
-
if (isFunction$
|
|
389
|
+
if (isFunction$1(finalizer)) finalizer();
|
|
397
390
|
else finalizer.unsubscribe();
|
|
398
391
|
}
|
|
399
392
|
//#endregion
|
|
@@ -575,7 +568,7 @@ var SafeSubscriber = function(_super) {
|
|
|
575
568
|
function SafeSubscriber(observerOrNext, error, complete) {
|
|
576
569
|
var _this = _super.call(this) || this;
|
|
577
570
|
var partialObserver;
|
|
578
|
-
if (isFunction$
|
|
571
|
+
if (isFunction$1(observerOrNext) || !observerOrNext) partialObserver = {
|
|
579
572
|
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : void 0,
|
|
580
573
|
error: error !== null && error !== void 0 ? error : void 0,
|
|
581
574
|
complete: complete !== null && complete !== void 0 ? complete : void 0
|
|
@@ -722,7 +715,7 @@ function getPromiseCtor(promiseCtor) {
|
|
|
722
715
|
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
723
716
|
}
|
|
724
717
|
function isObserver(value) {
|
|
725
|
-
return value && isFunction$
|
|
718
|
+
return value && isFunction$1(value.next) && isFunction$1(value.error) && isFunction$1(value.complete);
|
|
726
719
|
}
|
|
727
720
|
function isSubscriber(value) {
|
|
728
721
|
return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
|
|
@@ -730,7 +723,7 @@ function isSubscriber(value) {
|
|
|
730
723
|
//#endregion
|
|
731
724
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/lift.js
|
|
732
725
|
function hasLift(source) {
|
|
733
|
-
return isFunction$
|
|
726
|
+
return isFunction$1(source === null || source === void 0 ? void 0 : source.lift);
|
|
734
727
|
}
|
|
735
728
|
function operate(init) {
|
|
736
729
|
return function(source) {
|
|
@@ -973,22 +966,6 @@ var BehaviorSubject = function(_super) {
|
|
|
973
966
|
return BehaviorSubject;
|
|
974
967
|
}(Subject);
|
|
975
968
|
//#endregion
|
|
976
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
|
|
977
|
-
function isScheduler(value) {
|
|
978
|
-
return value && isFunction$2(value.schedule);
|
|
979
|
-
}
|
|
980
|
-
//#endregion
|
|
981
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/args.js
|
|
982
|
-
function last(arr) {
|
|
983
|
-
return arr[arr.length - 1];
|
|
984
|
-
}
|
|
985
|
-
function popResultSelector(args) {
|
|
986
|
-
return isFunction$2(last(args)) ? args.pop() : void 0;
|
|
987
|
-
}
|
|
988
|
-
function popScheduler(args) {
|
|
989
|
-
return isScheduler(last(args)) ? args.pop() : void 0;
|
|
990
|
-
}
|
|
991
|
-
//#endregion
|
|
992
969
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
|
|
993
970
|
var isArrayLike = (function(x) {
|
|
994
971
|
return x && typeof x.length === "number" && typeof x !== "function";
|
|
@@ -996,17 +973,17 @@ var isArrayLike = (function(x) {
|
|
|
996
973
|
//#endregion
|
|
997
974
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isPromise.js
|
|
998
975
|
function isPromise(value) {
|
|
999
|
-
return isFunction$
|
|
976
|
+
return isFunction$1(value === null || value === void 0 ? void 0 : value.then);
|
|
1000
977
|
}
|
|
1001
978
|
//#endregion
|
|
1002
979
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
|
|
1003
980
|
function isInteropObservable(input) {
|
|
1004
|
-
return isFunction$
|
|
981
|
+
return isFunction$1(input[observable]);
|
|
1005
982
|
}
|
|
1006
983
|
//#endregion
|
|
1007
984
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
|
|
1008
985
|
function isAsyncIterable(obj) {
|
|
1009
|
-
return Symbol.asyncIterator && isFunction$
|
|
986
|
+
return Symbol.asyncIterator && isFunction$1(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
1010
987
|
}
|
|
1011
988
|
//#endregion
|
|
1012
989
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
|
|
@@ -1023,7 +1000,7 @@ var iterator = getSymbolIterator();
|
|
|
1023
1000
|
//#endregion
|
|
1024
1001
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isIterable.js
|
|
1025
1002
|
function isIterable(input) {
|
|
1026
|
-
return isFunction$
|
|
1003
|
+
return isFunction$1(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
1027
1004
|
}
|
|
1028
1005
|
//#endregion
|
|
1029
1006
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
|
|
@@ -1064,7 +1041,7 @@ function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
|
1064
1041
|
});
|
|
1065
1042
|
}
|
|
1066
1043
|
function isReadableStreamLike(obj) {
|
|
1067
|
-
return isFunction$
|
|
1044
|
+
return isFunction$1(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
1068
1045
|
}
|
|
1069
1046
|
//#endregion
|
|
1070
1047
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
|
|
@@ -1083,7 +1060,7 @@ function innerFrom(input) {
|
|
|
1083
1060
|
function fromInteropObservable(obj) {
|
|
1084
1061
|
return new Observable(function(subscriber) {
|
|
1085
1062
|
var obs = obj[observable]();
|
|
1086
|
-
if (isFunction$
|
|
1063
|
+
if (isFunction$1(obs.subscribe)) return obs.subscribe(subscriber);
|
|
1087
1064
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
1088
1065
|
});
|
|
1089
1066
|
}
|
|
@@ -1128,7 +1105,7 @@ function fromIterable(iterable) {
|
|
|
1128
1105
|
}
|
|
1129
1106
|
function fromAsyncIterable(asyncIterable) {
|
|
1130
1107
|
return new Observable(function(subscriber) {
|
|
1131
|
-
process
|
|
1108
|
+
process(asyncIterable, subscriber).catch(function(err) {
|
|
1132
1109
|
return subscriber.error(err);
|
|
1133
1110
|
});
|
|
1134
1111
|
});
|
|
@@ -1136,7 +1113,7 @@ function fromAsyncIterable(asyncIterable) {
|
|
|
1136
1113
|
function fromReadableStreamLike(readableStream) {
|
|
1137
1114
|
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
1138
1115
|
}
|
|
1139
|
-
function process
|
|
1116
|
+
function process(asyncIterable, subscriber) {
|
|
1140
1117
|
var asyncIterable_1, asyncIterable_1_1;
|
|
1141
1118
|
var e_2, _a;
|
|
1142
1119
|
return __awaiter(this, void 0, void 0, function() {
|
|
@@ -1278,7 +1255,7 @@ function scheduleIterable(input, scheduler) {
|
|
|
1278
1255
|
}, 0, true);
|
|
1279
1256
|
});
|
|
1280
1257
|
return function() {
|
|
1281
|
-
return isFunction$
|
|
1258
|
+
return isFunction$1(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return();
|
|
1282
1259
|
};
|
|
1283
1260
|
});
|
|
1284
1261
|
}
|
|
@@ -1332,99 +1309,6 @@ function map(project, thisArg) {
|
|
|
1332
1309
|
});
|
|
1333
1310
|
}
|
|
1334
1311
|
//#endregion
|
|
1335
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
|
|
1336
|
-
var isArray$2 = Array.isArray;
|
|
1337
|
-
function callOrApply(fn, args) {
|
|
1338
|
-
return isArray$2(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args);
|
|
1339
|
-
}
|
|
1340
|
-
function mapOneOrManyArgs(fn) {
|
|
1341
|
-
return map(function(args) {
|
|
1342
|
-
return callOrApply(fn, args);
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
//#endregion
|
|
1346
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
|
|
1347
|
-
var isArray$1 = Array.isArray;
|
|
1348
|
-
var getPrototypeOf = Object.getPrototypeOf, objectProto = Object.prototype, getKeys = Object.keys;
|
|
1349
|
-
function argsArgArrayOrObject(args) {
|
|
1350
|
-
if (args.length === 1) {
|
|
1351
|
-
var first_1 = args[0];
|
|
1352
|
-
if (isArray$1(first_1)) return {
|
|
1353
|
-
args: first_1,
|
|
1354
|
-
keys: null
|
|
1355
|
-
};
|
|
1356
|
-
if (isPOJO(first_1)) {
|
|
1357
|
-
var keys = getKeys(first_1);
|
|
1358
|
-
return {
|
|
1359
|
-
args: keys.map(function(key) {
|
|
1360
|
-
return first_1[key];
|
|
1361
|
-
}),
|
|
1362
|
-
keys
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
return {
|
|
1367
|
-
args,
|
|
1368
|
-
keys: null
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
function isPOJO(obj) {
|
|
1372
|
-
return obj && typeof obj === "object" && getPrototypeOf(obj) === objectProto;
|
|
1373
|
-
}
|
|
1374
|
-
//#endregion
|
|
1375
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/createObject.js
|
|
1376
|
-
function createObject(keys, values) {
|
|
1377
|
-
return keys.reduce(function(result, key, i) {
|
|
1378
|
-
return result[key] = values[i], result;
|
|
1379
|
-
}, {});
|
|
1380
|
-
}
|
|
1381
|
-
//#endregion
|
|
1382
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js
|
|
1383
|
-
function combineLatest() {
|
|
1384
|
-
var args = [];
|
|
1385
|
-
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
1386
|
-
var scheduler = popScheduler(args);
|
|
1387
|
-
var resultSelector = popResultSelector(args);
|
|
1388
|
-
var _a = argsArgArrayOrObject(args), observables = _a.args, keys = _a.keys;
|
|
1389
|
-
if (observables.length === 0) return from([], scheduler);
|
|
1390
|
-
var result = new Observable(combineLatestInit(observables, scheduler, keys ? function(values) {
|
|
1391
|
-
return createObject(keys, values);
|
|
1392
|
-
} : identity));
|
|
1393
|
-
return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;
|
|
1394
|
-
}
|
|
1395
|
-
function combineLatestInit(observables, scheduler, valueTransform) {
|
|
1396
|
-
if (valueTransform === void 0) valueTransform = identity;
|
|
1397
|
-
return function(subscriber) {
|
|
1398
|
-
maybeSchedule(scheduler, function() {
|
|
1399
|
-
var length = observables.length;
|
|
1400
|
-
var values = new Array(length);
|
|
1401
|
-
var active = length;
|
|
1402
|
-
var remainingFirstValues = length;
|
|
1403
|
-
var _loop_1 = function(i) {
|
|
1404
|
-
maybeSchedule(scheduler, function() {
|
|
1405
|
-
var source = from(observables[i], scheduler);
|
|
1406
|
-
var hasFirstValue = false;
|
|
1407
|
-
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
1408
|
-
values[i] = value;
|
|
1409
|
-
if (!hasFirstValue) {
|
|
1410
|
-
hasFirstValue = true;
|
|
1411
|
-
remainingFirstValues--;
|
|
1412
|
-
}
|
|
1413
|
-
if (!remainingFirstValues) subscriber.next(valueTransform(values.slice()));
|
|
1414
|
-
}, function() {
|
|
1415
|
-
if (!--active) subscriber.complete();
|
|
1416
|
-
}));
|
|
1417
|
-
}, subscriber);
|
|
1418
|
-
};
|
|
1419
|
-
for (var i = 0; i < length; i++) _loop_1(i);
|
|
1420
|
-
}, subscriber);
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
function maybeSchedule(scheduler, execute, subscription) {
|
|
1424
|
-
if (scheduler) executeSchedule(subscription, scheduler, execute);
|
|
1425
|
-
else execute();
|
|
1426
|
-
}
|
|
1427
|
-
//#endregion
|
|
1428
1312
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
|
|
1429
1313
|
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1430
1314
|
var buffer = [];
|
|
@@ -1476,7 +1360,7 @@ function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, e
|
|
|
1476
1360
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
|
|
1477
1361
|
function mergeMap(project, resultSelector, concurrent) {
|
|
1478
1362
|
if (concurrent === void 0) concurrent = Infinity;
|
|
1479
|
-
if (isFunction$
|
|
1363
|
+
if (isFunction$1(resultSelector)) return mergeMap(function(a, i) {
|
|
1480
1364
|
return map(function(b, ii) {
|
|
1481
1365
|
return resultSelector(a, b, i, ii);
|
|
1482
1366
|
})(innerFrom(project(a, i)));
|
|
@@ -1529,17 +1413,6 @@ function toArray() {
|
|
|
1529
1413
|
});
|
|
1530
1414
|
}
|
|
1531
1415
|
//#endregion
|
|
1532
|
-
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/finalize.js
|
|
1533
|
-
function finalize(callback) {
|
|
1534
|
-
return operate(function(source, subscriber) {
|
|
1535
|
-
try {
|
|
1536
|
-
source.subscribe(subscriber);
|
|
1537
|
-
} finally {
|
|
1538
|
-
subscriber.add(callback);
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
//#endregion
|
|
1543
1416
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/share.js
|
|
1544
1417
|
function share(options) {
|
|
1545
1418
|
if (options === void 0) options = {};
|
|
@@ -1614,27 +1487,19 @@ function handleReset(reset, on) {
|
|
|
1614
1487
|
return innerFrom(on.apply(void 0, __spreadArray([], __read(args)))).subscribe(onSubscriber);
|
|
1615
1488
|
}
|
|
1616
1489
|
//#endregion
|
|
1617
|
-
//#region ../../node_modules/.pnpm/@signe+reactive@2.9.
|
|
1618
|
-
var __defProp$1 = Object.defineProperty;
|
|
1619
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", {
|
|
1620
|
-
value,
|
|
1621
|
-
configurable: true
|
|
1622
|
-
});
|
|
1490
|
+
//#region ../../node_modules/.pnpm/@signe+reactive@2.9.2/node_modules/@signe/reactive/dist/index.js
|
|
1623
1491
|
var ArraySubject = class extends BehaviorSubject {
|
|
1624
|
-
static {
|
|
1625
|
-
__name$1(this, "ArraySubject");
|
|
1626
|
-
}
|
|
1627
|
-
_items = [];
|
|
1628
1492
|
constructor(items = []) {
|
|
1629
1493
|
super({
|
|
1630
1494
|
type: "init",
|
|
1631
1495
|
items
|
|
1632
1496
|
});
|
|
1497
|
+
this._items = [];
|
|
1633
1498
|
this.createProxy(items);
|
|
1634
1499
|
}
|
|
1635
1500
|
createProxy(items) {
|
|
1636
1501
|
this._items = new Proxy(items, {
|
|
1637
|
-
get:
|
|
1502
|
+
get: (target, prop, receiver) => {
|
|
1638
1503
|
const origMethod = target[prop];
|
|
1639
1504
|
if (typeof origMethod === "function") return (...args) => {
|
|
1640
1505
|
let changeType = "update";
|
|
@@ -1689,8 +1554,8 @@ var ArraySubject = class extends BehaviorSubject {
|
|
|
1689
1554
|
return result;
|
|
1690
1555
|
};
|
|
1691
1556
|
return Reflect.get(target, prop, receiver);
|
|
1692
|
-
},
|
|
1693
|
-
set:
|
|
1557
|
+
},
|
|
1558
|
+
set: (target, prop, value) => {
|
|
1694
1559
|
const index = !isNaN(Number(prop)) ? Number(prop) : void 0;
|
|
1695
1560
|
target[prop] = value;
|
|
1696
1561
|
this.next({
|
|
@@ -1699,7 +1564,7 @@ var ArraySubject = class extends BehaviorSubject {
|
|
|
1699
1564
|
items: [value]
|
|
1700
1565
|
});
|
|
1701
1566
|
return true;
|
|
1702
|
-
}
|
|
1567
|
+
}
|
|
1703
1568
|
});
|
|
1704
1569
|
}
|
|
1705
1570
|
get items() {
|
|
@@ -1713,14 +1578,10 @@ var ArraySubject = class extends BehaviorSubject {
|
|
|
1713
1578
|
});
|
|
1714
1579
|
}
|
|
1715
1580
|
};
|
|
1716
|
-
var isArraySubject =
|
|
1581
|
+
var isArraySubject = (value) => {
|
|
1717
1582
|
return "_items" in value;
|
|
1718
|
-
}
|
|
1583
|
+
};
|
|
1719
1584
|
var ObjectSubject = class extends BehaviorSubject {
|
|
1720
|
-
static {
|
|
1721
|
-
__name$1(this, "ObjectSubject");
|
|
1722
|
-
}
|
|
1723
|
-
_obj;
|
|
1724
1585
|
constructor(obj = {}) {
|
|
1725
1586
|
super({
|
|
1726
1587
|
type: "init",
|
|
@@ -1730,10 +1591,10 @@ var ObjectSubject = class extends BehaviorSubject {
|
|
|
1730
1591
|
}
|
|
1731
1592
|
createProxy(obj) {
|
|
1732
1593
|
this._obj = new Proxy(obj, {
|
|
1733
|
-
get:
|
|
1594
|
+
get: (target, prop, receiver) => {
|
|
1734
1595
|
return Reflect.get(target, prop, receiver);
|
|
1735
|
-
},
|
|
1736
|
-
set:
|
|
1596
|
+
},
|
|
1597
|
+
set: (target, prop, value, receiver) => {
|
|
1737
1598
|
const key = prop;
|
|
1738
1599
|
const changeType = key in target ? "update" : "add";
|
|
1739
1600
|
target[key] = value;
|
|
@@ -1743,8 +1604,8 @@ var ObjectSubject = class extends BehaviorSubject {
|
|
|
1743
1604
|
value
|
|
1744
1605
|
});
|
|
1745
1606
|
return true;
|
|
1746
|
-
},
|
|
1747
|
-
deleteProperty:
|
|
1607
|
+
},
|
|
1608
|
+
deleteProperty: (target, prop) => {
|
|
1748
1609
|
const key = prop;
|
|
1749
1610
|
if (key in target) {
|
|
1750
1611
|
const value = target[key];
|
|
@@ -1757,7 +1618,7 @@ var ObjectSubject = class extends BehaviorSubject {
|
|
|
1757
1618
|
return true;
|
|
1758
1619
|
}
|
|
1759
1620
|
return false;
|
|
1760
|
-
}
|
|
1621
|
+
}
|
|
1761
1622
|
});
|
|
1762
1623
|
}
|
|
1763
1624
|
get obj() {
|
|
@@ -1771,10 +1632,10 @@ var ObjectSubject = class extends BehaviorSubject {
|
|
|
1771
1632
|
});
|
|
1772
1633
|
}
|
|
1773
1634
|
};
|
|
1774
|
-
var isObjectSubject =
|
|
1635
|
+
var isObjectSubject = (value) => {
|
|
1775
1636
|
return "_obj" in value;
|
|
1776
|
-
}
|
|
1777
|
-
var
|
|
1637
|
+
};
|
|
1638
|
+
var getGlobalReactiveStore = () => {
|
|
1778
1639
|
const globalKey = "__REACTIVE_STORE__";
|
|
1779
1640
|
if (typeof globalThis !== "undefined") {
|
|
1780
1641
|
if (!globalThis[globalKey]) globalThis[globalKey] = {
|
|
@@ -1785,8 +1646,8 @@ var reactiveStore = (/* @__PURE__ */ __name$1(() => {
|
|
|
1785
1646
|
}
|
|
1786
1647
|
let globalObj;
|
|
1787
1648
|
if (typeof window !== "undefined") globalObj = window;
|
|
1788
|
-
else if (typeof process !== "undefined" && process.versions && process.versions.node) globalObj = Function("return this")();
|
|
1789
1649
|
else if (typeof self !== "undefined") globalObj = self;
|
|
1650
|
+
else if (typeof Function !== "undefined") globalObj = Function("return this")();
|
|
1790
1651
|
else {
|
|
1791
1652
|
console.warn("Unable to find global object, using local instance");
|
|
1792
1653
|
return {
|
|
@@ -1799,24 +1660,25 @@ var reactiveStore = (/* @__PURE__ */ __name$1(() => {
|
|
|
1799
1660
|
currentSubscriptionsTracker: null
|
|
1800
1661
|
};
|
|
1801
1662
|
return globalObj[globalKey];
|
|
1802
|
-
}
|
|
1803
|
-
var
|
|
1663
|
+
};
|
|
1664
|
+
var reactiveStore = getGlobalReactiveStore();
|
|
1665
|
+
var trackDependency = (signal2) => {
|
|
1804
1666
|
if (reactiveStore.currentDependencyTracker) reactiveStore.currentDependencyTracker(signal2);
|
|
1805
|
-
}
|
|
1667
|
+
};
|
|
1806
1668
|
function signal(defaultValue, options) {
|
|
1807
1669
|
let subject;
|
|
1808
1670
|
if (Array.isArray(defaultValue)) subject = new ArraySubject(defaultValue);
|
|
1809
1671
|
else if (typeof defaultValue === "object" && defaultValue !== null) subject = new ObjectSubject(defaultValue);
|
|
1810
1672
|
else subject = new BehaviorSubject(defaultValue);
|
|
1811
|
-
const getValue =
|
|
1673
|
+
const getValue = () => {
|
|
1812
1674
|
if (subject instanceof ArraySubject) return subject.items;
|
|
1813
1675
|
else if (subject instanceof ObjectSubject) return subject.obj;
|
|
1814
1676
|
return subject.value;
|
|
1815
|
-
}
|
|
1816
|
-
const fn =
|
|
1677
|
+
};
|
|
1678
|
+
const fn = function() {
|
|
1817
1679
|
trackDependency(fn);
|
|
1818
1680
|
return getValue();
|
|
1819
|
-
}
|
|
1681
|
+
};
|
|
1820
1682
|
fn.set = (value) => {
|
|
1821
1683
|
const currentValue = getValue();
|
|
1822
1684
|
let shouldEmit = true;
|
|
@@ -1853,333 +1715,36 @@ function signal(defaultValue, options) {
|
|
|
1853
1715
|
fn._subject = subject;
|
|
1854
1716
|
return fn;
|
|
1855
1717
|
}
|
|
1856
|
-
__name$1(signal, "signal");
|
|
1857
1718
|
function isSignal(value) {
|
|
1858
1719
|
return !!(value && value.observable);
|
|
1859
1720
|
}
|
|
1860
|
-
__name$1(isSignal, "isSignal");
|
|
1861
1721
|
function isComputed(value) {
|
|
1862
1722
|
return isSignal(value) && !!value.dependencies;
|
|
1863
1723
|
}
|
|
1864
|
-
__name$1(isComputed, "isComputed");
|
|
1865
|
-
function computed(computeFunction, disposableFn) {
|
|
1866
|
-
const dependencies = /* @__PURE__ */ new Set();
|
|
1867
|
-
let init = true;
|
|
1868
|
-
let lastComputedValue;
|
|
1869
|
-
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
1870
|
-
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
1871
|
-
dependencies.add(signal2);
|
|
1872
|
-
};
|
|
1873
|
-
lastComputedValue = computeFunction();
|
|
1874
|
-
if (computeFunction["isEffect"]) disposableFn = lastComputedValue;
|
|
1875
|
-
reactiveStore.currentDependencyTracker = previousTracker;
|
|
1876
|
-
const computedObservable = combineLatest([...dependencies].map((dep) => {
|
|
1877
|
-
if (isComputed(dep) && "dependencies" in dep) {
|
|
1878
|
-
const computedDep = dep;
|
|
1879
|
-
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
1880
|
-
}
|
|
1881
|
-
return dep.observable;
|
|
1882
|
-
})).pipe(filter(() => !init), map(() => computeFunction()), finalize(() => disposableFn?.()));
|
|
1883
|
-
const fn = /* @__PURE__ */ __name$1(function() {
|
|
1884
|
-
trackDependency(fn);
|
|
1885
|
-
return lastComputedValue;
|
|
1886
|
-
}, "fn");
|
|
1887
|
-
fn.observable = computedObservable;
|
|
1888
|
-
fn.subscription = computedObservable.subscribe((value) => {
|
|
1889
|
-
lastComputedValue = value;
|
|
1890
|
-
});
|
|
1891
|
-
fn.dependencies = dependencies;
|
|
1892
|
-
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
1893
|
-
init = false;
|
|
1894
|
-
return fn;
|
|
1895
|
-
}
|
|
1896
|
-
__name$1(computed, "computed");
|
|
1897
|
-
function linkedSignal(computationOrOptions, simpleOptions) {
|
|
1898
|
-
const dependencies = /* @__PURE__ */ new Set();
|
|
1899
|
-
let init = true;
|
|
1900
|
-
let lastComputedValue;
|
|
1901
|
-
let computeFunction;
|
|
1902
|
-
let sourceSignal;
|
|
1903
|
-
let computationFn;
|
|
1904
|
-
let equalFn;
|
|
1905
|
-
let previousValue;
|
|
1906
|
-
let isOverridden = false;
|
|
1907
|
-
let overriddenValue;
|
|
1908
|
-
let depVersion = 0;
|
|
1909
|
-
let overrideDepVersion = null;
|
|
1910
|
-
if (typeof computationOrOptions === "function") {
|
|
1911
|
-
computeFunction = computationOrOptions;
|
|
1912
|
-
equalFn = simpleOptions?.equal;
|
|
1913
|
-
} else {
|
|
1914
|
-
const options = computationOrOptions;
|
|
1915
|
-
sourceSignal = options.source;
|
|
1916
|
-
computationFn = options.computation;
|
|
1917
|
-
equalFn = options.equal;
|
|
1918
|
-
if (typeof sourceSignal === "function" && !isSignal(sourceSignal)) {
|
|
1919
|
-
const sourceFn = sourceSignal;
|
|
1920
|
-
computeFunction = /* @__PURE__ */ __name$1(() => {
|
|
1921
|
-
const sourceValue = sourceFn();
|
|
1922
|
-
if (computationFn.length > 1) {
|
|
1923
|
-
const result = computationFn(sourceValue, previousValue);
|
|
1924
|
-
previousValue = {
|
|
1925
|
-
source: sourceValue,
|
|
1926
|
-
value: result
|
|
1927
|
-
};
|
|
1928
|
-
return result;
|
|
1929
|
-
} else {
|
|
1930
|
-
const result = computationFn(sourceValue);
|
|
1931
|
-
previousValue = {
|
|
1932
|
-
source: sourceValue,
|
|
1933
|
-
value: result
|
|
1934
|
-
};
|
|
1935
|
-
return result;
|
|
1936
|
-
}
|
|
1937
|
-
}, "computeFunction");
|
|
1938
|
-
} else {
|
|
1939
|
-
const source = typeof sourceSignal === "function" ? sourceSignal : sourceSignal;
|
|
1940
|
-
computeFunction = /* @__PURE__ */ __name$1(() => {
|
|
1941
|
-
const sourceValue = source();
|
|
1942
|
-
if (computationFn.length > 1) {
|
|
1943
|
-
const result = computationFn(sourceValue, previousValue);
|
|
1944
|
-
previousValue = {
|
|
1945
|
-
source: sourceValue,
|
|
1946
|
-
value: result
|
|
1947
|
-
};
|
|
1948
|
-
return result;
|
|
1949
|
-
} else {
|
|
1950
|
-
const result = computationFn(sourceValue);
|
|
1951
|
-
previousValue = {
|
|
1952
|
-
source: sourceValue,
|
|
1953
|
-
value: result
|
|
1954
|
-
};
|
|
1955
|
-
return result;
|
|
1956
|
-
}
|
|
1957
|
-
}, "computeFunction");
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
1961
|
-
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
1962
|
-
dependencies.add(signal2);
|
|
1963
|
-
};
|
|
1964
|
-
if (sourceSignal && typeof sourceSignal === "function" && !isSignal(sourceSignal)) lastComputedValue = computeFunction();
|
|
1965
|
-
else if (sourceSignal && isSignal(sourceSignal)) {
|
|
1966
|
-
dependencies.add(sourceSignal);
|
|
1967
|
-
lastComputedValue = computeFunction();
|
|
1968
|
-
} else lastComputedValue = computeFunction();
|
|
1969
|
-
reactiveStore.currentDependencyTracker = previousTracker;
|
|
1970
|
-
const subject = new BehaviorSubject(lastComputedValue);
|
|
1971
|
-
const observables = [...dependencies].map((dep) => {
|
|
1972
|
-
if (isComputed(dep) && "dependencies" in dep) {
|
|
1973
|
-
const computedDep = dep;
|
|
1974
|
-
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
1975
|
-
}
|
|
1976
|
-
return dep.observable;
|
|
1977
|
-
});
|
|
1978
|
-
let linkedObservable;
|
|
1979
|
-
if (observables.length > 0) linkedObservable = combineLatest(observables).pipe(filter(() => !init), map(() => {
|
|
1980
|
-
const computed2 = computeFunction();
|
|
1981
|
-
if (equalFn) {
|
|
1982
|
-
if (!equalFn(lastComputedValue, computed2)) {
|
|
1983
|
-
lastComputedValue = computed2;
|
|
1984
|
-
isOverridden = false;
|
|
1985
|
-
}
|
|
1986
|
-
} else if (lastComputedValue !== computed2) {
|
|
1987
|
-
lastComputedValue = computed2;
|
|
1988
|
-
isOverridden = false;
|
|
1989
|
-
}
|
|
1990
|
-
return lastComputedValue;
|
|
1991
|
-
}));
|
|
1992
|
-
else linkedObservable = subject.asObservable().pipe(filter(() => !init));
|
|
1993
|
-
const fn = /* @__PURE__ */ __name$1(function() {
|
|
1994
|
-
trackDependency(fn);
|
|
1995
|
-
if (isOverridden && dependencies.size > 0) {
|
|
1996
|
-
if (overrideDepVersion !== depVersion) {
|
|
1997
|
-
const computed2 = computeFunction();
|
|
1998
|
-
isOverridden = false;
|
|
1999
|
-
overriddenValue = void 0;
|
|
2000
|
-
lastComputedValue = computed2;
|
|
2001
|
-
overrideDepVersion = null;
|
|
2002
|
-
return computed2;
|
|
2003
|
-
}
|
|
2004
|
-
return overriddenValue;
|
|
2005
|
-
}
|
|
2006
|
-
if (isOverridden) return overriddenValue;
|
|
2007
|
-
if (dependencies.size === 0) lastComputedValue = computeFunction();
|
|
2008
|
-
return lastComputedValue;
|
|
2009
|
-
}, "fn");
|
|
2010
|
-
fn.observable = new Observable((observer) => {
|
|
2011
|
-
const depSubscription = linkedObservable.subscribe((value) => {
|
|
2012
|
-
if (dependencies.size > 0) {
|
|
2013
|
-
depVersion++;
|
|
2014
|
-
isOverridden = false;
|
|
2015
|
-
overrideDepVersion = null;
|
|
2016
|
-
lastComputedValue = value;
|
|
2017
|
-
} else lastComputedValue = value;
|
|
2018
|
-
observer.next(value);
|
|
2019
|
-
});
|
|
2020
|
-
let subjectSubscription;
|
|
2021
|
-
if (dependencies.size === 0) subjectSubscription = subject.pipe(filter(() => !init)).subscribe((value) => {
|
|
2022
|
-
observer.next(value);
|
|
2023
|
-
});
|
|
2024
|
-
observer.next(lastComputedValue);
|
|
2025
|
-
return () => {
|
|
2026
|
-
depSubscription.unsubscribe();
|
|
2027
|
-
if (subjectSubscription) subjectSubscription.unsubscribe();
|
|
2028
|
-
};
|
|
2029
|
-
});
|
|
2030
|
-
fn.subscription = fn.observable.subscribe(() => {});
|
|
2031
|
-
fn.dependencies = dependencies;
|
|
2032
|
-
fn._subject = subject;
|
|
2033
|
-
fn.set = (value) => {
|
|
2034
|
-
if (!isOverridden) {
|
|
2035
|
-
overrideDepVersion = depVersion;
|
|
2036
|
-
if (computationFn && sourceSignal) previousValue = {
|
|
2037
|
-
source: untracked(() => {
|
|
2038
|
-
if (typeof sourceSignal === "function") {
|
|
2039
|
-
const source = sourceSignal;
|
|
2040
|
-
return isSignal(source) ? source() : sourceSignal();
|
|
2041
|
-
}
|
|
2042
|
-
return sourceSignal();
|
|
2043
|
-
}),
|
|
2044
|
-
value
|
|
2045
|
-
};
|
|
2046
|
-
}
|
|
2047
|
-
isOverridden = true;
|
|
2048
|
-
overriddenValue = value;
|
|
2049
|
-
lastComputedValue = value;
|
|
2050
|
-
subject.next(value);
|
|
2051
|
-
};
|
|
2052
|
-
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
2053
|
-
init = false;
|
|
2054
|
-
return fn;
|
|
2055
|
-
}
|
|
2056
|
-
__name$1(linkedSignal, "linkedSignal");
|
|
2057
|
-
function untracked(fn) {
|
|
2058
|
-
const prevDepTracker = reactiveStore.currentDependencyTracker;
|
|
2059
|
-
const prevSubTracker = reactiveStore.currentSubscriptionsTracker;
|
|
2060
|
-
reactiveStore.currentDependencyTracker = null;
|
|
2061
|
-
reactiveStore.currentSubscriptionsTracker = null;
|
|
2062
|
-
try {
|
|
2063
|
-
return fn();
|
|
2064
|
-
} finally {
|
|
2065
|
-
reactiveStore.currentDependencyTracker = prevDepTracker;
|
|
2066
|
-
reactiveStore.currentSubscriptionsTracker = prevSubTracker;
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
__name$1(untracked, "untracked");
|
|
2070
|
-
function effect(fn) {
|
|
2071
|
-
fn["isEffect"] = true;
|
|
2072
|
-
return computed(fn);
|
|
2073
|
-
}
|
|
2074
|
-
__name$1(effect, "effect");
|
|
2075
1724
|
//#endregion
|
|
2076
|
-
//#region ../../node_modules/.pnpm/@signe+sync@2.9.
|
|
2077
|
-
|
|
2078
|
-
return {}.toString.call(val) === "[object Function]";
|
|
2079
|
-
}
|
|
2080
|
-
__name$2(isFunction$1, "isFunction");
|
|
2081
|
-
function isClass(obj) {
|
|
2082
|
-
return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
|
|
2083
|
-
}
|
|
2084
|
-
__name$2(isClass, "isClass");
|
|
2085
|
-
var isObject = /* @__PURE__ */ __name$2((item) => item && typeof item === "object" && !Array.isArray(item) && item !== null, "isObject");
|
|
1725
|
+
//#region ../../node_modules/.pnpm/@signe+sync@2.9.4/node_modules/@signe/sync/dist/index.js
|
|
1726
|
+
var isObject = (item) => item && typeof item === "object" && !Array.isArray(item) && item !== null;
|
|
2086
1727
|
function isInstanceOfClass(value) {
|
|
2087
1728
|
if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) return false;
|
|
2088
1729
|
return Object.getPrototypeOf(value) !== Object.prototype;
|
|
2089
1730
|
}
|
|
2090
|
-
__name$2(isInstanceOfClass, "isInstanceOfClass");
|
|
2091
1731
|
function generateShortUUID() {
|
|
2092
1732
|
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1733
|
+
const randomBytes = typeof globalThis.crypto?.getRandomValues === "function" ? globalThis.crypto.getRandomValues(new Uint8Array(8)) : null;
|
|
2093
1734
|
let uuid = "";
|
|
2094
1735
|
for (let i = 0; i < 8; i++) {
|
|
2095
|
-
const
|
|
2096
|
-
uuid += chars[
|
|
1736
|
+
const randomValue = randomBytes?.[i] ?? Math.floor(Math.random() * 256);
|
|
1737
|
+
uuid += chars[randomValue % 62];
|
|
2097
1738
|
}
|
|
2098
1739
|
return uuid;
|
|
2099
1740
|
}
|
|
2100
|
-
__name$2(generateShortUUID, "generateShortUUID");
|
|
2101
1741
|
var DELETE_TOKEN = "$delete";
|
|
2102
|
-
var syncClass = /* @__PURE__ */ __name$2((instance, options = {}) => {
|
|
2103
|
-
const cacheSync = /* @__PURE__ */ new Map();
|
|
2104
|
-
const cachePersist = /* @__PURE__ */ new Map();
|
|
2105
|
-
instance.$valuesChanges = {
|
|
2106
|
-
set: /* @__PURE__ */ __name$2((path, value) => {
|
|
2107
|
-
cacheSync.set(path, value);
|
|
2108
|
-
options.onSync?.(cacheSync);
|
|
2109
|
-
}, "set"),
|
|
2110
|
-
setPersist: /* @__PURE__ */ __name$2((path, value) => {
|
|
2111
|
-
if (path == "") path = ".";
|
|
2112
|
-
cachePersist.set(path, value);
|
|
2113
|
-
options.onPersist?.(cachePersist);
|
|
2114
|
-
}, "setPersist"),
|
|
2115
|
-
has: /* @__PURE__ */ __name$2((path) => {
|
|
2116
|
-
return cacheSync.has(path);
|
|
2117
|
-
}, "has"),
|
|
2118
|
-
get: /* @__PURE__ */ __name$2((path) => {
|
|
2119
|
-
return cacheSync.get(path);
|
|
2120
|
-
}, "get")
|
|
2121
|
-
};
|
|
2122
|
-
createSyncClass(instance);
|
|
2123
|
-
}, "syncClass");
|
|
2124
|
-
function createStatesSnapshot(instance) {
|
|
2125
|
-
let persistObject = {};
|
|
2126
|
-
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
2127
|
-
const signal = instance.$snapshot.get(key);
|
|
2128
|
-
const persist2 = signal.options.persist ?? true;
|
|
2129
|
-
let value = signal();
|
|
2130
|
-
if (isObject(value) || Array.isArray(value)) continue;
|
|
2131
|
-
if (persist2) persistObject[key] = value;
|
|
2132
|
-
}
|
|
2133
|
-
return persistObject;
|
|
2134
|
-
}
|
|
2135
|
-
__name$2(createStatesSnapshot, "createStatesSnapshot");
|
|
2136
|
-
var SNAPSHOT_SKIP = Symbol("snapshot-skip");
|
|
2137
|
-
var serializeSnapshotDeep = /* @__PURE__ */ __name$2((value, path, options, seen) => {
|
|
2138
|
-
if (isSignal(value)) return serializeSnapshotDeep(value(), path, options, seen);
|
|
2139
|
-
if (value instanceof Map) return SNAPSHOT_SKIP;
|
|
2140
|
-
if (options.filter && !options.filter(value, path)) return SNAPSHOT_SKIP;
|
|
2141
|
-
if (value instanceof Date) return options.dateToString ? options.dateToString(value) : value.toISOString();
|
|
2142
|
-
if (value && typeof value === "object") {
|
|
2143
|
-
if (seen.has(value)) return SNAPSHOT_SKIP;
|
|
2144
|
-
seen.add(value);
|
|
2145
|
-
if (Array.isArray(value)) {
|
|
2146
|
-
const result2 = [];
|
|
2147
|
-
value.forEach((item, index) => {
|
|
2148
|
-
const serialized = serializeSnapshotDeep(item, path ? `${path}.${index}` : String(index), options, seen);
|
|
2149
|
-
if (serialized !== SNAPSHOT_SKIP) result2.push(serialized);
|
|
2150
|
-
});
|
|
2151
|
-
return result2;
|
|
2152
|
-
}
|
|
2153
|
-
const result = {};
|
|
2154
|
-
const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get("id") : void 0;
|
|
2155
|
-
const entries = Object.entries(value).filter(([key]) => isInstanceOfClass(value) ? key.startsWith("__") || (idKey ? key === idKey : false) : true);
|
|
2156
|
-
for (const [key, childValue] of entries) {
|
|
2157
|
-
const normalizedKey = key.startsWith("__") ? key.slice(2) : key;
|
|
2158
|
-
const serialized = serializeSnapshotDeep(childValue, path ? `${path}.${normalizedKey}` : normalizedKey, options, seen);
|
|
2159
|
-
if (serialized !== SNAPSHOT_SKIP) result[normalizedKey] = serialized;
|
|
2160
|
-
}
|
|
2161
|
-
return result;
|
|
2162
|
-
}
|
|
2163
|
-
return value;
|
|
2164
|
-
}, "serializeSnapshotDeep");
|
|
2165
|
-
function createStatesSnapshotDeep(instance, options = {}) {
|
|
2166
|
-
const persistObject = {};
|
|
2167
|
-
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
2168
|
-
const signal = instance.$snapshot.get(key);
|
|
2169
|
-
if (!(signal.options.persist ?? true)) continue;
|
|
2170
|
-
const serialized = serializeSnapshotDeep(signal(), key, options, /* @__PURE__ */ new WeakSet());
|
|
2171
|
-
if (serialized !== SNAPSHOT_SKIP) persistObject[key] = serialized;
|
|
2172
|
-
}
|
|
2173
|
-
return persistObject;
|
|
2174
|
-
}
|
|
2175
|
-
__name$2(createStatesSnapshotDeep, "createStatesSnapshotDeep");
|
|
2176
1742
|
function setMetadata(target, key, value) {
|
|
2177
1743
|
const propId = target.constructor._propertyMetadata?.get(key);
|
|
2178
1744
|
if (propId) if (isSignal(target[propId])) target[propId].set(value);
|
|
2179
1745
|
else target[propId] = value;
|
|
2180
1746
|
}
|
|
2181
|
-
|
|
2182
|
-
var createSyncClass = /* @__PURE__ */ __name$2((currentClass, parentKey = null, parentClass = null, path = "") => {
|
|
1747
|
+
var createSyncClass = (currentClass, parentKey = null, parentClass = null, path = "") => {
|
|
2183
1748
|
currentClass.$path = path;
|
|
2184
1749
|
if (parentClass) currentClass.$valuesChanges = parentClass.$valuesChanges;
|
|
2185
1750
|
if (parentKey) setMetadata(currentClass, "id", parentKey);
|
|
@@ -2204,11 +1769,11 @@ var createSyncClass = /* @__PURE__ */ __name$2((currentClass, parentKey = null,
|
|
|
2204
1769
|
}
|
|
2205
1770
|
});
|
|
2206
1771
|
}
|
|
2207
|
-
}
|
|
2208
|
-
var type =
|
|
1772
|
+
};
|
|
1773
|
+
var type = (_signal, path, options = {}, currentInstance) => {
|
|
2209
1774
|
const { syncToClient = true, persist: persist2 = true, transform } = options;
|
|
2210
1775
|
let init = true;
|
|
2211
|
-
const handleObjectSubject =
|
|
1776
|
+
const handleObjectSubject = (value, propPath) => {
|
|
2212
1777
|
const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
|
|
2213
1778
|
if ([
|
|
2214
1779
|
"add",
|
|
@@ -2218,8 +1783,8 @@ var type = /* @__PURE__ */ __name$2((_signal, path, options = {}, currentInstanc
|
|
|
2218
1783
|
else if (value.type === "update" && (isObject(value.value) || Array.isArray(value.value))) createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
2219
1784
|
else savePath(newPath, value.value);
|
|
2220
1785
|
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
2221
|
-
}
|
|
2222
|
-
const handleArraySubject =
|
|
1786
|
+
};
|
|
1787
|
+
const handleArraySubject = (value, propPath) => {
|
|
2223
1788
|
if (value.type === "reset" && Array.isArray(value.items)) {
|
|
2224
1789
|
value.items.forEach((item, index) => {
|
|
2225
1790
|
const newPath2 = `${propPath}.${index}`;
|
|
@@ -2234,13 +1799,13 @@ var type = /* @__PURE__ */ __name$2((_signal, path, options = {}, currentInstanc
|
|
|
2234
1799
|
else if (value.type === "update" && (isObject(firstItem) || Array.isArray(firstItem))) createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
2235
1800
|
else savePath(newPath, firstItem);
|
|
2236
1801
|
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
2237
|
-
}
|
|
2238
|
-
const savePath =
|
|
1802
|
+
};
|
|
1803
|
+
const savePath = (propPath, value) => {
|
|
2239
1804
|
const transformedValue = transform && value !== "$delete" ? transform(value) : value;
|
|
2240
1805
|
if (syncToClient) currentInstance.$valuesChanges.set(propPath, transformedValue);
|
|
2241
1806
|
if (persist2 && currentInstance.$path !== void 0) currentInstance.$valuesChanges.setPersist(transformedValue == "$delete" ? propPath : currentInstance.$path, transformedValue);
|
|
2242
|
-
}
|
|
2243
|
-
const setupSubscription =
|
|
1807
|
+
};
|
|
1808
|
+
const setupSubscription = (signal, signalPath) => {
|
|
2244
1809
|
if (!isSignal(signal)) return;
|
|
2245
1810
|
if (syncToClient && currentInstance.$valuesChanges) {
|
|
2246
1811
|
const initialValue = signal();
|
|
@@ -2260,7 +1825,7 @@ var type = /* @__PURE__ */ __name$2((_signal, path, options = {}, currentInstanc
|
|
|
2260
1825
|
});
|
|
2261
1826
|
if (!currentInstance.$snapshot) currentInstance.$snapshot = /* @__PURE__ */ new Map();
|
|
2262
1827
|
currentInstance.$snapshot.set(path, signal);
|
|
2263
|
-
}
|
|
1828
|
+
};
|
|
2264
1829
|
if (!isSignal(_signal)) {
|
|
2265
1830
|
if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
|
|
2266
1831
|
for (const key in _signal) if (Object.prototype.hasOwnProperty.call(_signal, key)) {
|
|
@@ -2276,7 +1841,7 @@ var type = /* @__PURE__ */ __name$2((_signal, path, options = {}, currentInstanc
|
|
|
2276
1841
|
setupSubscription(_signal, path);
|
|
2277
1842
|
init = false;
|
|
2278
1843
|
return _signal;
|
|
2279
|
-
}
|
|
1844
|
+
};
|
|
2280
1845
|
function sync(options) {
|
|
2281
1846
|
let classType;
|
|
2282
1847
|
let persist2 = true;
|
|
@@ -2291,46 +1856,31 @@ function sync(options) {
|
|
|
2291
1856
|
}
|
|
2292
1857
|
return function(target, propertyKey) {
|
|
2293
1858
|
const privatePropertyKey = `__${propertyKey}`;
|
|
1859
|
+
const getter = function() {
|
|
1860
|
+
return this[privatePropertyKey];
|
|
1861
|
+
};
|
|
1862
|
+
const setter = function(newVal) {
|
|
1863
|
+
this[privatePropertyKey] = type(newVal, propertyKey, {
|
|
1864
|
+
classType,
|
|
1865
|
+
persist: persist2,
|
|
1866
|
+
syncToClient,
|
|
1867
|
+
transform
|
|
1868
|
+
}, this);
|
|
1869
|
+
};
|
|
2294
1870
|
Object.defineProperty(target, propertyKey, {
|
|
2295
|
-
get:
|
|
2296
|
-
|
|
2297
|
-
}, "getter"),
|
|
2298
|
-
set: /* @__PURE__ */ __name$2(function(newVal) {
|
|
2299
|
-
this[privatePropertyKey] = type(newVal, propertyKey, {
|
|
2300
|
-
classType,
|
|
2301
|
-
persist: persist2,
|
|
2302
|
-
syncToClient,
|
|
2303
|
-
transform
|
|
2304
|
-
}, this);
|
|
2305
|
-
}, "setter"),
|
|
1871
|
+
get: getter,
|
|
1872
|
+
set: setter,
|
|
2306
1873
|
enumerable: true,
|
|
2307
1874
|
configurable: true
|
|
2308
1875
|
});
|
|
2309
1876
|
};
|
|
2310
1877
|
}
|
|
2311
|
-
__name$2(sync, "sync");
|
|
2312
1878
|
function id() {
|
|
2313
1879
|
return function(target, propertyKey) {
|
|
2314
1880
|
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
2315
1881
|
target.constructor._propertyMetadata.set("id", propertyKey);
|
|
2316
1882
|
};
|
|
2317
1883
|
}
|
|
2318
|
-
__name$2(id, "id");
|
|
2319
|
-
function users(options) {
|
|
2320
|
-
return function(target, propertyKey) {
|
|
2321
|
-
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
2322
|
-
target.constructor._propertyMetadata.set("users", propertyKey);
|
|
2323
|
-
sync(options)(target, propertyKey);
|
|
2324
|
-
};
|
|
2325
|
-
}
|
|
2326
|
-
__name$2(users, "users");
|
|
2327
|
-
function persist() {
|
|
2328
|
-
return sync({
|
|
2329
|
-
persist: true,
|
|
2330
|
-
syncToClient: false
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
__name$2(persist, "persist");
|
|
2334
1884
|
function connected() {
|
|
2335
1885
|
return function(target, propertyKey) {
|
|
2336
1886
|
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
@@ -2338,67 +1888,13 @@ function connected() {
|
|
|
2338
1888
|
sync({ persist: false })(target, propertyKey);
|
|
2339
1889
|
};
|
|
2340
1890
|
}
|
|
2341
|
-
__name$2(connected, "connected");
|
|
2342
|
-
function load(rootInstance, values, valueIsObject) {
|
|
2343
|
-
if (valueIsObject) loadFromObject(rootInstance, values);
|
|
2344
|
-
else loadFromPaths(rootInstance, values);
|
|
2345
|
-
}
|
|
2346
|
-
__name$2(load, "load");
|
|
2347
|
-
function loadFromPaths(rootInstance, values) {
|
|
2348
|
-
for (const [path, value] of Object.entries(values)) loadValue(rootInstance, path.split("."), value);
|
|
2349
|
-
}
|
|
2350
|
-
__name$2(loadFromPaths, "loadFromPaths");
|
|
2351
|
-
function loadFromObject(rootInstance, values, currentPath = "") {
|
|
2352
|
-
for (let key in values) {
|
|
2353
|
-
const value = values[key];
|
|
2354
|
-
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
|
2355
|
-
if (typeof value === "object" && !Array.isArray(value) && value !== null) loadFromObject(rootInstance, value, newPath);
|
|
2356
|
-
else loadValue(rootInstance, newPath.split("."), value);
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
__name$2(loadFromObject, "loadFromObject");
|
|
2360
|
-
function loadValue(rootInstance, parts, value) {
|
|
2361
|
-
let current = rootInstance;
|
|
2362
|
-
for (let i = 0; i < parts.length; i++) {
|
|
2363
|
-
const part = parts[i];
|
|
2364
|
-
if (i === parts.length - 1) if (value == "$delete") {
|
|
2365
|
-
if (isSignal(current)) current = current();
|
|
2366
|
-
Reflect.deleteProperty(current, part);
|
|
2367
|
-
} else if (current[part]?._subject) current[part].set(value);
|
|
2368
|
-
else if (isSignal(current) && Array.isArray(current()) && !isNaN(Number(part))) current()[Number(part)] = value;
|
|
2369
|
-
else current[part] = value;
|
|
2370
|
-
else {
|
|
2371
|
-
if (isSignal(current)) current = current();
|
|
2372
|
-
if (current[part] === void 0) {
|
|
2373
|
-
const classType = getByPath(rootInstance, parts.slice(0, i).join("."))?.options?.classType;
|
|
2374
|
-
if (classType) {
|
|
2375
|
-
current[part] = !isClass(classType) ? classType(part) : new classType();
|
|
2376
|
-
setMetadata(current[part], "id", part);
|
|
2377
|
-
} else current[part] = {};
|
|
2378
|
-
}
|
|
2379
|
-
current = current[part];
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
__name$2(loadValue, "loadValue");
|
|
2384
|
-
function getByPath(root, path) {
|
|
2385
|
-
const parts = path.split(".");
|
|
2386
|
-
let current = root;
|
|
2387
|
-
for (const part of parts) {
|
|
2388
|
-
if (isSignal(current)) current = current();
|
|
2389
|
-
if (current[part]) current = current[part];
|
|
2390
|
-
else return;
|
|
2391
|
-
}
|
|
2392
|
-
return current;
|
|
2393
|
-
}
|
|
2394
|
-
__name$2(getByPath, "getByPath");
|
|
2395
1891
|
//#endregion
|
|
2396
|
-
//#region \0@oxc-project+runtime@0.
|
|
1892
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/decorateMetadata.js
|
|
2397
1893
|
function __decorateMetadata(k, v) {
|
|
2398
1894
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2399
1895
|
}
|
|
2400
1896
|
//#endregion
|
|
2401
|
-
//#region \0@oxc-project+runtime@0.
|
|
1897
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/decorate.js
|
|
2402
1898
|
function __decorate(decorators, target, key, desc) {
|
|
2403
1899
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2404
1900
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2461,6 +1957,24 @@ __decorate([sync(), __decorateMetadata("design:type", Object)], Skill.prototype,
|
|
|
2461
1957
|
__decorate([sync(), __decorateMetadata("design:type", Object)], Skill.prototype, "icon", void 0);
|
|
2462
1958
|
//#endregion
|
|
2463
1959
|
//#region ../common/src/Player.ts
|
|
1960
|
+
var readReactiveValue = (value) => {
|
|
1961
|
+
if (typeof value === "function" && value.observable) return value();
|
|
1962
|
+
return value;
|
|
1963
|
+
};
|
|
1964
|
+
var toCloneableSyncValue = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
1965
|
+
const resolved = readReactiveValue(value);
|
|
1966
|
+
if (resolved == null || typeof resolved !== "object") return typeof resolved === "function" ? void 0 : resolved;
|
|
1967
|
+
if (seen.has(resolved)) return;
|
|
1968
|
+
seen.add(resolved);
|
|
1969
|
+
if (Array.isArray(resolved)) return resolved.map((item) => toCloneableSyncValue(item, seen)).filter((item) => item !== void 0);
|
|
1970
|
+
const output = {};
|
|
1971
|
+
for (const [key, child] of Object.entries(resolved)) {
|
|
1972
|
+
if (key.startsWith("$") || key === "_itemInstance" || key === "_subject" || key === "observable" || key === "options") continue;
|
|
1973
|
+
const childValue = toCloneableSyncValue(child, seen);
|
|
1974
|
+
if (childValue !== void 0) output[key.startsWith("__") ? key.slice(2) : key] = childValue;
|
|
1975
|
+
}
|
|
1976
|
+
return output;
|
|
1977
|
+
};
|
|
2464
1978
|
var Direction = /* @__PURE__ */ function(Direction) {
|
|
2465
1979
|
Direction["Up"] = "up";
|
|
2466
1980
|
Direction["Down"] = "down";
|
|
@@ -2506,6 +2020,7 @@ var RpgCommonPlayer = class {
|
|
|
2506
2020
|
this.componentsCenter = signal(null);
|
|
2507
2021
|
this.componentsLeft = signal(null);
|
|
2508
2022
|
this.componentsRight = signal(null);
|
|
2023
|
+
this._removeTransition = signal("");
|
|
2509
2024
|
this.isConnected = signal(false);
|
|
2510
2025
|
this._intendedDirection = null;
|
|
2511
2026
|
this._directionFixed = signal(false);
|
|
@@ -2644,8 +2159,11 @@ __decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.
|
|
|
2644
2159
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "_exp", void 0);
|
|
2645
2160
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "_level", void 0);
|
|
2646
2161
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "_class", void 0);
|
|
2647
|
-
__decorate([sync(
|
|
2648
|
-
|
|
2162
|
+
__decorate([sync({
|
|
2163
|
+
classType: Item,
|
|
2164
|
+
transform: toCloneableSyncValue
|
|
2165
|
+
}), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "items", void 0);
|
|
2166
|
+
__decorate([sync({ transform: toCloneableSyncValue }), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "equipments", void 0);
|
|
2649
2167
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "states", void 0);
|
|
2650
2168
|
__decorate([sync(Skill), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "skills", void 0);
|
|
2651
2169
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "_effects", void 0);
|
|
@@ -2659,6 +2177,7 @@ __decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.
|
|
|
2659
2177
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "componentsCenter", void 0);
|
|
2660
2178
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "componentsLeft", void 0);
|
|
2661
2179
|
__decorate([sync(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "componentsRight", void 0);
|
|
2180
|
+
__decorate([sync({ persist: false }), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "_removeTransition", void 0);
|
|
2662
2181
|
__decorate([connected(), __decorateMetadata("design:type", Object)], RpgCommonPlayer.prototype, "isConnected", void 0);
|
|
2663
2182
|
//#endregion
|
|
2664
2183
|
//#region ../common/src/Shape.ts
|
|
@@ -4766,6 +4285,18 @@ var CapsuleCollider = class CapsuleCollider {
|
|
|
4766
4285
|
}
|
|
4767
4286
|
};
|
|
4768
4287
|
//#endregion
|
|
4288
|
+
//#region ../physic/src/collision/collider-cache.ts
|
|
4289
|
+
var colliderCache = /* @__PURE__ */ new WeakMap();
|
|
4290
|
+
function getCachedCollider(entity) {
|
|
4291
|
+
return colliderCache.get(entity);
|
|
4292
|
+
}
|
|
4293
|
+
function setCachedCollider(entity, collider) {
|
|
4294
|
+
colliderCache.set(entity, collider);
|
|
4295
|
+
}
|
|
4296
|
+
function invalidateCollider(entity) {
|
|
4297
|
+
colliderCache.delete(entity);
|
|
4298
|
+
}
|
|
4299
|
+
//#endregion
|
|
4769
4300
|
//#region ../physic/src/collision/PolygonCollider.ts
|
|
4770
4301
|
/**
|
|
4771
4302
|
* Weak registry to attach polygon configurations to entities
|
|
@@ -4785,6 +4316,7 @@ var entityToPolygonConfig = /* @__PURE__ */ new WeakMap();
|
|
|
4785
4316
|
*/
|
|
4786
4317
|
function assignPolygonCollider(entity, config) {
|
|
4787
4318
|
entityToPolygonConfig.set(entity, config);
|
|
4319
|
+
invalidateCollider(entity);
|
|
4788
4320
|
}
|
|
4789
4321
|
/**
|
|
4790
4322
|
* Polygon collider implementation (convex via SAT; concave via convex parts)
|
|
@@ -5090,7 +4622,6 @@ function polygonCentroid(poly) {
|
|
|
5090
4622
|
}
|
|
5091
4623
|
//#endregion
|
|
5092
4624
|
//#region ../physic/src/collision/detector.ts
|
|
5093
|
-
var colliderCache = /* @__PURE__ */ new WeakMap();
|
|
5094
4625
|
/**
|
|
5095
4626
|
* Collision detector
|
|
5096
4627
|
*
|
|
@@ -5104,14 +4635,14 @@ var colliderCache = /* @__PURE__ */ new WeakMap();
|
|
|
5104
4635
|
* @returns Appropriate collider instance
|
|
5105
4636
|
*/
|
|
5106
4637
|
function createCollider(entity) {
|
|
5107
|
-
const cached =
|
|
4638
|
+
const cached = getCachedCollider(entity);
|
|
5108
4639
|
if (cached) return cached;
|
|
5109
4640
|
let collider = null;
|
|
5110
4641
|
if (entityToPolygonConfig.has(entity)) collider = new PolygonCollider(entity);
|
|
5111
4642
|
else if (entity.capsule) collider = new CapsuleCollider(entity);
|
|
5112
4643
|
else if (entity.radius > 0) collider = new CircleCollider(entity);
|
|
5113
4644
|
else if (entity.width > 0 && entity.height > 0) collider = new AABBCollider(entity);
|
|
5114
|
-
if (collider)
|
|
4645
|
+
if (collider) setCachedCollider(entity, collider);
|
|
5115
4646
|
return collider;
|
|
5116
4647
|
}
|
|
5117
4648
|
/**
|
|
@@ -5127,7 +4658,24 @@ function testCollision(entityA, entityB) {
|
|
|
5127
4658
|
const colliderA = createCollider(entityA);
|
|
5128
4659
|
const colliderB = createCollider(entityB);
|
|
5129
4660
|
if (!colliderA || !colliderB) return null;
|
|
5130
|
-
|
|
4661
|
+
const directCollision = colliderA.testCollision(colliderB);
|
|
4662
|
+
if (directCollision) return directCollision;
|
|
4663
|
+
const reverseCollision = colliderB.testCollision(colliderA);
|
|
4664
|
+
if (!reverseCollision) return null;
|
|
4665
|
+
return reverseCollisionInfo(reverseCollision);
|
|
4666
|
+
}
|
|
4667
|
+
function reverseCollisionInfo(collision) {
|
|
4668
|
+
return {
|
|
4669
|
+
entityA: collision.entityB,
|
|
4670
|
+
entityB: collision.entityA,
|
|
4671
|
+
contacts: collision.contacts.map((contact) => ({
|
|
4672
|
+
point: contact.point,
|
|
4673
|
+
normal: contact.normal.mul(-1),
|
|
4674
|
+
depth: contact.depth
|
|
4675
|
+
})),
|
|
4676
|
+
normal: collision.normal.mul(-1),
|
|
4677
|
+
depth: collision.depth
|
|
4678
|
+
};
|
|
5131
4679
|
}
|
|
5132
4680
|
//#endregion
|
|
5133
4681
|
//#region ../physic/src/collision/spatial-hash.ts
|
|
@@ -5476,148 +5024,6 @@ var Ray = class {
|
|
|
5476
5024
|
}
|
|
5477
5025
|
};
|
|
5478
5026
|
//#endregion
|
|
5479
|
-
//#region ../physic/src/collision/raycast.ts
|
|
5480
|
-
/**
|
|
5481
|
-
* Casts a ray in the world using the spatial partition for broad-phase, then shape-specific narrow-phase.
|
|
5482
|
-
* Direction will be normalized internally.
|
|
5483
|
-
*
|
|
5484
|
-
* @param partition - Spatial partition to query
|
|
5485
|
-
* @param origin - Ray origin
|
|
5486
|
-
* @param direction - Ray direction (any length)
|
|
5487
|
-
* @param maxDistance - Maximum distance
|
|
5488
|
-
* @param mask - Optional collision mask (layer)
|
|
5489
|
-
* @param filter - Optional filter function (return true to include entity)
|
|
5490
|
-
* @returns Nearest hit or null
|
|
5491
|
-
*
|
|
5492
|
-
* @example
|
|
5493
|
-
* ```typescript
|
|
5494
|
-
* const hit = raycast(worldPartition, new Vector2(0,0), new Vector2(1,0), 1000);
|
|
5495
|
-
* if (hit) {
|
|
5496
|
-
* // handle
|
|
5497
|
-
* }
|
|
5498
|
-
* ```
|
|
5499
|
-
*/
|
|
5500
|
-
function raycast(partition, origin, direction, maxDistance, mask, filter) {
|
|
5501
|
-
const dir = direction.length() > 0 ? direction.normalize() : new Vector2(1, 0);
|
|
5502
|
-
const end = origin.add(dir.mul(maxDistance));
|
|
5503
|
-
const candidates = partition.raycast(new Ray(origin, dir, maxDistance), mask, filter);
|
|
5504
|
-
if (candidates) return candidates;
|
|
5505
|
-
const bounds = new AABB(Math.min(origin.x, end.x), Math.min(origin.y, end.y), Math.max(origin.x, end.x), Math.max(origin.y, end.y));
|
|
5506
|
-
const entities = partition.queryAABB(bounds);
|
|
5507
|
-
let best = null;
|
|
5508
|
-
for (const e of entities) {
|
|
5509
|
-
if (mask !== void 0 && (e.collisionCategory & mask) === 0) continue;
|
|
5510
|
-
if (filter && !filter(e)) continue;
|
|
5511
|
-
const collider = createCollider(e);
|
|
5512
|
-
if (!collider) continue;
|
|
5513
|
-
const hit = raycastCollider(collider, origin, dir, maxDistance);
|
|
5514
|
-
if (!hit) continue;
|
|
5515
|
-
if (!best || hit.distance < best.distance) best = hit;
|
|
5516
|
-
}
|
|
5517
|
-
return best;
|
|
5518
|
-
}
|
|
5519
|
-
function raycastCollider(collider, origin, dir, maxDistance) {
|
|
5520
|
-
if (collider instanceof CircleCollider) return raycastCircle(collider, origin, dir, maxDistance);
|
|
5521
|
-
if (collider instanceof AABBCollider) return raycastAABB(collider, origin, dir, maxDistance);
|
|
5522
|
-
if (collider instanceof PolygonCollider) return raycastPolygon(collider, origin, dir, maxDistance);
|
|
5523
|
-
return null;
|
|
5524
|
-
}
|
|
5525
|
-
function raycastCircle(circle, origin, dir, maxDistance) {
|
|
5526
|
-
const c = circle.getCenter();
|
|
5527
|
-
const r = circle.getRadius();
|
|
5528
|
-
const m = origin.sub(c);
|
|
5529
|
-
const b = m.dot(dir);
|
|
5530
|
-
const cval = m.dot(m) - r * r;
|
|
5531
|
-
if (cval > 0 && b > 0) return null;
|
|
5532
|
-
const discr = b * b - cval;
|
|
5533
|
-
if (discr < 0) return null;
|
|
5534
|
-
const t = -b - Math.sqrt(discr);
|
|
5535
|
-
if (t < 0) return null;
|
|
5536
|
-
if (t > maxDistance) return null;
|
|
5537
|
-
const point = origin.add(dir.mul(t));
|
|
5538
|
-
const normal = point.sub(c).normalize();
|
|
5539
|
-
return {
|
|
5540
|
-
entity: circle.getEntity(),
|
|
5541
|
-
point,
|
|
5542
|
-
normal,
|
|
5543
|
-
distance: t
|
|
5544
|
-
};
|
|
5545
|
-
}
|
|
5546
|
-
function raycastAABB(box, origin, dir, maxDistance) {
|
|
5547
|
-
const b = box.getBounds();
|
|
5548
|
-
let tmin = 0;
|
|
5549
|
-
let tmax = maxDistance;
|
|
5550
|
-
const invDx = 1 / (dir.x === 0 ? 1e-9 : dir.x);
|
|
5551
|
-
const invDy = 1 / (dir.y === 0 ? 1e-9 : dir.y);
|
|
5552
|
-
let tx1 = (b.minX - origin.x) * invDx;
|
|
5553
|
-
let tx2 = (b.maxX - origin.x) * invDx;
|
|
5554
|
-
let ty1 = (b.minY - origin.y) * invDy;
|
|
5555
|
-
let ty2 = (b.maxY - origin.y) * invDy;
|
|
5556
|
-
const tminX = Math.min(tx1, tx2);
|
|
5557
|
-
const tmaxX = Math.max(tx1, tx2);
|
|
5558
|
-
const tminY = Math.min(ty1, ty2);
|
|
5559
|
-
const tmaxY = Math.max(ty1, ty2);
|
|
5560
|
-
tmin = Math.max(tmin, Math.max(tminX, tminY));
|
|
5561
|
-
tmax = Math.min(tmax, Math.min(tmaxX, tmaxY));
|
|
5562
|
-
if (tmax < tmin || tmin < 0 || tmin > maxDistance) return null;
|
|
5563
|
-
const point = origin.add(dir.mul(tmin));
|
|
5564
|
-
let normal;
|
|
5565
|
-
if (tmin === tminX) normal = new Vector2(dir.x > 0 ? -1 : 1, 0);
|
|
5566
|
-
else normal = new Vector2(0, dir.y > 0 ? -1 : 1);
|
|
5567
|
-
return {
|
|
5568
|
-
entity: box.getEntity(),
|
|
5569
|
-
point,
|
|
5570
|
-
normal,
|
|
5571
|
-
distance: tmin
|
|
5572
|
-
};
|
|
5573
|
-
}
|
|
5574
|
-
function raycastPolygon(poly, origin, dir, maxDistance) {
|
|
5575
|
-
const end = origin.add(dir.mul(maxDistance));
|
|
5576
|
-
let bestT = Number.POSITIVE_INFINITY;
|
|
5577
|
-
let bestPoint = null;
|
|
5578
|
-
let bestNormal = null;
|
|
5579
|
-
const any = poly;
|
|
5580
|
-
const parts = any["getWorldParts"] ? any["getWorldParts"]() : [];
|
|
5581
|
-
for (const part of parts) for (let i = 0; i < part.length; i++) {
|
|
5582
|
-
const a = part[i];
|
|
5583
|
-
const b = part[(i + 1) % part.length];
|
|
5584
|
-
if (!a || !b) continue;
|
|
5585
|
-
const hit = segmentRayIntersection(a, b, origin, end);
|
|
5586
|
-
if (!hit) continue;
|
|
5587
|
-
const t = hit.distance;
|
|
5588
|
-
if (t >= 0 && t <= maxDistance && t < bestT) {
|
|
5589
|
-
bestT = t;
|
|
5590
|
-
bestPoint = hit.point;
|
|
5591
|
-
const edge = b.sub(a);
|
|
5592
|
-
bestNormal = new Vector2(-edge.y, edge.x).normalize();
|
|
5593
|
-
}
|
|
5594
|
-
}
|
|
5595
|
-
if (!bestPoint || !bestNormal || bestT === Number.POSITIVE_INFINITY) return null;
|
|
5596
|
-
return {
|
|
5597
|
-
entity: poly.getEntity(),
|
|
5598
|
-
point: bestPoint,
|
|
5599
|
-
normal: bestNormal,
|
|
5600
|
-
distance: bestT
|
|
5601
|
-
};
|
|
5602
|
-
}
|
|
5603
|
-
function segmentRayIntersection(a, b, r0, r1) {
|
|
5604
|
-
const v1 = r0.sub(a);
|
|
5605
|
-
const v2 = b.sub(a);
|
|
5606
|
-
const v3 = new Vector2(-(r1.y - r0.y), r1.x - r0.x);
|
|
5607
|
-
const denom = v2.dot(v3);
|
|
5608
|
-
if (Math.abs(denom) < 1e-9) return null;
|
|
5609
|
-
const t1 = v2.cross(v1) / denom;
|
|
5610
|
-
const t2 = v1.dot(v3) / denom;
|
|
5611
|
-
if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
|
|
5612
|
-
const hitPoint = new Vector2(r0.x + (r1.x - r0.x) * t1, r0.y + (r1.y - r0.y) * t1);
|
|
5613
|
-
return {
|
|
5614
|
-
point: hitPoint,
|
|
5615
|
-
distance: hitPoint.sub(r0).length()
|
|
5616
|
-
};
|
|
5617
|
-
}
|
|
5618
|
-
return null;
|
|
5619
|
-
}
|
|
5620
|
-
//#endregion
|
|
5621
5027
|
//#region ../physic/src/collision/resolver.ts
|
|
5622
5028
|
/**
|
|
5623
5029
|
* Collision resolver
|
|
@@ -6077,13 +5483,41 @@ var World = class {
|
|
|
6077
5483
|
*/
|
|
6078
5484
|
addEntity(entity) {
|
|
6079
5485
|
this.entities.add(entity);
|
|
6080
|
-
|
|
6081
|
-
else this.dynamicEntities.add(entity);
|
|
5486
|
+
this.syncEntityCollection(entity);
|
|
6082
5487
|
this.spatialPartition.insert(entity);
|
|
6083
5488
|
this.events.emitEntityAdded(entity);
|
|
6084
5489
|
return entity;
|
|
6085
5490
|
}
|
|
6086
5491
|
/**
|
|
5492
|
+
* Synchronizes an entity with the world's broad-phase structures.
|
|
5493
|
+
*
|
|
5494
|
+
* Call this after manually changing an entity position, dimensions, or state
|
|
5495
|
+
* outside the normal physics step.
|
|
5496
|
+
*
|
|
5497
|
+
* @param entity - Entity to synchronize
|
|
5498
|
+
*/
|
|
5499
|
+
updateEntity(entity) {
|
|
5500
|
+
if (!this.entities.has(entity)) return;
|
|
5501
|
+
invalidateCollider(entity);
|
|
5502
|
+
this.syncEntity(entity);
|
|
5503
|
+
}
|
|
5504
|
+
syncEntity(entity) {
|
|
5505
|
+
this.syncEntityCollection(entity);
|
|
5506
|
+
this.spatialPartition.update(entity);
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* Queries entities in an AABB region.
|
|
5510
|
+
*
|
|
5511
|
+
* The returned array comes from the broad-phase partition and may contain
|
|
5512
|
+
* false positives from overlapping cells.
|
|
5513
|
+
*
|
|
5514
|
+
* @param bounds - AABB to query
|
|
5515
|
+
* @returns Array of entities in overlapping partition cells
|
|
5516
|
+
*/
|
|
5517
|
+
queryAABB(bounds) {
|
|
5518
|
+
return Array.from(this.spatialPartition.queryAABB(bounds));
|
|
5519
|
+
}
|
|
5520
|
+
/**
|
|
6087
5521
|
* Performs a raycast against all entities in the world.
|
|
6088
5522
|
*
|
|
6089
5523
|
* @param origin - Starting point of the ray
|
|
@@ -6143,13 +5577,14 @@ var World = class {
|
|
|
6143
5577
|
* Updates all entities, detects and resolves collisions.
|
|
6144
5578
|
*/
|
|
6145
5579
|
step() {
|
|
6146
|
-
this.
|
|
5580
|
+
this.refreshEntitiesInPartition();
|
|
6147
5581
|
for (const entity of this.dynamicEntities) if (!entity.isSleeping()) {
|
|
6148
5582
|
const startPos = entity.position.clone();
|
|
6149
5583
|
this.integrator.integrate(entity);
|
|
6150
5584
|
this.updateEntityTile(entity, startPos);
|
|
6151
5585
|
if (entity.continuous) this.performCCD(entity);
|
|
6152
5586
|
}
|
|
5587
|
+
this.refreshDynamicEntitiesInPartition();
|
|
6153
5588
|
let firstPassCollisions = [];
|
|
6154
5589
|
for (let iteration = 0; iteration < this.resolverIterations; iteration++) {
|
|
6155
5590
|
const collisions = this.detectCollisions();
|
|
@@ -6157,9 +5592,12 @@ var World = class {
|
|
|
6157
5592
|
if (collisions.length === 0) break;
|
|
6158
5593
|
this.sortCollisionsForDeterminism(collisions);
|
|
6159
5594
|
this.resolver.resolveAll(collisions);
|
|
6160
|
-
|
|
5595
|
+
this.refreshDynamicEntitiesInPartition();
|
|
5596
|
+
}
|
|
5597
|
+
if (this.positionQuantizationStep !== null || this.velocityQuantizationStep !== null) {
|
|
5598
|
+
this.quantizeEntities();
|
|
5599
|
+
this.refreshDynamicEntitiesInPartition();
|
|
6161
5600
|
}
|
|
6162
|
-
if (this.positionQuantizationStep !== null || this.velocityQuantizationStep !== null) this.quantizeEntities();
|
|
6163
5601
|
this.handleCollisionEvents(firstPassCollisions);
|
|
6164
5602
|
if (this.enableSleep) this.updateSleepState();
|
|
6165
5603
|
}
|
|
@@ -6249,7 +5687,10 @@ var World = class {
|
|
|
6249
5687
|
clear() {
|
|
6250
5688
|
for (const entity of this.entities) this.events.emitEntityRemoved(entity);
|
|
6251
5689
|
this.entities.clear();
|
|
5690
|
+
this.staticEntities.clear();
|
|
5691
|
+
this.dynamicEntities.clear();
|
|
6252
5692
|
this.spatialPartition.clear();
|
|
5693
|
+
this.queryResults.clear();
|
|
6253
5694
|
this.previousCollisions.clear();
|
|
6254
5695
|
}
|
|
6255
5696
|
quantizeEntities() {
|
|
@@ -6270,6 +5711,18 @@ var World = class {
|
|
|
6270
5711
|
refreshDynamicEntitiesInPartition() {
|
|
6271
5712
|
for (const entity of this.dynamicEntities) this.spatialPartition.update(entity);
|
|
6272
5713
|
}
|
|
5714
|
+
refreshEntitiesInPartition() {
|
|
5715
|
+
for (const entity of this.entities) this.syncEntity(entity);
|
|
5716
|
+
}
|
|
5717
|
+
syncEntityCollection(entity) {
|
|
5718
|
+
if (entity.isStatic()) {
|
|
5719
|
+
this.dynamicEntities.delete(entity);
|
|
5720
|
+
this.staticEntities.add(entity);
|
|
5721
|
+
} else {
|
|
5722
|
+
this.staticEntities.delete(entity);
|
|
5723
|
+
this.dynamicEntities.add(entity);
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
6273
5726
|
/**
|
|
6274
5727
|
* Gets statistics about the world
|
|
6275
5728
|
*
|
|
@@ -6358,6 +5811,10 @@ var World = class {
|
|
|
6358
5811
|
*
|
|
6359
5812
|
* Represents an independent simulation zone that can contain entities.
|
|
6360
5813
|
* Regions can overlap to allow smooth entity transitions.
|
|
5814
|
+
*
|
|
5815
|
+
* @experimental Region simulation is not the recommended default path for
|
|
5816
|
+
* RPG-JS server physics yet. Prefer a single `PhysicsEngine` world until
|
|
5817
|
+
* region migration semantics are fully benchmarked and documented.
|
|
6361
5818
|
*
|
|
6362
5819
|
* @example
|
|
6363
5820
|
* ```typescript
|
|
@@ -6509,6 +5966,11 @@ var Region = class {
|
|
|
6509
5966
|
*
|
|
6510
5967
|
* Manages multiple regions in a distributed physics world.
|
|
6511
5968
|
* Handles entity migration between regions and region activation/deactivation.
|
|
5969
|
+
*
|
|
5970
|
+
* @experimental Region simulation is not the recommended default path for
|
|
5971
|
+
* RPG-JS server physics yet. Prefer `PhysicsEngine` without regions until
|
|
5972
|
+
* migration semantics, events, stats, and config propagation are fully
|
|
5973
|
+
* benchmarked and documented.
|
|
6512
5974
|
*
|
|
6513
5975
|
* @example
|
|
6514
5976
|
* ```typescript
|
|
@@ -6617,6 +6079,37 @@ var RegionManager = class {
|
|
|
6617
6079
|
}
|
|
6618
6080
|
}
|
|
6619
6081
|
/**
|
|
6082
|
+
* Synchronizes an entity with its current region, migrating it when needed.
|
|
6083
|
+
*
|
|
6084
|
+
* @param entity - Entity to synchronize
|
|
6085
|
+
*/
|
|
6086
|
+
updateEntity(entity) {
|
|
6087
|
+
const currentRegion = this.entityRegionMap.get(entity);
|
|
6088
|
+
const newRegion = this.getRegionAt(entity.position);
|
|
6089
|
+
if (!newRegion) {
|
|
6090
|
+
if (currentRegion) {
|
|
6091
|
+
currentRegion.removeEntity(entity);
|
|
6092
|
+
this.entityRegionMap.delete(entity);
|
|
6093
|
+
}
|
|
6094
|
+
return;
|
|
6095
|
+
}
|
|
6096
|
+
if (!currentRegion) {
|
|
6097
|
+
newRegion.addEntity(entity);
|
|
6098
|
+
this.entityRegionMap.set(entity, newRegion);
|
|
6099
|
+
if (this.config.autoActivate) newRegion.activate();
|
|
6100
|
+
return;
|
|
6101
|
+
}
|
|
6102
|
+
if (newRegion !== currentRegion) {
|
|
6103
|
+
currentRegion.removeEntity(entity);
|
|
6104
|
+
newRegion.addEntity(entity);
|
|
6105
|
+
this.entityRegionMap.set(entity, newRegion);
|
|
6106
|
+
if (this.config.autoActivate) newRegion.activate();
|
|
6107
|
+
if (this.config.autoActivate && currentRegion.getEntities().length === 0) currentRegion.deactivate();
|
|
6108
|
+
return;
|
|
6109
|
+
}
|
|
6110
|
+
currentRegion.getWorld().updateEntity(entity);
|
|
6111
|
+
}
|
|
6112
|
+
/**
|
|
6620
6113
|
* Updates entity positions and migrates them between regions if needed
|
|
6621
6114
|
*/
|
|
6622
6115
|
updateEntities() {
|
|
@@ -6628,13 +6121,7 @@ var RegionManager = class {
|
|
|
6628
6121
|
newRegion
|
|
6629
6122
|
});
|
|
6630
6123
|
}
|
|
6631
|
-
for (const { entity
|
|
6632
|
-
const oldRegion = this.entityRegionMap.get(entity);
|
|
6633
|
-
if (oldRegion) oldRegion.removeEntity(entity);
|
|
6634
|
-
newRegion.addEntity(entity);
|
|
6635
|
-
this.entityRegionMap.set(entity, newRegion);
|
|
6636
|
-
if (this.config.autoActivate) newRegion.activate();
|
|
6637
|
-
}
|
|
6124
|
+
for (const { entity } of entitiesToMigrate) this.updateEntity(entity);
|
|
6638
6125
|
}
|
|
6639
6126
|
/**
|
|
6640
6127
|
* Steps all active regions
|
|
@@ -7046,7 +6533,8 @@ var ZoneManager = class {
|
|
|
7046
6533
|
* ```
|
|
7047
6534
|
*/
|
|
7048
6535
|
createZone(config, callbacks) {
|
|
7049
|
-
const id = generateUUID();
|
|
6536
|
+
const id = config.id ?? generateUUID();
|
|
6537
|
+
if (this.zones.has(id)) throw new Error(`Zone "${id}" already exists`);
|
|
7050
6538
|
const radius = config.radius;
|
|
7051
6539
|
if (typeof radius !== "number" || radius <= 0) throw new Error("Zone radius must be a positive number");
|
|
7052
6540
|
const angle = config.angle ?? 360;
|
|
@@ -7370,6 +6858,7 @@ var PhysicsEngine = class {
|
|
|
7370
6858
|
this.regionManager = null;
|
|
7371
6859
|
this.movementManager = null;
|
|
7372
6860
|
this.zoneManager = null;
|
|
6861
|
+
this.rpgSpeeds = /* @__PURE__ */ new Map();
|
|
7373
6862
|
this.tick = 0;
|
|
7374
6863
|
this.useRegions = config.enableRegions ?? false;
|
|
7375
6864
|
if (this.useRegions) {
|
|
@@ -7460,6 +6949,19 @@ var PhysicsEngine = class {
|
|
|
7460
6949
|
return this.tick;
|
|
7461
6950
|
}
|
|
7462
6951
|
/**
|
|
6952
|
+
* Applies a frame of RPG movement inputs, advances the simulation, and updates sensors.
|
|
6953
|
+
*
|
|
6954
|
+
* @param inputs - Map of entity id to direction input
|
|
6955
|
+
* @returns Current tick index after stepping
|
|
6956
|
+
*/
|
|
6957
|
+
stepFrame(inputs = {}) {
|
|
6958
|
+
for (const [id, input] of Object.entries(inputs)) if (this.isFrameInputObject(input)) this.moveEntity(id, input.direction, input.speed);
|
|
6959
|
+
else this.moveEntity(id, input);
|
|
6960
|
+
this.step();
|
|
6961
|
+
if (this.zoneManager) this.zoneManager.update();
|
|
6962
|
+
return this.tick;
|
|
6963
|
+
}
|
|
6964
|
+
/**
|
|
7463
6965
|
* Advances the simulation by a fixed number of ticks.
|
|
7464
6966
|
*
|
|
7465
6967
|
* @param ticks - Number of ticks to simulate (>= 1)
|
|
@@ -7494,6 +6996,93 @@ var PhysicsEngine = class {
|
|
|
7494
6996
|
return entity;
|
|
7495
6997
|
}
|
|
7496
6998
|
/**
|
|
6999
|
+
* Creates a dynamic RPG character with a stable id, hitbox, and default movement speed.
|
|
7000
|
+
*
|
|
7001
|
+
* This is the recommended creation path for players and NPCs in server-side RPG
|
|
7002
|
+
* simulations because the entity is registered and ready for `moveEntity` and
|
|
7003
|
+
* `stepFrame` immediately.
|
|
7004
|
+
*
|
|
7005
|
+
* @param id - Stable entity identifier
|
|
7006
|
+
* @param options - Character configuration
|
|
7007
|
+
* @returns Created entity
|
|
7008
|
+
*/
|
|
7009
|
+
createCharacter(id, options) {
|
|
7010
|
+
const { x, y, hitbox: hitboxOption, speed, velocity, maxLinearVelocity, ...entityOptions } = options;
|
|
7011
|
+
const hitbox = this.resolveHitbox(hitboxOption);
|
|
7012
|
+
const config = {
|
|
7013
|
+
...entityOptions,
|
|
7014
|
+
...hitbox,
|
|
7015
|
+
uuid: id,
|
|
7016
|
+
position: {
|
|
7017
|
+
x,
|
|
7018
|
+
y
|
|
7019
|
+
},
|
|
7020
|
+
mass: options.mass ?? 1,
|
|
7021
|
+
maxLinearVelocity: maxLinearVelocity ?? speed
|
|
7022
|
+
};
|
|
7023
|
+
if (velocity !== void 0) config.velocity = velocity;
|
|
7024
|
+
const entity = this.createEntity(config);
|
|
7025
|
+
this.rpgSpeeds.set(entity.uuid, speed);
|
|
7026
|
+
return entity;
|
|
7027
|
+
}
|
|
7028
|
+
/**
|
|
7029
|
+
* Creates a static rectangular obstacle for RPG maps.
|
|
7030
|
+
*
|
|
7031
|
+
* @param id - Stable entity identifier
|
|
7032
|
+
* @param options - Obstacle configuration
|
|
7033
|
+
* @returns Created static entity
|
|
7034
|
+
*/
|
|
7035
|
+
createStaticObstacle(id, options) {
|
|
7036
|
+
return this.createEntity({
|
|
7037
|
+
...options,
|
|
7038
|
+
uuid: id,
|
|
7039
|
+
position: {
|
|
7040
|
+
x: options.x,
|
|
7041
|
+
y: options.y
|
|
7042
|
+
},
|
|
7043
|
+
width: options.width,
|
|
7044
|
+
height: options.height,
|
|
7045
|
+
mass: 0
|
|
7046
|
+
});
|
|
7047
|
+
}
|
|
7048
|
+
/**
|
|
7049
|
+
* Creates a static or attached sensor zone with a stable id.
|
|
7050
|
+
*
|
|
7051
|
+
* Sensors detect entities through the `ZoneManager` and do not create physical
|
|
7052
|
+
* collision responses.
|
|
7053
|
+
*
|
|
7054
|
+
* @param id - Stable sensor identifier
|
|
7055
|
+
* @param options - Sensor configuration
|
|
7056
|
+
* @returns Sensor identifier
|
|
7057
|
+
*/
|
|
7058
|
+
createSensor(id, options) {
|
|
7059
|
+
const { onEnter, onExit, entity, position, x, y, ...zoneOptions } = options;
|
|
7060
|
+
let callbacks;
|
|
7061
|
+
if (onEnter || onExit) {
|
|
7062
|
+
callbacks = {};
|
|
7063
|
+
if (onEnter) callbacks.onEnter = onEnter;
|
|
7064
|
+
if (onExit) callbacks.onExit = onExit;
|
|
7065
|
+
}
|
|
7066
|
+
if (entity) {
|
|
7067
|
+
const attachedEntity = this.resolveEntity(entity);
|
|
7068
|
+
if (!attachedEntity) throw new Error(`Cannot create sensor "${id}" for unknown entity`);
|
|
7069
|
+
return this.getZoneManager().createZone({
|
|
7070
|
+
...zoneOptions,
|
|
7071
|
+
id,
|
|
7072
|
+
entity: attachedEntity
|
|
7073
|
+
}, callbacks);
|
|
7074
|
+
}
|
|
7075
|
+
const resolvedPosition = position ?? {
|
|
7076
|
+
x: x ?? 0,
|
|
7077
|
+
y: y ?? 0
|
|
7078
|
+
};
|
|
7079
|
+
return this.getZoneManager().createZone({
|
|
7080
|
+
...zoneOptions,
|
|
7081
|
+
id,
|
|
7082
|
+
position: resolvedPosition
|
|
7083
|
+
}, callbacks);
|
|
7084
|
+
}
|
|
7085
|
+
/**
|
|
7497
7086
|
* Adds an existing entity to the engine
|
|
7498
7087
|
*
|
|
7499
7088
|
* @param entity - Entity to add
|
|
@@ -7510,6 +7099,7 @@ var PhysicsEngine = class {
|
|
|
7510
7099
|
* @param entity - Entity to remove
|
|
7511
7100
|
*/
|
|
7512
7101
|
removeEntity(entity) {
|
|
7102
|
+
this.rpgSpeeds.delete(entity.uuid);
|
|
7513
7103
|
if (this.useRegions && this.regionManager) this.regionManager.removeEntity(entity);
|
|
7514
7104
|
else this.world.removeEntity(entity);
|
|
7515
7105
|
}
|
|
@@ -7586,7 +7176,70 @@ var PhysicsEngine = class {
|
|
|
7586
7176
|
*/
|
|
7587
7177
|
teleport(entity, position) {
|
|
7588
7178
|
entity.teleport(position);
|
|
7589
|
-
|
|
7179
|
+
this.updateEntity(entity);
|
|
7180
|
+
}
|
|
7181
|
+
/**
|
|
7182
|
+
* Teleports an entity by id or entity reference.
|
|
7183
|
+
*
|
|
7184
|
+
* @param entity - Entity or UUID to teleport
|
|
7185
|
+
* @param position - New position
|
|
7186
|
+
* @returns True when the entity was found
|
|
7187
|
+
*/
|
|
7188
|
+
teleportEntity(entity, position) {
|
|
7189
|
+
const target = this.resolveEntity(entity);
|
|
7190
|
+
if (!target) return false;
|
|
7191
|
+
this.teleport(target, position);
|
|
7192
|
+
return true;
|
|
7193
|
+
}
|
|
7194
|
+
/**
|
|
7195
|
+
* Moves an entity in a cardinal or vector direction using its configured RPG speed.
|
|
7196
|
+
*
|
|
7197
|
+
* Pass `'idle'` or a zero vector to stop the entity.
|
|
7198
|
+
*
|
|
7199
|
+
* @param entity - Entity or UUID to move
|
|
7200
|
+
* @param direction - Cardinal direction or arbitrary vector
|
|
7201
|
+
* @param speed - Optional speed override for this command
|
|
7202
|
+
* @returns True when the entity was found
|
|
7203
|
+
*/
|
|
7204
|
+
moveEntity(entity, direction, speed) {
|
|
7205
|
+
const target = this.resolveEntity(entity);
|
|
7206
|
+
if (!target) return false;
|
|
7207
|
+
const vector = this.resolveDirection(direction);
|
|
7208
|
+
const magnitude = vector.length();
|
|
7209
|
+
if (magnitude === 0) {
|
|
7210
|
+
target.setVelocity({
|
|
7211
|
+
x: 0,
|
|
7212
|
+
y: 0
|
|
7213
|
+
});
|
|
7214
|
+
return true;
|
|
7215
|
+
}
|
|
7216
|
+
const resolvedSpeed = speed ?? this.rpgSpeeds.get(target.uuid) ?? target.maxLinearVelocity;
|
|
7217
|
+
if (!Number.isFinite(resolvedSpeed) || resolvedSpeed <= 0) {
|
|
7218
|
+
target.setVelocity({
|
|
7219
|
+
x: 0,
|
|
7220
|
+
y: 0
|
|
7221
|
+
});
|
|
7222
|
+
return true;
|
|
7223
|
+
}
|
|
7224
|
+
target.setVelocity({
|
|
7225
|
+
x: vector.x / magnitude * resolvedSpeed,
|
|
7226
|
+
y: vector.y / magnitude * resolvedSpeed
|
|
7227
|
+
});
|
|
7228
|
+
return true;
|
|
7229
|
+
}
|
|
7230
|
+
/**
|
|
7231
|
+
* Synchronizes an entity after manual position, shape, or state changes.
|
|
7232
|
+
*
|
|
7233
|
+
* Direct mutations such as `entity.position.set(...)`, `entity.width = ...`,
|
|
7234
|
+
* or `entity.freeze()` bypass the world's broad-phase structures. Call this
|
|
7235
|
+
* helper after such mutations so spatial queries and collisions use the
|
|
7236
|
+
* current entity state immediately.
|
|
7237
|
+
*
|
|
7238
|
+
* @param entity - Entity to synchronize
|
|
7239
|
+
*/
|
|
7240
|
+
updateEntity(entity) {
|
|
7241
|
+
if (this.useRegions && this.regionManager) this.regionManager.updateEntity(entity);
|
|
7242
|
+
else this.world.updateEntity(entity);
|
|
7590
7243
|
}
|
|
7591
7244
|
/**
|
|
7592
7245
|
* Freezes an entity (makes it static)
|
|
@@ -7595,6 +7248,7 @@ var PhysicsEngine = class {
|
|
|
7595
7248
|
*/
|
|
7596
7249
|
freeze(entity) {
|
|
7597
7250
|
entity.freeze();
|
|
7251
|
+
this.updateEntity(entity);
|
|
7598
7252
|
}
|
|
7599
7253
|
/**
|
|
7600
7254
|
* Unfreezes an entity (makes it dynamic)
|
|
@@ -7603,6 +7257,7 @@ var PhysicsEngine = class {
|
|
|
7603
7257
|
*/
|
|
7604
7258
|
unfreeze(entity) {
|
|
7605
7259
|
entity.unfreeze();
|
|
7260
|
+
this.updateEntity(entity);
|
|
7606
7261
|
}
|
|
7607
7262
|
/**
|
|
7608
7263
|
* Queries entities in an AABB region
|
|
@@ -7620,9 +7275,7 @@ var PhysicsEngine = class {
|
|
|
7620
7275
|
}
|
|
7621
7276
|
return entities;
|
|
7622
7277
|
}
|
|
7623
|
-
|
|
7624
|
-
if (world.spatialPartition) return Array.from(world.spatialPartition.queryAABB(bounds));
|
|
7625
|
-
return this.world.getEntities().filter((e) => bounds.contains(e.position));
|
|
7278
|
+
return this.world.queryAABB(bounds);
|
|
7626
7279
|
}
|
|
7627
7280
|
/**
|
|
7628
7281
|
* Clears all entities from the engine
|
|
@@ -7630,6 +7283,7 @@ var PhysicsEngine = class {
|
|
|
7630
7283
|
clear() {
|
|
7631
7284
|
if (this.useRegions && this.regionManager) this.regionManager.clear();
|
|
7632
7285
|
else this.world.clear();
|
|
7286
|
+
this.rpgSpeeds.clear();
|
|
7633
7287
|
this.tick = 0;
|
|
7634
7288
|
}
|
|
7635
7289
|
/**
|
|
@@ -7647,6 +7301,7 @@ var PhysicsEngine = class {
|
|
|
7647
7301
|
*/
|
|
7648
7302
|
assignPolygonCollider(entity, config) {
|
|
7649
7303
|
assignPolygonCollider(entity, config);
|
|
7304
|
+
this.updateEntity(entity);
|
|
7650
7305
|
}
|
|
7651
7306
|
/**
|
|
7652
7307
|
* Casts a ray in the physics world and returns the nearest hit, if any.
|
|
@@ -7664,9 +7319,7 @@ var PhysicsEngine = class {
|
|
|
7664
7319
|
* ```
|
|
7665
7320
|
*/
|
|
7666
7321
|
raycast(origin, direction, maxDistance, mask, filter) {
|
|
7667
|
-
|
|
7668
|
-
if (!partition) return null;
|
|
7669
|
-
return raycast(partition, origin, direction, maxDistance, mask, filter);
|
|
7322
|
+
return this.world.raycast(origin, direction, maxDistance, mask, filter);
|
|
7670
7323
|
}
|
|
7671
7324
|
/**
|
|
7672
7325
|
* Computes continuous collision detection (sweep test) time-of-impact between two entities
|
|
@@ -7766,6 +7419,7 @@ var PhysicsEngine = class {
|
|
|
7766
7419
|
entity.angularVelocity = state.angularVelocity;
|
|
7767
7420
|
if (state.sleeping) entity.sleep();
|
|
7768
7421
|
else entity.wakeUp();
|
|
7422
|
+
this.updateEntity(entity);
|
|
7769
7423
|
}
|
|
7770
7424
|
this.tick = snapshot.tick;
|
|
7771
7425
|
}
|
|
@@ -7777,6 +7431,43 @@ var PhysicsEngine = class {
|
|
|
7777
7431
|
getRegionManager() {
|
|
7778
7432
|
return this.regionManager;
|
|
7779
7433
|
}
|
|
7434
|
+
resolveEntity(entity) {
|
|
7435
|
+
if (entity instanceof Entity) return entity;
|
|
7436
|
+
return this.getEntityByUUID(entity);
|
|
7437
|
+
}
|
|
7438
|
+
resolveHitbox(hitbox) {
|
|
7439
|
+
if (typeof hitbox === "number") return { radius: hitbox };
|
|
7440
|
+
if ("type" in hitbox) {
|
|
7441
|
+
if (hitbox.type === "circle") return { radius: hitbox.radius };
|
|
7442
|
+
if (hitbox.type === "capsule") return { capsule: {
|
|
7443
|
+
radius: hitbox.radius,
|
|
7444
|
+
height: hitbox.height
|
|
7445
|
+
} };
|
|
7446
|
+
return {
|
|
7447
|
+
width: hitbox.width,
|
|
7448
|
+
height: hitbox.height
|
|
7449
|
+
};
|
|
7450
|
+
}
|
|
7451
|
+
if ("radius" in hitbox) return { radius: hitbox.radius };
|
|
7452
|
+
return {
|
|
7453
|
+
width: hitbox.width,
|
|
7454
|
+
height: hitbox.height
|
|
7455
|
+
};
|
|
7456
|
+
}
|
|
7457
|
+
resolveDirection(direction) {
|
|
7458
|
+
if (direction instanceof Vector2) return direction.clone();
|
|
7459
|
+
if (typeof direction === "string") switch (direction) {
|
|
7460
|
+
case "up": return new Vector2(0, -1);
|
|
7461
|
+
case "down": return new Vector2(0, 1);
|
|
7462
|
+
case "left": return new Vector2(-1, 0);
|
|
7463
|
+
case "right": return new Vector2(1, 0);
|
|
7464
|
+
default: return new Vector2(0, 0);
|
|
7465
|
+
}
|
|
7466
|
+
return new Vector2(direction.x, direction.y);
|
|
7467
|
+
}
|
|
7468
|
+
isFrameInputObject(input) {
|
|
7469
|
+
return typeof input === "object" && !(input instanceof Vector2) && "direction" in input;
|
|
7470
|
+
}
|
|
7780
7471
|
};
|
|
7781
7472
|
//#endregion
|
|
7782
7473
|
//#region ../physic/src/movement/strategies/Dash.ts
|
|
@@ -8381,17 +8072,7 @@ var ProjectileMovement = class {
|
|
|
8381
8072
|
const gravity = this.options.gravity ?? 30;
|
|
8382
8073
|
this.verticalVelocity -= gravity * dt;
|
|
8383
8074
|
this.currentHeight += this.verticalVelocity * dt;
|
|
8384
|
-
|
|
8385
|
-
else {
|
|
8386
|
-
const dispatcher = globalThis;
|
|
8387
|
-
if (typeof dispatcher.dispatchEvent === "function" && typeof CustomEvent !== "undefined") {
|
|
8388
|
-
const event = new CustomEvent("projectile:height", { detail: {
|
|
8389
|
-
id: body.id,
|
|
8390
|
-
height: this.currentHeight
|
|
8391
|
-
} });
|
|
8392
|
-
dispatcher.dispatchEvent(event);
|
|
8393
|
-
}
|
|
8394
|
-
}
|
|
8075
|
+
this.options.onHeightUpdate?.(this.currentHeight, body);
|
|
8395
8076
|
if (this.currentHeight <= 0) {
|
|
8396
8077
|
this.currentHeight = 0;
|
|
8397
8078
|
if (this.type === ProjectileType.Bounce) if (this.bounceCount < (this.options.maxBounces ?? 0)) {
|
|
@@ -8572,6 +8253,9 @@ var MovementManager = class {
|
|
|
8572
8253
|
};
|
|
8573
8254
|
//#endregion
|
|
8574
8255
|
//#region ../common/src/rooms/Map.ts
|
|
8256
|
+
var COLLISION_PROXIMITY_MARGIN = 1;
|
|
8257
|
+
var DEFAULT_INTERACTION_RANGE = 16;
|
|
8258
|
+
var INTERACTION_SIDE_PADDING = 4;
|
|
8575
8259
|
var RpgCommonMap = class {
|
|
8576
8260
|
constructor() {
|
|
8577
8261
|
this.data = signal(null);
|
|
@@ -8796,6 +8480,10 @@ var RpgCommonMap = class {
|
|
|
8796
8480
|
this.removeHitbox(key, event, "npc");
|
|
8797
8481
|
} else if (type === "update") {
|
|
8798
8482
|
event.id = event.id ?? key;
|
|
8483
|
+
if (event._removeTransition?.()) {
|
|
8484
|
+
this.removeHitbox(key, event, "npc");
|
|
8485
|
+
return;
|
|
8486
|
+
}
|
|
8799
8487
|
if (!this.getBody(key)) {
|
|
8800
8488
|
this.createCharacterHitbox(event, "npc", { mass: 100 });
|
|
8801
8489
|
return;
|
|
@@ -8924,9 +8612,8 @@ var RpgCommonMap = class {
|
|
|
8924
8612
|
this.physicsAccumulatorMs -= fixedStepMs;
|
|
8925
8613
|
hooks?.beforeStep?.();
|
|
8926
8614
|
this.physic.updateMovements();
|
|
8927
|
-
const tick = this.physic.
|
|
8615
|
+
const tick = this.physic.stepFrame();
|
|
8928
8616
|
executed += 1;
|
|
8929
|
-
this.runPostTickUpdates();
|
|
8930
8617
|
hooks?.afterStep?.(tick);
|
|
8931
8618
|
}
|
|
8932
8619
|
return executed;
|
|
@@ -9006,8 +8693,7 @@ var RpgCommonMap = class {
|
|
|
9006
8693
|
forceSingleTick(hooks) {
|
|
9007
8694
|
hooks?.beforeStep?.();
|
|
9008
8695
|
this.physic.updateMovements();
|
|
9009
|
-
const tick = this.physic.
|
|
9010
|
-
this.runPostTickUpdates();
|
|
8696
|
+
const tick = this.physic.stepFrame();
|
|
9011
8697
|
hooks?.afterStep?.(tick);
|
|
9012
8698
|
const fixedMs = this.physic.getWorld().getTimeStep() * 1e3;
|
|
9013
8699
|
this.physicsAccumulatorMs = Math.max(0, this.physicsAccumulatorMs - fixedMs);
|
|
@@ -9023,12 +8709,10 @@ var RpgCommonMap = class {
|
|
|
9023
8709
|
return;
|
|
9024
8710
|
}
|
|
9025
8711
|
const hitbox = typeof owner.hitbox === "function" ? owner.hitbox() : owner.hitbox;
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
const radius = Math.max(width, height) / 2;
|
|
8712
|
+
hitbox?.w;
|
|
8713
|
+
hitbox?.h;
|
|
9029
8714
|
this.addCharacter({
|
|
9030
8715
|
owner,
|
|
9031
|
-
radius,
|
|
9032
8716
|
kind,
|
|
9033
8717
|
maxSpeed: owner.speed(),
|
|
9034
8718
|
collidesWithCharacters: !this.shouldDisableCharacterCollisions(owner),
|
|
@@ -9350,19 +9034,13 @@ var RpgCommonMap = class {
|
|
|
9350
9034
|
const centerY = y + height / 2;
|
|
9351
9035
|
boxWidth = Math.max(width, 1);
|
|
9352
9036
|
boxHeight = Math.max(height, 1);
|
|
9353
|
-
entity = this.physic.
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
x: centerX,
|
|
9357
|
-
y: centerY
|
|
9358
|
-
},
|
|
9037
|
+
entity = this.physic.createStaticObstacle(id, {
|
|
9038
|
+
x: centerX,
|
|
9039
|
+
y: centerY,
|
|
9359
9040
|
width: boxWidth,
|
|
9360
9041
|
height: boxHeight,
|
|
9361
|
-
mass: Infinity,
|
|
9362
|
-
state: EntityState.Static,
|
|
9363
9042
|
restitution: 0
|
|
9364
9043
|
});
|
|
9365
|
-
entity.freeze();
|
|
9366
9044
|
}
|
|
9367
9045
|
return id;
|
|
9368
9046
|
}
|
|
@@ -9407,25 +9085,24 @@ var RpgCommonMap = class {
|
|
|
9407
9085
|
const hitbox = typeof owner.hitbox === "function" ? owner.hitbox() : owner.hitbox;
|
|
9408
9086
|
const width = hitbox?.w ?? 32;
|
|
9409
9087
|
const height = hitbox?.h ?? 32;
|
|
9410
|
-
const radius = Math.max(width, height) / 2;
|
|
9411
9088
|
const topLeftX = owner.x();
|
|
9412
9089
|
const topLeftY = owner.y();
|
|
9413
9090
|
const centerX = topLeftX + width / 2;
|
|
9414
9091
|
const centerY = topLeftY + height / 2;
|
|
9415
9092
|
const isStatic = !!options.isStatic;
|
|
9416
|
-
const
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9093
|
+
const speed = options.maxSpeed ? options.maxSpeed * this.speedScalar : 200;
|
|
9094
|
+
const entity = this.physic.createCharacter(id, {
|
|
9095
|
+
x: centerX,
|
|
9096
|
+
y: centerY,
|
|
9097
|
+
hitbox: {
|
|
9098
|
+
width,
|
|
9099
|
+
height
|
|
9421
9100
|
},
|
|
9422
|
-
|
|
9423
|
-
width,
|
|
9424
|
-
height,
|
|
9101
|
+
speed,
|
|
9425
9102
|
mass: options.mass ?? (isStatic ? Infinity : 1),
|
|
9426
9103
|
friction: options.friction ?? .4,
|
|
9427
9104
|
linearDamping: isStatic ? 1 : .2,
|
|
9428
|
-
maxLinearVelocity:
|
|
9105
|
+
maxLinearVelocity: speed,
|
|
9429
9106
|
restitution: 0
|
|
9430
9107
|
});
|
|
9431
9108
|
if (isStatic) entity.freeze();
|
|
@@ -9543,7 +9220,10 @@ var RpgCommonMap = class {
|
|
|
9543
9220
|
const entityHeight = entity.height || entity.radius * 2 || 32;
|
|
9544
9221
|
const centerX = x + entityWidth / 2;
|
|
9545
9222
|
const centerY = y + entityHeight / 2;
|
|
9546
|
-
|
|
9223
|
+
this.physic.teleportEntity(entity, {
|
|
9224
|
+
x: centerX,
|
|
9225
|
+
y: centerY
|
|
9226
|
+
});
|
|
9547
9227
|
return true;
|
|
9548
9228
|
}
|
|
9549
9229
|
/**
|
|
@@ -9579,26 +9259,8 @@ var RpgCommonMap = class {
|
|
|
9579
9259
|
moveBody(player, direction) {
|
|
9580
9260
|
const entity = this.physic.getEntityByUUID(player.id);
|
|
9581
9261
|
if (!entity) return false;
|
|
9582
|
-
const
|
|
9583
|
-
|
|
9584
|
-
switch (direction) {
|
|
9585
|
-
case Direction.Left:
|
|
9586
|
-
vx = -speedValue * this.speedScalar;
|
|
9587
|
-
break;
|
|
9588
|
-
case Direction.Right:
|
|
9589
|
-
vx = speedValue * this.speedScalar;
|
|
9590
|
-
break;
|
|
9591
|
-
case Direction.Up:
|
|
9592
|
-
vy = -speedValue * this.speedScalar;
|
|
9593
|
-
break;
|
|
9594
|
-
case Direction.Down:
|
|
9595
|
-
vy = speedValue * this.speedScalar;
|
|
9596
|
-
break;
|
|
9597
|
-
}
|
|
9598
|
-
entity.setVelocity({
|
|
9599
|
-
x: vx,
|
|
9600
|
-
y: vy
|
|
9601
|
-
});
|
|
9262
|
+
const speed = player.speed() * this.speedScalar;
|
|
9263
|
+
this.physic.moveEntity(entity, direction, speed);
|
|
9602
9264
|
entity.wakeUp();
|
|
9603
9265
|
return true;
|
|
9604
9266
|
}
|
|
@@ -9667,8 +9329,7 @@ var RpgCommonMap = class {
|
|
|
9667
9329
|
if (!entity) return [];
|
|
9668
9330
|
const collider = createCollider(entity);
|
|
9669
9331
|
if (!collider) return [];
|
|
9670
|
-
const
|
|
9671
|
-
const expandedAABB = entityAABB.expand(1);
|
|
9332
|
+
const expandedAABB = collider.getBounds().expand(1);
|
|
9672
9333
|
const nearby = this.physic.queryAABB(expandedAABB);
|
|
9673
9334
|
const collisions = [];
|
|
9674
9335
|
for (const other of nearby) {
|
|
@@ -9676,10 +9337,46 @@ var RpgCommonMap = class {
|
|
|
9676
9337
|
const otherCollider = createCollider(other);
|
|
9677
9338
|
if (!otherCollider) continue;
|
|
9678
9339
|
const otherAABB = otherCollider.getBounds();
|
|
9679
|
-
if (
|
|
9340
|
+
if (expandedAABB.intersects(otherAABB)) collisions.push(other.uuid);
|
|
9341
|
+
}
|
|
9342
|
+
return collisions;
|
|
9343
|
+
}
|
|
9344
|
+
/**
|
|
9345
|
+
* Get entities inside the action area directly in front of an entity.
|
|
9346
|
+
*
|
|
9347
|
+
* This is intentionally separate from physical collisions: a player often
|
|
9348
|
+
* presses the action key while blocked just before touching an NPC, so the
|
|
9349
|
+
* physics solver may leave a tiny gap even though gameplay expects an
|
|
9350
|
+
* interaction.
|
|
9351
|
+
*/
|
|
9352
|
+
getInteractionCollisions(id, direction, range = DEFAULT_INTERACTION_RANGE) {
|
|
9353
|
+
const entity = this.physic.getEntityByUUID(id);
|
|
9354
|
+
if (!entity) return [];
|
|
9355
|
+
const collider = createCollider(entity);
|
|
9356
|
+
if (!collider) return [];
|
|
9357
|
+
const entityAABB = collider.getBounds();
|
|
9358
|
+
const interactionAABB = this.getInteractionAABB(entityAABB, direction, range);
|
|
9359
|
+
const nearby = this.physic.queryAABB(interactionAABB);
|
|
9360
|
+
const collisions = [];
|
|
9361
|
+
for (const other of nearby) {
|
|
9362
|
+
if (other.uuid === id) continue;
|
|
9363
|
+
const otherCollider = createCollider(other);
|
|
9364
|
+
if (!otherCollider) continue;
|
|
9365
|
+
if (interactionAABB.intersects(otherCollider.getBounds())) collisions.push(other.uuid);
|
|
9680
9366
|
}
|
|
9681
9367
|
return collisions;
|
|
9682
9368
|
}
|
|
9369
|
+
getInteractionAABB(bounds, direction, range = DEFAULT_INTERACTION_RANGE) {
|
|
9370
|
+
const distance = Number.isFinite(range) ? Math.max(0, range) : DEFAULT_INTERACTION_RANGE;
|
|
9371
|
+
const sidePadding = distance > 0 ? Math.min(INTERACTION_SIDE_PADDING, distance / 2) : 0;
|
|
9372
|
+
switch (direction) {
|
|
9373
|
+
case Direction.Up: return new AABB(bounds.minX - sidePadding, bounds.minY - distance, bounds.maxX + sidePadding, bounds.minY + COLLISION_PROXIMITY_MARGIN);
|
|
9374
|
+
case Direction.Down: return new AABB(bounds.minX - sidePadding, bounds.maxY - COLLISION_PROXIMITY_MARGIN, bounds.maxX + sidePadding, bounds.maxY + distance);
|
|
9375
|
+
case Direction.Left: return new AABB(bounds.minX - distance, bounds.minY - sidePadding, bounds.minX + COLLISION_PROXIMITY_MARGIN, bounds.maxY + sidePadding);
|
|
9376
|
+
case Direction.Right: return new AABB(bounds.maxX - COLLISION_PROXIMITY_MARGIN, bounds.minY - sidePadding, bounds.maxX + distance, bounds.maxY + sidePadding);
|
|
9377
|
+
default: return bounds.expand(distance);
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9683
9380
|
/**
|
|
9684
9381
|
* Get physics body (entity) for an id
|
|
9685
9382
|
* @protected
|
|
@@ -9739,6 +9436,7 @@ var RpgCommonMap = class {
|
|
|
9739
9436
|
}
|
|
9740
9437
|
entity.position.set(centerX, centerY);
|
|
9741
9438
|
entity.notifyPositionChange();
|
|
9439
|
+
this.physic.updateEntity(entity);
|
|
9742
9440
|
return entity;
|
|
9743
9441
|
}
|
|
9744
9442
|
/**
|
|
@@ -9750,7 +9448,6 @@ var RpgCommonMap = class {
|
|
|
9750
9448
|
* @private
|
|
9751
9449
|
*/
|
|
9752
9450
|
addZone(id, options) {
|
|
9753
|
-
const zoneManager = this.physic.getZoneManager();
|
|
9754
9451
|
if (this.physic.getEntityByUUID(id)) throw new Error(`Zone with id ${id} already exists as entity`);
|
|
9755
9452
|
const radius = options.radius;
|
|
9756
9453
|
if (typeof radius !== "number" || radius <= 0) throw new Error("Zone radius must be a positive number");
|
|
@@ -9759,15 +9456,13 @@ var RpgCommonMap = class {
|
|
|
9759
9456
|
attachedEntity = this.physic.getEntityByUUID(options.linkedTo);
|
|
9760
9457
|
if (!attachedEntity) throw new Error(`Cannot link zone to unknown entity ${options.linkedTo}`);
|
|
9761
9458
|
}
|
|
9762
|
-
const
|
|
9763
|
-
|
|
9764
|
-
callbacks._onExitString = void 0;
|
|
9765
|
-
const zoneId = attachedEntity ? zoneManager.createAttachedZone(attachedEntity, {
|
|
9459
|
+
const zoneId = this.physic.createSensor(id, attachedEntity ? {
|
|
9460
|
+
entity: attachedEntity,
|
|
9766
9461
|
radius,
|
|
9767
9462
|
angle: options.angle ?? 360,
|
|
9768
9463
|
direction: options.direction ?? "down",
|
|
9769
9464
|
limitedByWalls: options.limitedByWalls ?? false
|
|
9770
|
-
}
|
|
9465
|
+
} : {
|
|
9771
9466
|
position: {
|
|
9772
9467
|
x: options.x ?? 0,
|
|
9773
9468
|
y: options.y ?? 0
|
|
@@ -9776,7 +9471,7 @@ var RpgCommonMap = class {
|
|
|
9776
9471
|
angle: options.angle ?? 360,
|
|
9777
9472
|
direction: options.direction ?? "down",
|
|
9778
9473
|
limitedByWalls: options.limitedByWalls ?? false
|
|
9779
|
-
}
|
|
9474
|
+
});
|
|
9780
9475
|
this._zoneIdMap = this._zoneIdMap || /* @__PURE__ */ new Map();
|
|
9781
9476
|
this._zoneIdMap.set(id, zoneId);
|
|
9782
9477
|
return id;
|
|
@@ -10422,25 +10117,17 @@ var AGI = "agi";
|
|
|
10422
10117
|
var INT = "int";
|
|
10423
10118
|
var DEX = "dex";
|
|
10424
10119
|
//#endregion
|
|
10425
|
-
//#region ../../node_modules/.pnpm/@signe+di@2.
|
|
10426
|
-
var __defProp = Object.defineProperty;
|
|
10427
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
10428
|
-
value,
|
|
10429
|
-
configurable: true
|
|
10430
|
-
});
|
|
10120
|
+
//#region ../../node_modules/.pnpm/@signe+di@2.10.0/node_modules/@signe/di/dist/index.js
|
|
10431
10121
|
var DEFAULT_INSTANCE_KEY = "__default__";
|
|
10432
10122
|
function toTokenName(token) {
|
|
10433
10123
|
return typeof token === "function" ? token.name : token;
|
|
10434
10124
|
}
|
|
10435
|
-
__name(toTokenName, "toTokenName");
|
|
10436
10125
|
function toInstanceKey(name) {
|
|
10437
10126
|
return name ?? DEFAULT_INSTANCE_KEY;
|
|
10438
10127
|
}
|
|
10439
|
-
__name(toInstanceKey, "toInstanceKey");
|
|
10440
10128
|
function getRecord(context, token) {
|
|
10441
10129
|
return context.get("inject:" + toTokenName(token));
|
|
10442
10130
|
}
|
|
10443
|
-
__name(getRecord, "getRecord");
|
|
10444
10131
|
function ensureRecord(context, token) {
|
|
10445
10132
|
const key = "inject:" + toTokenName(token);
|
|
10446
10133
|
let record = context.get(key);
|
|
@@ -10452,7 +10139,6 @@ function ensureRecord(context, token) {
|
|
|
10452
10139
|
context.set(key, record);
|
|
10453
10140
|
return record;
|
|
10454
10141
|
}
|
|
10455
|
-
__name(ensureRecord, "ensureRecord");
|
|
10456
10142
|
function provide(context, token, value, options = {}) {
|
|
10457
10143
|
const record = ensureRecord(context, token);
|
|
10458
10144
|
const instanceKey = toInstanceKey(options.name);
|
|
@@ -10461,41 +10147,17 @@ function provide(context, token, value, options = {}) {
|
|
|
10461
10147
|
record.values.set(instanceKey, value);
|
|
10462
10148
|
return value;
|
|
10463
10149
|
}
|
|
10464
|
-
__name(provide, "provide");
|
|
10465
|
-
function isInjected(context, token, options = {}) {
|
|
10466
|
-
const record = getRecord(context, token);
|
|
10467
|
-
if (!record) return false;
|
|
10468
|
-
if (options.name) return record.injected.has(toInstanceKey(options.name));
|
|
10469
|
-
if (record.multi) return record.injected.size > 0;
|
|
10470
|
-
return record.injected.has(DEFAULT_INSTANCE_KEY);
|
|
10471
|
-
}
|
|
10472
|
-
__name(isInjected, "isInjected");
|
|
10473
|
-
function isProvided(context, token, options = {}) {
|
|
10474
|
-
const record = getRecord(context, token);
|
|
10475
|
-
if (!record) return false;
|
|
10476
|
-
if (options.name) return record.values.has(toInstanceKey(options.name));
|
|
10477
|
-
if (record.multi) return record.values.size > 0;
|
|
10478
|
-
return record.values.has(DEFAULT_INSTANCE_KEY);
|
|
10479
|
-
}
|
|
10480
|
-
__name(isProvided, "isProvided");
|
|
10481
|
-
function hasInstance(context, token, options = {}) {
|
|
10482
|
-
return isProvided(context, token, options);
|
|
10483
|
-
}
|
|
10484
|
-
__name(hasInstance, "hasInstance");
|
|
10485
10150
|
function handleMissingInjection(token, options) {
|
|
10486
10151
|
const name = toTokenName(token);
|
|
10487
10152
|
if (options.name) throw new Error(`Injection provider ${name} with name ${options.name} not found`);
|
|
10488
10153
|
throw new Error(`Injection provider ${name} not found`);
|
|
10489
10154
|
}
|
|
10490
|
-
__name(handleMissingInjection, "handleMissingInjection");
|
|
10491
10155
|
function markInjected(record, key) {
|
|
10492
10156
|
record.injected.add(key);
|
|
10493
10157
|
}
|
|
10494
|
-
__name(markInjected, "markInjected");
|
|
10495
10158
|
function markAllInjected(record) {
|
|
10496
10159
|
for (const key of record.values.keys()) record.injected.add(key);
|
|
10497
10160
|
}
|
|
10498
|
-
__name(markAllInjected, "markAllInjected");
|
|
10499
10161
|
function inject$1(context, token, options = {}) {
|
|
10500
10162
|
const record = getRecord(context, token);
|
|
10501
10163
|
if (!record) {
|
|
@@ -10528,78 +10190,6 @@ function inject$1(context, token, options = {}) {
|
|
|
10528
10190
|
markInjected(record, DEFAULT_INSTANCE_KEY);
|
|
10529
10191
|
return value;
|
|
10530
10192
|
}
|
|
10531
|
-
__name(inject$1, "inject");
|
|
10532
|
-
function override(providers, newProvider, options) {
|
|
10533
|
-
let { upsert = false, key } = options ?? {};
|
|
10534
|
-
if (!key) key = typeof newProvider === "function" ? newProvider.name : newProvider.provide;
|
|
10535
|
-
const flatProviders = providers.flat();
|
|
10536
|
-
const exists = flatProviders.some((provider) => {
|
|
10537
|
-
if (typeof provider === "function") return provider.name === key;
|
|
10538
|
-
else if (typeof provider === "object") return provider.provide === key;
|
|
10539
|
-
return false;
|
|
10540
|
-
});
|
|
10541
|
-
const mappedProviders = flatProviders.map((provider) => {
|
|
10542
|
-
if (typeof provider === "function" && provider.name === key) return newProvider;
|
|
10543
|
-
else if (typeof provider === "object" && provider.provide === key) return newProvider;
|
|
10544
|
-
return provider;
|
|
10545
|
-
});
|
|
10546
|
-
if (upsert && !exists) mappedProviders.push(newProvider);
|
|
10547
|
-
return mappedProviders;
|
|
10548
|
-
}
|
|
10549
|
-
__name(override, "override");
|
|
10550
|
-
function findProviders(providers, name) {
|
|
10551
|
-
const results = [];
|
|
10552
|
-
for (const provider of providers) if (Array.isArray(provider)) results.push(...findProviders(provider, name));
|
|
10553
|
-
else if (findProvider(provider, name)) results.push(provider);
|
|
10554
|
-
return results;
|
|
10555
|
-
}
|
|
10556
|
-
__name(findProviders, "findProviders");
|
|
10557
|
-
function findProvider(providers, name) {
|
|
10558
|
-
if (!Array.isArray(providers)) {
|
|
10559
|
-
if (typeof providers === "object" && "provide" in providers) {
|
|
10560
|
-
const provider = providers;
|
|
10561
|
-
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
10562
|
-
if (name instanceof RegExp) {
|
|
10563
|
-
if (name.test(providerName)) return providers;
|
|
10564
|
-
} else if (providerName === name) return providers;
|
|
10565
|
-
}
|
|
10566
|
-
return null;
|
|
10567
|
-
}
|
|
10568
|
-
for (const provider of providers) {
|
|
10569
|
-
if (Array.isArray(provider)) {
|
|
10570
|
-
const found = findProvider(provider, name);
|
|
10571
|
-
if (found) return found;
|
|
10572
|
-
continue;
|
|
10573
|
-
}
|
|
10574
|
-
if (typeof provider === "object" && "provide" in provider) {
|
|
10575
|
-
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
10576
|
-
if (name instanceof RegExp) {
|
|
10577
|
-
if (name.test(providerName)) return provider;
|
|
10578
|
-
} else if (providerName === name) return provider;
|
|
10579
|
-
}
|
|
10580
|
-
}
|
|
10581
|
-
return null;
|
|
10582
|
-
}
|
|
10583
|
-
__name(findProvider, "findProvider");
|
|
10584
|
-
function processProvider(mergedConfig, baseConfig, provider) {
|
|
10585
|
-
if (Array.isArray(provider)) {
|
|
10586
|
-
for (const nestedProvider of provider) processProvider(mergedConfig, baseConfig, nestedProvider);
|
|
10587
|
-
return;
|
|
10588
|
-
}
|
|
10589
|
-
if (findProvider(baseConfig.providers, provider.provide)) mergedConfig.providers = override(mergedConfig.providers, provider);
|
|
10590
|
-
else mergedConfig.providers.push(provider);
|
|
10591
|
-
}
|
|
10592
|
-
__name(processProvider, "processProvider");
|
|
10593
|
-
function mergeConfig(baseConfig, config) {
|
|
10594
|
-
const mergedConfig = {
|
|
10595
|
-
...baseConfig,
|
|
10596
|
-
...config,
|
|
10597
|
-
providers: [...baseConfig.providers]
|
|
10598
|
-
};
|
|
10599
|
-
for (const provider of config.providers) processProvider(mergedConfig, baseConfig, provider);
|
|
10600
|
-
return mergedConfig;
|
|
10601
|
-
}
|
|
10602
|
-
__name(mergeConfig, "mergeConfig");
|
|
10603
10193
|
function extractProvideOptions(source) {
|
|
10604
10194
|
if (!source) return;
|
|
10605
10195
|
const { multi, name } = source;
|
|
@@ -10609,14 +10199,12 @@ function extractProvideOptions(source) {
|
|
|
10609
10199
|
name
|
|
10610
10200
|
};
|
|
10611
10201
|
}
|
|
10612
|
-
__name(extractProvideOptions, "extractProvideOptions");
|
|
10613
10202
|
function getDeps(provider) {
|
|
10614
10203
|
if (typeof provider === "function") return provider.deps ?? [];
|
|
10615
10204
|
return provider.deps ?? [];
|
|
10616
10205
|
}
|
|
10617
|
-
__name(getDeps, "getDeps");
|
|
10618
10206
|
function sortProviders(providers) {
|
|
10619
|
-
const tokenName =
|
|
10207
|
+
const tokenName = (t) => typeof t === "function" ? t.name : t;
|
|
10620
10208
|
const map = /* @__PURE__ */ new Map();
|
|
10621
10209
|
for (const p of providers) {
|
|
10622
10210
|
const token = tokenName(typeof p === "function" ? p : p.provide);
|
|
@@ -10627,7 +10215,7 @@ function sortProviders(providers) {
|
|
|
10627
10215
|
const result = [];
|
|
10628
10216
|
const visited = /* @__PURE__ */ new Set();
|
|
10629
10217
|
const stack = /* @__PURE__ */ new Set();
|
|
10630
|
-
const visit =
|
|
10218
|
+
const visit = (token) => {
|
|
10631
10219
|
const name = tokenName(token);
|
|
10632
10220
|
if (visited.has(name)) return;
|
|
10633
10221
|
if (stack.has(name)) throw new Error(`Circular dependency detected for provider ${name}`);
|
|
@@ -10641,11 +10229,10 @@ function sortProviders(providers) {
|
|
|
10641
10229
|
visited.add(name);
|
|
10642
10230
|
}
|
|
10643
10231
|
stack.delete(name);
|
|
10644
|
-
}
|
|
10232
|
+
};
|
|
10645
10233
|
for (const p of providers) visit(typeof p === "function" ? p : p.provide);
|
|
10646
10234
|
return result;
|
|
10647
10235
|
}
|
|
10648
|
-
__name(sortProviders, "sortProviders");
|
|
10649
10236
|
async function injector(context, providers) {
|
|
10650
10237
|
providers = providers.flat();
|
|
10651
10238
|
providers = sortProviders(providers);
|
|
@@ -10671,13 +10258,11 @@ async function injector(context, providers) {
|
|
|
10671
10258
|
provide(context, token, instance, options);
|
|
10672
10259
|
}
|
|
10673
10260
|
}
|
|
10674
|
-
__name(injector, "injector");
|
|
10675
10261
|
var Context = class {
|
|
10676
|
-
|
|
10677
|
-
|
|
10262
|
+
constructor() {
|
|
10263
|
+
/** Internal storage for injected values */
|
|
10264
|
+
this.values = {};
|
|
10678
10265
|
}
|
|
10679
|
-
/** Internal storage for injected values */
|
|
10680
|
-
values = {};
|
|
10681
10266
|
/**
|
|
10682
10267
|
* Sets a value in the context
|
|
10683
10268
|
* @param key - Unique identifier for the value
|
|
@@ -11041,6 +10626,6 @@ function provideServerModules(modules) {
|
|
|
11041
10626
|
});
|
|
11042
10627
|
}
|
|
11043
10628
|
//#endregion
|
|
11044
|
-
export {
|
|
10629
|
+
export { Skill as $, isArray as A, ProjectileMovement as B, SDEF as C, arrayFlat as D, PrebuiltGui as E, ModulesToken as F, Knockback as G, PathFollow as H, RpgModule as I, Entity as J, IceMovement as K, WorldMapsManager as L, isInstanceOf as M, isString as N, arrayUniq as O, random as P, RpgCommonPlayer as Q, RpgCommonMap as R, PDEF as S, PerlinNoise2D as T, Oscillate as U, ProjectileType as V, LinearRepulsion as W, RpgShape as X, Vector2 as Y, Direction as Z, ATK as _, isMapUpdateAuthorized as a, map as at, MAXHP as b, updateMap as c, BehaviorSubject as ct, context$1 as d, Observable as dt, Item as et, inject as f, identity as ft, AGI as g, __spreadArray as gt, injector as h, __read as ht, createMapUpdateHeaders as i, filter as it, isFunction as j, capitalize as k, context as l, createOperatorSubscriber as lt, inject$1 as m, isFunction$1 as mt, MAP_UPDATE_TOKEN_ENV as n, __decorateMetadata as nt, readMapUpdateToken as o, from as ot, setInject as p, createErrorClass as pt, Dash as q, MAP_UPDATE_TOKEN_HEADER as r, signal as rt, resolveMapUpdateToken as s, executeSchedule as st, provideServerModules as t, __decorate as tt, clearInject as u, operate as ut, DEX as v, STR as w, MAXSP as x, INT as y, SeekAvoid as z };
|
|
11045
10630
|
|
|
11046
|
-
//# sourceMappingURL=module-
|
|
10631
|
+
//# sourceMappingURL=module-5HOX9Ovu.js.map
|