@modlock/modlock 0.1.74 → 0.1.76
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/host.gen.d.ts +23 -1
- package/index.d.ts +1 -1
- package/index.js +1538 -1158
- package/package.json +6 -6
- package/ui.d.ts +71 -5
package/index.js
CHANGED
|
@@ -3643,6 +3643,94 @@ var GiveItemRequest = /* @__PURE__ */ createMessageType(
|
|
|
3643
3643
|
}
|
|
3644
3644
|
}
|
|
3645
3645
|
);
|
|
3646
|
+
var BuyItemRequest = /* @__PURE__ */ createMessageType(
|
|
3647
|
+
"modlock.wasm.abilities.BuyItemRequest",
|
|
3648
|
+
() => [
|
|
3649
|
+
[1, "player", 5],
|
|
3650
|
+
[2, "item", 9],
|
|
3651
|
+
[3, "imbue", 13, 4],
|
|
3652
|
+
[4, "source", 13, 4]
|
|
3653
|
+
],
|
|
3654
|
+
{
|
|
3655
|
+
decode: (r, end, m) => {
|
|
3656
|
+
while (r.pos < end) {
|
|
3657
|
+
const t = r.tag();
|
|
3658
|
+
if ((t & 7) === 4) return m;
|
|
3659
|
+
switch (t >>> 3) {
|
|
3660
|
+
case 1:
|
|
3661
|
+
m.player = r.int32();
|
|
3662
|
+
break;
|
|
3663
|
+
case 2:
|
|
3664
|
+
m.item = r.string();
|
|
3665
|
+
break;
|
|
3666
|
+
case 3:
|
|
3667
|
+
m.imbue = r.uint32();
|
|
3668
|
+
break;
|
|
3669
|
+
case 4:
|
|
3670
|
+
m.source = r.uint32();
|
|
3671
|
+
break;
|
|
3672
|
+
default:
|
|
3673
|
+
r.skip(t);
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
return m;
|
|
3677
|
+
},
|
|
3678
|
+
encode: (m, w) => {
|
|
3679
|
+
{
|
|
3680
|
+
const v = m.player;
|
|
3681
|
+
if (v) w.uint32(8).int32(v);
|
|
3682
|
+
}
|
|
3683
|
+
{
|
|
3684
|
+
const v = m.item;
|
|
3685
|
+
if (v) w.uint32(18).string(v);
|
|
3686
|
+
}
|
|
3687
|
+
{
|
|
3688
|
+
const v = m.imbue;
|
|
3689
|
+
if (v != null) w.uint32(24).uint32(v);
|
|
3690
|
+
}
|
|
3691
|
+
{
|
|
3692
|
+
const v = m.source;
|
|
3693
|
+
if (v != null) w.uint32(32).uint32(v);
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
);
|
|
3698
|
+
var TrainAbilityRequest = /* @__PURE__ */ createMessageType(
|
|
3699
|
+
"modlock.wasm.abilities.TrainAbilityRequest",
|
|
3700
|
+
() => [
|
|
3701
|
+
[1, "player", 5],
|
|
3702
|
+
[2, "slot", 13]
|
|
3703
|
+
],
|
|
3704
|
+
{
|
|
3705
|
+
decode: (r, end, m) => {
|
|
3706
|
+
while (r.pos < end) {
|
|
3707
|
+
const t = r.tag();
|
|
3708
|
+
if ((t & 7) === 4) return m;
|
|
3709
|
+
switch (t >>> 3) {
|
|
3710
|
+
case 1:
|
|
3711
|
+
m.player = r.int32();
|
|
3712
|
+
break;
|
|
3713
|
+
case 2:
|
|
3714
|
+
m.slot = r.uint32();
|
|
3715
|
+
break;
|
|
3716
|
+
default:
|
|
3717
|
+
r.skip(t);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
return m;
|
|
3721
|
+
},
|
|
3722
|
+
encode: (m, w) => {
|
|
3723
|
+
{
|
|
3724
|
+
const v = m.player;
|
|
3725
|
+
if (v) w.uint32(8).int32(v);
|
|
3726
|
+
}
|
|
3727
|
+
{
|
|
3728
|
+
const v = m.slot;
|
|
3729
|
+
if (v) w.uint32(16).uint32(v);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
);
|
|
3646
3734
|
var ReplaceAbilityRequest = /* @__PURE__ */ createMessageType(
|
|
3647
3735
|
"modlock.wasm.abilities.ReplaceAbilityRequest",
|
|
3648
3736
|
() => [
|
|
@@ -10334,7 +10422,10 @@ var HudPart_Enum = /* @__PURE__ */ createEnumType(
|
|
|
10334
10422
|
[6, "HUD_PART_MINIMAP"],
|
|
10335
10423
|
[7, "HUD_PART_ABILITIES"],
|
|
10336
10424
|
[8, "HUD_PART_STATUS"],
|
|
10337
|
-
[9, "HUD_PART_STATS"]
|
|
10425
|
+
[9, "HUD_PART_STATS"],
|
|
10426
|
+
[10, "HUD_PART_HERO_PICKER"],
|
|
10427
|
+
[11, "HUD_PART_BROKER_COUNTDOWN"],
|
|
10428
|
+
[12, "HUD_PART_ALL"]
|
|
10338
10429
|
]
|
|
10339
10430
|
);
|
|
10340
10431
|
var Kind_Enum = /* @__PURE__ */ createEnumType(
|
|
@@ -10472,7 +10563,12 @@ var Node = /* @__PURE__ */ createMessageType(
|
|
|
10472
10563
|
[30, "sheets", 9, 1],
|
|
10473
10564
|
[31, "free_cursor", 8],
|
|
10474
10565
|
[32, "item", 13],
|
|
10475
|
-
[33, "free_cursor_asks", 13]
|
|
10566
|
+
[33, "free_cursor_asks", 13],
|
|
10567
|
+
[34, "ability", 13],
|
|
10568
|
+
[35, "ability_player", 13],
|
|
10569
|
+
[36, "cues", 11, 1, Cue.codec],
|
|
10570
|
+
[37, "ability_bar_presses", 8],
|
|
10571
|
+
[38, "ability_display", 11, 1, AbilityRow.codec]
|
|
10476
10572
|
],
|
|
10477
10573
|
{
|
|
10478
10574
|
decode: (r, end, m) => {
|
|
@@ -10619,6 +10715,25 @@ var Node = /* @__PURE__ */ createMessageType(
|
|
|
10619
10715
|
case 33:
|
|
10620
10716
|
m.freeCursorAsks = r.uint32();
|
|
10621
10717
|
break;
|
|
10718
|
+
case 34:
|
|
10719
|
+
m.ability = r.uint32();
|
|
10720
|
+
break;
|
|
10721
|
+
case 35:
|
|
10722
|
+
m.abilityPlayer = r.uint32();
|
|
10723
|
+
break;
|
|
10724
|
+
case 36:
|
|
10725
|
+
;
|
|
10726
|
+
(m.cues ??= []).push(Cue.decode(r, r.delimited(), {}));
|
|
10727
|
+
break;
|
|
10728
|
+
case 37:
|
|
10729
|
+
m.abilityBarPresses = r.bool();
|
|
10730
|
+
break;
|
|
10731
|
+
case 38:
|
|
10732
|
+
;
|
|
10733
|
+
(m.abilityDisplay ??= []).push(
|
|
10734
|
+
AbilityRow.decode(r, r.delimited(), {})
|
|
10735
|
+
);
|
|
10736
|
+
break;
|
|
10622
10737
|
default:
|
|
10623
10738
|
r.skip(t);
|
|
10624
10739
|
}
|
|
@@ -10772,6 +10887,177 @@ var Node = /* @__PURE__ */ createMessageType(
|
|
|
10772
10887
|
const v = m.freeCursorAsks;
|
|
10773
10888
|
if (v) w.uint32(264).uint32(v);
|
|
10774
10889
|
}
|
|
10890
|
+
{
|
|
10891
|
+
const v = m.ability;
|
|
10892
|
+
if (v) w.uint32(272).uint32(v);
|
|
10893
|
+
}
|
|
10894
|
+
{
|
|
10895
|
+
const v = m.abilityPlayer;
|
|
10896
|
+
if (v) w.uint32(280).uint32(v);
|
|
10897
|
+
}
|
|
10898
|
+
{
|
|
10899
|
+
const a = m.cues;
|
|
10900
|
+
if (a != null) for (const e of a) Cue.writeField(w, 36, e);
|
|
10901
|
+
}
|
|
10902
|
+
{
|
|
10903
|
+
const v = m.abilityBarPresses;
|
|
10904
|
+
if (v) w.uint32(296).bool(v);
|
|
10905
|
+
}
|
|
10906
|
+
{
|
|
10907
|
+
const a = m.abilityDisplay;
|
|
10908
|
+
if (a != null) for (const e of a) AbilityRow.writeField(w, 38, e);
|
|
10909
|
+
}
|
|
10910
|
+
}
|
|
10911
|
+
}
|
|
10912
|
+
);
|
|
10913
|
+
var AbilityRow = /* @__PURE__ */ createMessageType(
|
|
10914
|
+
"modlock.wasm.ui.AbilityRow",
|
|
10915
|
+
() => [
|
|
10916
|
+
[1, "player", 13],
|
|
10917
|
+
[2, "name", 9],
|
|
10918
|
+
[3, "hero", 9],
|
|
10919
|
+
[4, "own", 8],
|
|
10920
|
+
[5, "abilities", 11, 1, ShownAbility.codec]
|
|
10921
|
+
],
|
|
10922
|
+
{
|
|
10923
|
+
decode: (r, end, m) => {
|
|
10924
|
+
while (r.pos < end) {
|
|
10925
|
+
const t = r.tag();
|
|
10926
|
+
if ((t & 7) === 4) return m;
|
|
10927
|
+
switch (t >>> 3) {
|
|
10928
|
+
case 1:
|
|
10929
|
+
m.player = r.uint32();
|
|
10930
|
+
break;
|
|
10931
|
+
case 2:
|
|
10932
|
+
m.name = r.string();
|
|
10933
|
+
break;
|
|
10934
|
+
case 3:
|
|
10935
|
+
m.hero = r.string();
|
|
10936
|
+
break;
|
|
10937
|
+
case 4:
|
|
10938
|
+
m.own = r.bool();
|
|
10939
|
+
break;
|
|
10940
|
+
case 5:
|
|
10941
|
+
;
|
|
10942
|
+
(m.abilities ??= []).push(
|
|
10943
|
+
ShownAbility.decode(r, r.delimited(), {})
|
|
10944
|
+
);
|
|
10945
|
+
break;
|
|
10946
|
+
default:
|
|
10947
|
+
r.skip(t);
|
|
10948
|
+
}
|
|
10949
|
+
}
|
|
10950
|
+
return m;
|
|
10951
|
+
},
|
|
10952
|
+
encode: (m, w) => {
|
|
10953
|
+
{
|
|
10954
|
+
const v = m.player;
|
|
10955
|
+
if (v) w.uint32(8).uint32(v);
|
|
10956
|
+
}
|
|
10957
|
+
{
|
|
10958
|
+
const v = m.name;
|
|
10959
|
+
if (v) w.uint32(18).string(v);
|
|
10960
|
+
}
|
|
10961
|
+
{
|
|
10962
|
+
const v = m.hero;
|
|
10963
|
+
if (v) w.uint32(26).string(v);
|
|
10964
|
+
}
|
|
10965
|
+
{
|
|
10966
|
+
const v = m.own;
|
|
10967
|
+
if (v) w.uint32(32).bool(v);
|
|
10968
|
+
}
|
|
10969
|
+
{
|
|
10970
|
+
const a = m.abilities;
|
|
10971
|
+
if (a != null) for (const e of a) ShownAbility.writeField(w, 5, e);
|
|
10972
|
+
}
|
|
10973
|
+
}
|
|
10974
|
+
}
|
|
10975
|
+
);
|
|
10976
|
+
var ShownAbility = /* @__PURE__ */ createMessageType(
|
|
10977
|
+
"modlock.wasm.ui.ShownAbility",
|
|
10978
|
+
() => [
|
|
10979
|
+
[1, "ability", 13],
|
|
10980
|
+
[2, "image", 9],
|
|
10981
|
+
[3, "upgrades", 13]
|
|
10982
|
+
],
|
|
10983
|
+
{
|
|
10984
|
+
decode: (r, end, m) => {
|
|
10985
|
+
while (r.pos < end) {
|
|
10986
|
+
const t = r.tag();
|
|
10987
|
+
if ((t & 7) === 4) return m;
|
|
10988
|
+
switch (t >>> 3) {
|
|
10989
|
+
case 1:
|
|
10990
|
+
m.ability = r.uint32();
|
|
10991
|
+
break;
|
|
10992
|
+
case 2:
|
|
10993
|
+
m.image = r.string();
|
|
10994
|
+
break;
|
|
10995
|
+
case 3:
|
|
10996
|
+
m.upgrades = r.uint32();
|
|
10997
|
+
break;
|
|
10998
|
+
default:
|
|
10999
|
+
r.skip(t);
|
|
11000
|
+
}
|
|
11001
|
+
}
|
|
11002
|
+
return m;
|
|
11003
|
+
},
|
|
11004
|
+
encode: (m, w) => {
|
|
11005
|
+
{
|
|
11006
|
+
const v = m.ability;
|
|
11007
|
+
if (v) w.uint32(8).uint32(v);
|
|
11008
|
+
}
|
|
11009
|
+
{
|
|
11010
|
+
const v = m.image;
|
|
11011
|
+
if (v) w.uint32(18).string(v);
|
|
11012
|
+
}
|
|
11013
|
+
{
|
|
11014
|
+
const v = m.upgrades;
|
|
11015
|
+
if (v) w.uint32(24).uint32(v);
|
|
11016
|
+
}
|
|
11017
|
+
}
|
|
11018
|
+
}
|
|
11019
|
+
);
|
|
11020
|
+
var Cue = /* @__PURE__ */ createMessageType(
|
|
11021
|
+
"modlock.wasm.ui.Cue",
|
|
11022
|
+
() => [
|
|
11023
|
+
[1, "number", 13],
|
|
11024
|
+
[2, "sound", 9],
|
|
11025
|
+
[3, "seconds", 2]
|
|
11026
|
+
],
|
|
11027
|
+
{
|
|
11028
|
+
decode: (r, end, m) => {
|
|
11029
|
+
while (r.pos < end) {
|
|
11030
|
+
const t = r.tag();
|
|
11031
|
+
if ((t & 7) === 4) return m;
|
|
11032
|
+
switch (t >>> 3) {
|
|
11033
|
+
case 1:
|
|
11034
|
+
m.number = r.uint32();
|
|
11035
|
+
break;
|
|
11036
|
+
case 2:
|
|
11037
|
+
m.sound = r.string();
|
|
11038
|
+
break;
|
|
11039
|
+
case 3:
|
|
11040
|
+
m.seconds = r.float();
|
|
11041
|
+
break;
|
|
11042
|
+
default:
|
|
11043
|
+
r.skip(t);
|
|
11044
|
+
}
|
|
11045
|
+
}
|
|
11046
|
+
return m;
|
|
11047
|
+
},
|
|
11048
|
+
encode: (m, w) => {
|
|
11049
|
+
{
|
|
11050
|
+
const v = m.number;
|
|
11051
|
+
if (v) w.uint32(8).uint32(v);
|
|
11052
|
+
}
|
|
11053
|
+
{
|
|
11054
|
+
const v = m.sound;
|
|
11055
|
+
if (v) w.uint32(18).string(v);
|
|
11056
|
+
}
|
|
11057
|
+
{
|
|
11058
|
+
const v = m.seconds;
|
|
11059
|
+
if (v != null && v !== 0) w.uint32(29).float(v);
|
|
11060
|
+
}
|
|
10775
11061
|
}
|
|
10776
11062
|
}
|
|
10777
11063
|
);
|
|
@@ -12863,7 +13149,9 @@ var Player = class _Player {
|
|
|
12863
13149
|
/**
|
|
12864
13150
|
* selectHero gives the player a hero on a team, 2 or 3, and returns the
|
|
12865
13151
|
* hero's identifier as Pawn.hero reports it. The hero appears on a later
|
|
12866
|
-
* frame.
|
|
13152
|
+
* frame. A hero the player picked through the game's Change Hero wins: the
|
|
13153
|
+
* game removes the old hero before it spawns the pick, and a call in that
|
|
13154
|
+
* gap, up to 5 seconds, fails and leaves the pick to land.
|
|
12867
13155
|
*/
|
|
12868
13156
|
selectHero(hero, team) {
|
|
12869
13157
|
const reply2 = call("SelectHero", SelectHeroRequest.toBinary({ player: this.slot, hero: typeof hero === "string" ? { case: "heroName", value: hero } : typeof hero === "number" ? { case: "heroId", value: hero } : void 0, team: int32(team) }));
|
|
@@ -12993,6 +13281,30 @@ var Player = class _Player {
|
|
|
12993
13281
|
giveItem(item2, imbue) {
|
|
12994
13282
|
return call("GiveItem", GiveItemRequest.toBinary({ player: this.slot, item: item2, imbue })) !== void 0;
|
|
12995
13283
|
}
|
|
13284
|
+
/**
|
|
13285
|
+
* buyItem buys an item for the hero as the shop does, under the shop's own
|
|
13286
|
+
* rules and for the souls it charges, or fails and charges nothing when the
|
|
13287
|
+
* shop refuses, as away from the shop or without the souls. With imbue, an
|
|
13288
|
+
* imbuing item strengthens whatever ability the hero holds in that slot, 0
|
|
13289
|
+
* to 3, including one ReplaceAbility put there, which the game's own
|
|
13290
|
+
* buydependentitem refuses; the call fails, buying nothing, when the
|
|
13291
|
+
* ability does not accept it.
|
|
13292
|
+
*/
|
|
13293
|
+
buyItem(item2, imbue, source) {
|
|
13294
|
+
return call("BuyItem", BuyItemRequest.toBinary({ player: this.slot, item: item2, imbue, source })) !== void 0;
|
|
13295
|
+
}
|
|
13296
|
+
/**
|
|
13297
|
+
* trainAbility trains or upgrades whatever ability the hero holds in a
|
|
13298
|
+
* slot, 0 to 3, as the player holding the upgrade key and pressing the
|
|
13299
|
+
* slot's ability key does: an untrained ability trains for an ability
|
|
13300
|
+
* unlock, and a trained one buys its next tier for ability points. It works
|
|
13301
|
+
* on an ability ReplaceAbility put there, which the game's own commands for
|
|
13302
|
+
* a slot do not reach. When the game refuses, as without an unlock or the
|
|
13303
|
+
* points, the call fails and nothing is spent.
|
|
13304
|
+
*/
|
|
13305
|
+
trainAbility(slot) {
|
|
13306
|
+
return call("TrainAbility", TrainAbilityRequest.toBinary({ player: this.slot, slot })) !== void 0;
|
|
13307
|
+
}
|
|
12996
13308
|
/**
|
|
12997
13309
|
* replaceAbility puts the ability named ability, untrained unless keep
|
|
12998
13310
|
* carries the old one's progress, in the hero's ability slot index, as
|
|
@@ -14052,1153 +14364,6 @@ function itemId(name) {
|
|
|
14052
14364
|
return (h ^ h >>> 15) >>> 0;
|
|
14053
14365
|
}
|
|
14054
14366
|
|
|
14055
|
-
// js/src/ui.ts
|
|
14056
|
-
function jsx(type, props, key) {
|
|
14057
|
-
const named = key === void 0 ? void 0 : String(key);
|
|
14058
|
-
if (typeof type === "function") {
|
|
14059
|
-
return { type: fragment, props: { children: type(props) }, key: named };
|
|
14060
|
-
}
|
|
14061
|
-
return { type, props, key: named };
|
|
14062
|
-
}
|
|
14063
|
-
var fragment = "fragment";
|
|
14064
|
-
var jsxs = jsx;
|
|
14065
|
-
function Fragment(props) {
|
|
14066
|
-
return props.children;
|
|
14067
|
-
}
|
|
14068
|
-
function show(player, root) {
|
|
14069
|
-
views.set(player.slot, { ...view(player), root });
|
|
14070
|
-
return draw(player);
|
|
14071
|
-
}
|
|
14072
|
-
function hideHud(player, parts) {
|
|
14073
|
-
views.set(player.slot, { ...view(player), hud: parts });
|
|
14074
|
-
return draw(player);
|
|
14075
|
-
}
|
|
14076
|
-
function freeCursor(player, free) {
|
|
14077
|
-
const current = view(player);
|
|
14078
|
-
views.set(player.slot, {
|
|
14079
|
-
...current,
|
|
14080
|
-
cursor: free,
|
|
14081
|
-
asks: free ? current.asks + 1 : current.asks
|
|
14082
|
-
});
|
|
14083
|
-
return draw(player);
|
|
14084
|
-
}
|
|
14085
|
-
function cursorFree(player) {
|
|
14086
|
-
const pawn = player.pawn();
|
|
14087
|
-
if (pawn === void 0) return void 0;
|
|
14088
|
-
return readField(
|
|
14089
|
-
pawn.entity,
|
|
14090
|
-
"CCitadelPlayer_MovementServices",
|
|
14091
|
-
"m_bHasFreeCursor",
|
|
14092
|
-
"bool"
|
|
14093
|
-
);
|
|
14094
|
-
}
|
|
14095
|
-
function sheet(path) {
|
|
14096
|
-
if (!path.endsWith(".css") || !path.split("/").every((part) => sheetPart.test(part) && part !== "..")) {
|
|
14097
|
-
return false;
|
|
14098
|
-
}
|
|
14099
|
-
if (sheets.includes(path)) {
|
|
14100
|
-
return true;
|
|
14101
|
-
}
|
|
14102
|
-
sheets.push(path);
|
|
14103
|
-
for (const current of views.values()) {
|
|
14104
|
-
draw(current.player);
|
|
14105
|
-
}
|
|
14106
|
-
return true;
|
|
14107
|
-
}
|
|
14108
|
-
var sheetPart = /^[\w.-]+$/;
|
|
14109
|
-
var sheets = [];
|
|
14110
|
-
function route(player, name, value) {
|
|
14111
|
-
const routes = new Map(view(player).routes);
|
|
14112
|
-
const encoded = value === void 0 ? void 0 : JSON.stringify(value);
|
|
14113
|
-
if (!routeName.test(name) || value !== void 0 && encoded === void 0) {
|
|
14114
|
-
return false;
|
|
14115
|
-
}
|
|
14116
|
-
if (encoded === void 0) {
|
|
14117
|
-
routes.delete(name);
|
|
14118
|
-
} else {
|
|
14119
|
-
routes.set(name, encoded);
|
|
14120
|
-
}
|
|
14121
|
-
views.set(player.slot, { ...view(player), routes });
|
|
14122
|
-
return draw(player);
|
|
14123
|
-
}
|
|
14124
|
-
var routeName = /^[\w.-]+$/;
|
|
14125
|
-
function hide(player) {
|
|
14126
|
-
views.delete(player.slot);
|
|
14127
|
-
screens.delete(player.slot);
|
|
14128
|
-
return send(player.slot, { reset: true });
|
|
14129
|
-
}
|
|
14130
|
-
function toast(player, text2, seconds = 4) {
|
|
14131
|
-
const current = view(player);
|
|
14132
|
-
const notice = { id: nextNotice++, text: text2, until: now2 + seconds };
|
|
14133
|
-
views.set(player.slot, {
|
|
14134
|
-
...current,
|
|
14135
|
-
notices: [...current.notices, notice].slice(-maxNotices)
|
|
14136
|
-
});
|
|
14137
|
-
return draw(player);
|
|
14138
|
-
}
|
|
14139
|
-
function press(player, node) {
|
|
14140
|
-
const pressed = screens.get(player.slot)?.presses.get(node);
|
|
14141
|
-
if (pressed) {
|
|
14142
|
-
pressed.handler(player);
|
|
14143
|
-
}
|
|
14144
|
-
}
|
|
14145
|
-
function change(player, node, value) {
|
|
14146
|
-
if (typeof value === "object" && value !== null) {
|
|
14147
|
-
screens.get(player.slot)?.wheels.get(node)?.handler(player, value);
|
|
14148
|
-
return;
|
|
14149
|
-
}
|
|
14150
|
-
const changed = screens.get(player.slot)?.changes.get(node);
|
|
14151
|
-
if (changed) {
|
|
14152
|
-
changed.handler(player, value);
|
|
14153
|
-
}
|
|
14154
|
-
}
|
|
14155
|
-
function tick(seconds) {
|
|
14156
|
-
now2 = seconds;
|
|
14157
|
-
for (const current of views.values()) {
|
|
14158
|
-
if (current.notices.length === 0) {
|
|
14159
|
-
continue;
|
|
14160
|
-
}
|
|
14161
|
-
current.notices = current.notices.filter((notice) => notice.until > now2);
|
|
14162
|
-
draw(current.player);
|
|
14163
|
-
}
|
|
14164
|
-
}
|
|
14165
|
-
var views = /* @__PURE__ */ new Map();
|
|
14166
|
-
var now2 = 0;
|
|
14167
|
-
var nextNotice = 0;
|
|
14168
|
-
var maxNotices = 4;
|
|
14169
|
-
var noticeMotion = {
|
|
14170
|
-
enter: { opacity: 0, translate: [-16, 0] },
|
|
14171
|
-
exit: { opacity: 0 },
|
|
14172
|
-
transition: { seconds: 0.25, easing: "out" }
|
|
14173
|
-
};
|
|
14174
|
-
function view(player) {
|
|
14175
|
-
return views.get(player.slot) ?? {
|
|
14176
|
-
player,
|
|
14177
|
-
root: void 0,
|
|
14178
|
-
hud: [],
|
|
14179
|
-
cursor: false,
|
|
14180
|
-
asks: 0,
|
|
14181
|
-
routes: /* @__PURE__ */ new Map(),
|
|
14182
|
-
notices: []
|
|
14183
|
-
};
|
|
14184
|
-
}
|
|
14185
|
-
function draw(player) {
|
|
14186
|
-
const current = view(player);
|
|
14187
|
-
const root = [
|
|
14188
|
-
current.root,
|
|
14189
|
-
current.notices.length !== 0 && notices(current.notices)
|
|
14190
|
-
];
|
|
14191
|
-
const previous = screens.get(player.slot);
|
|
14192
|
-
const hud = current.hud.map((part) => hudParts[part]);
|
|
14193
|
-
const next = render(
|
|
14194
|
-
previous,
|
|
14195
|
-
root,
|
|
14196
|
-
hud,
|
|
14197
|
-
current.cursor,
|
|
14198
|
-
current.asks,
|
|
14199
|
-
current.routes
|
|
14200
|
-
);
|
|
14201
|
-
const change2 = diff(previous, next);
|
|
14202
|
-
if (change2 && !send(player.slot, change2)) {
|
|
14203
|
-
const whole = render(
|
|
14204
|
-
void 0,
|
|
14205
|
-
root,
|
|
14206
|
-
hud,
|
|
14207
|
-
current.cursor,
|
|
14208
|
-
current.asks,
|
|
14209
|
-
current.routes
|
|
14210
|
-
);
|
|
14211
|
-
if (!send(player.slot, diff(void 0, whole))) {
|
|
14212
|
-
screens.delete(player.slot);
|
|
14213
|
-
return false;
|
|
14214
|
-
}
|
|
14215
|
-
screens.set(player.slot, whole);
|
|
14216
|
-
return true;
|
|
14217
|
-
}
|
|
14218
|
-
screens.set(player.slot, next);
|
|
14219
|
-
return true;
|
|
14220
|
-
}
|
|
14221
|
-
function notices(stack) {
|
|
14222
|
-
const style = {
|
|
14223
|
-
width: "fit",
|
|
14224
|
-
height: "fit",
|
|
14225
|
-
flow: "down",
|
|
14226
|
-
horizontalAlign: "left",
|
|
14227
|
-
verticalAlign: "bottom",
|
|
14228
|
-
margin: [0, 0, 260, 24],
|
|
14229
|
-
transition: noticeMotion.transition
|
|
14230
|
-
};
|
|
14231
|
-
const labels = stack.map(
|
|
14232
|
-
(notice) => jsx(
|
|
14233
|
-
"label",
|
|
14234
|
-
{
|
|
14235
|
-
style: {
|
|
14236
|
-
horizontalAlign: "left",
|
|
14237
|
-
margin: [4, 0, 0, 0],
|
|
14238
|
-
padding: [5, 10],
|
|
14239
|
-
background: "#101418d8",
|
|
14240
|
-
color: "#f2f2f2",
|
|
14241
|
-
fontSize: 16,
|
|
14242
|
-
borderRadius: 4,
|
|
14243
|
-
transition: noticeMotion.transition
|
|
14244
|
-
},
|
|
14245
|
-
enter: noticeMotion.enter,
|
|
14246
|
-
exit: noticeMotion.exit,
|
|
14247
|
-
children: notice.text
|
|
14248
|
-
},
|
|
14249
|
-
notice.id
|
|
14250
|
-
)
|
|
14251
|
-
);
|
|
14252
|
-
return jsx("panel", { style, exit: noticeMotion.exit, children: labels });
|
|
14253
|
-
}
|
|
14254
|
-
var screens = /* @__PURE__ */ new Map();
|
|
14255
|
-
function render(previous, root, hud, cursor, asks, routes) {
|
|
14256
|
-
const layout = new Layout(previous);
|
|
14257
|
-
layout.add({
|
|
14258
|
-
id: "",
|
|
14259
|
-
kind: 0 /* PANEL */,
|
|
14260
|
-
children: place(layout, root, "/"),
|
|
14261
|
-
hideHud: [...hud],
|
|
14262
|
-
freeCursor: cursor,
|
|
14263
|
-
freeCursorAsks: asks,
|
|
14264
|
-
sheets: [...sheets]
|
|
14265
|
-
});
|
|
14266
|
-
for (const [name, data] of routes) {
|
|
14267
|
-
layout.add({ id: `route:${name}`, kind: 5 /* ROUTE */, route: name, data });
|
|
14268
|
-
}
|
|
14269
|
-
return layout.screen;
|
|
14270
|
-
}
|
|
14271
|
-
var Layout = class {
|
|
14272
|
-
screen;
|
|
14273
|
-
previous;
|
|
14274
|
-
/** The layout continues previous's id counter and keeps its ids. */
|
|
14275
|
-
constructor(previous) {
|
|
14276
|
-
this.previous = previous;
|
|
14277
|
-
this.screen = {
|
|
14278
|
-
nodes: /* @__PURE__ */ new Map(),
|
|
14279
|
-
ids: /* @__PURE__ */ new Map(),
|
|
14280
|
-
presses: /* @__PURE__ */ new Map(),
|
|
14281
|
-
changes: /* @__PURE__ */ new Map(),
|
|
14282
|
-
wheels: /* @__PURE__ */ new Map(),
|
|
14283
|
-
next: previous?.next ?? 0
|
|
14284
|
-
};
|
|
14285
|
-
}
|
|
14286
|
-
/** add records a node. */
|
|
14287
|
-
add(node) {
|
|
14288
|
-
const value = node.steamId === void 0 ? node : { ...node, steamId: String(node.steamId) };
|
|
14289
|
-
const encoded = JSON.stringify(value);
|
|
14290
|
-
this.screen.nodes.set(node.id, { node, encoded });
|
|
14291
|
-
}
|
|
14292
|
-
/** id returns the node id for the element at place. */
|
|
14293
|
-
id(place2) {
|
|
14294
|
-
let found = this.previous?.ids.get(place2);
|
|
14295
|
-
if (found === void 0) {
|
|
14296
|
-
found = (this.screen.next++).toString(36);
|
|
14297
|
-
}
|
|
14298
|
-
this.screen.ids.set(place2, found);
|
|
14299
|
-
return found;
|
|
14300
|
-
}
|
|
14301
|
-
};
|
|
14302
|
-
function place(layout, child, at2) {
|
|
14303
|
-
if (child === null || child === void 0 || typeof child === "boolean") {
|
|
14304
|
-
return [];
|
|
14305
|
-
}
|
|
14306
|
-
if (isList(child)) {
|
|
14307
|
-
return child.flatMap((item2, index) => {
|
|
14308
|
-
const key = isElement(item2) ? item2.key : void 0;
|
|
14309
|
-
return place(
|
|
14310
|
-
layout,
|
|
14311
|
-
item2,
|
|
14312
|
-
key === void 0 ? `${at2},${index}` : `${at2},=${key}`
|
|
14313
|
-
);
|
|
14314
|
-
});
|
|
14315
|
-
}
|
|
14316
|
-
if (!isElement(child)) {
|
|
14317
|
-
const node2 = {
|
|
14318
|
-
id: layout.id(at2),
|
|
14319
|
-
kind: 1 /* LABEL */,
|
|
14320
|
-
text: String(child)
|
|
14321
|
-
};
|
|
14322
|
-
layout.add(node2);
|
|
14323
|
-
return [node2.id];
|
|
14324
|
-
}
|
|
14325
|
-
if (child.type === fragment) {
|
|
14326
|
-
return place(layout, child.props.children, `${at2}>`);
|
|
14327
|
-
}
|
|
14328
|
-
const props = child.props;
|
|
14329
|
-
const node = {
|
|
14330
|
-
id: layout.id(at2),
|
|
14331
|
-
style: wireStyle(props.style),
|
|
14332
|
-
hover: wireStyle(props.hover),
|
|
14333
|
-
tooltip: props.tooltip,
|
|
14334
|
-
item: props.item ? itemId(props.item) : void 0,
|
|
14335
|
-
hoverSound: props.hoverSound,
|
|
14336
|
-
enter: wireStyle(props.enter),
|
|
14337
|
-
exit: wireStyle(props.exit),
|
|
14338
|
-
cycle: cycle(props.cycle),
|
|
14339
|
-
classes: classes(props.class)
|
|
14340
|
-
};
|
|
14341
|
-
switch (child.type) {
|
|
14342
|
-
case "label":
|
|
14343
|
-
node.kind = 1 /* LABEL */;
|
|
14344
|
-
node.text = text(props.children);
|
|
14345
|
-
node.token = props.token;
|
|
14346
|
-
node.variables = variables(props.variables);
|
|
14347
|
-
break;
|
|
14348
|
-
case "avatar":
|
|
14349
|
-
node.kind = 8 /* AVATAR */;
|
|
14350
|
-
node.steamId = props.steamId;
|
|
14351
|
-
break;
|
|
14352
|
-
case "entry":
|
|
14353
|
-
case "slider":
|
|
14354
|
-
case "toggle":
|
|
14355
|
-
case "dropdown":
|
|
14356
|
-
input(layout, node, child.type, props);
|
|
14357
|
-
break;
|
|
14358
|
-
case "image":
|
|
14359
|
-
node.kind = 2 /* IMAGE */;
|
|
14360
|
-
node.image = props.src ?? "";
|
|
14361
|
-
node.scaling = scaling(props.scaling);
|
|
14362
|
-
break;
|
|
14363
|
-
case "hero":
|
|
14364
|
-
node.kind = 6 /* HERO_IMAGE */;
|
|
14365
|
-
node.hero = props.hero;
|
|
14366
|
-
node.heroLook = props.look === void 0 ? void 0 : looks[props.look];
|
|
14367
|
-
node.scaling = scaling(props.scaling);
|
|
14368
|
-
break;
|
|
14369
|
-
case "button":
|
|
14370
|
-
node.kind = 3 /* BUTTON */;
|
|
14371
|
-
node.sound = props.sound;
|
|
14372
|
-
node.disabled = props.disabled;
|
|
14373
|
-
if (props.onPress && !props.disabled) {
|
|
14374
|
-
layout.screen.presses.set(node.id, { handler: props.onPress });
|
|
14375
|
-
}
|
|
14376
|
-
node.children = place(layout, props.children, `${at2}/`);
|
|
14377
|
-
break;
|
|
14378
|
-
case "layout":
|
|
14379
|
-
node.kind = 4 /* LAYOUT */;
|
|
14380
|
-
node.layout = props.src ?? "";
|
|
14381
|
-
node.data = props.data === void 0 ? "" : JSON.stringify(props.data) ?? "";
|
|
14382
|
-
break;
|
|
14383
|
-
default:
|
|
14384
|
-
node.kind = 0 /* PANEL */;
|
|
14385
|
-
node.children = place(layout, props.children, `${at2}/`);
|
|
14386
|
-
}
|
|
14387
|
-
layout.add(node);
|
|
14388
|
-
return [node.id];
|
|
14389
|
-
}
|
|
14390
|
-
function classes(names) {
|
|
14391
|
-
const list = (names ?? "").split(" ").filter((name) => name !== "");
|
|
14392
|
-
return list.length === 0 ? void 0 : list;
|
|
14393
|
-
}
|
|
14394
|
-
function input(layout, node, kind, props) {
|
|
14395
|
-
node.kind = 7 /* INPUT */;
|
|
14396
|
-
node.disabled = props.disabled;
|
|
14397
|
-
if (props.onChange && !props.disabled) {
|
|
14398
|
-
layout.screen.changes.set(node.id, { handler: props.onChange });
|
|
14399
|
-
}
|
|
14400
|
-
switch (kind) {
|
|
14401
|
-
case "entry":
|
|
14402
|
-
node.input = {
|
|
14403
|
-
case: "textEntry",
|
|
14404
|
-
value: {
|
|
14405
|
-
text: String(props.value ?? ""),
|
|
14406
|
-
placeholder: props.placeholder,
|
|
14407
|
-
maxLength: props.maxLength
|
|
14408
|
-
}
|
|
14409
|
-
};
|
|
14410
|
-
break;
|
|
14411
|
-
case "slider":
|
|
14412
|
-
if (props.onWheel && !props.disabled) {
|
|
14413
|
-
layout.screen.wheels.set(node.id, { handler: props.onWheel });
|
|
14414
|
-
}
|
|
14415
|
-
node.input = {
|
|
14416
|
-
case: "slider",
|
|
14417
|
-
value: {
|
|
14418
|
-
value: Number(props.value ?? 0),
|
|
14419
|
-
min: props.min,
|
|
14420
|
-
max: props.max,
|
|
14421
|
-
step: props.step,
|
|
14422
|
-
wheel: !!props.onWheel && !props.disabled
|
|
14423
|
-
}
|
|
14424
|
-
};
|
|
14425
|
-
break;
|
|
14426
|
-
case "toggle":
|
|
14427
|
-
node.text = text(props.children);
|
|
14428
|
-
node.input = { case: "toggle", value: { on: props.on } };
|
|
14429
|
-
break;
|
|
14430
|
-
case "dropdown":
|
|
14431
|
-
node.input = {
|
|
14432
|
-
case: "dropdown",
|
|
14433
|
-
value: {
|
|
14434
|
-
options: [...props.options ?? []],
|
|
14435
|
-
selected: props.selected
|
|
14436
|
-
}
|
|
14437
|
-
};
|
|
14438
|
-
}
|
|
14439
|
-
}
|
|
14440
|
-
function variables(value) {
|
|
14441
|
-
if (!value) {
|
|
14442
|
-
return void 0;
|
|
14443
|
-
}
|
|
14444
|
-
const encoded = {};
|
|
14445
|
-
for (const [name, filled] of Object.entries(value)) {
|
|
14446
|
-
encoded[name] = String(filled);
|
|
14447
|
-
}
|
|
14448
|
-
return encoded;
|
|
14449
|
-
}
|
|
14450
|
-
function cycle(value) {
|
|
14451
|
-
if (!value) {
|
|
14452
|
-
return void 0;
|
|
14453
|
-
}
|
|
14454
|
-
return {
|
|
14455
|
-
style: wireStyle(value.style),
|
|
14456
|
-
seconds: value.seconds,
|
|
14457
|
-
count: value.count
|
|
14458
|
-
};
|
|
14459
|
-
}
|
|
14460
|
-
function diff(previous, next) {
|
|
14461
|
-
const set = [...next.nodes.values()].filter(
|
|
14462
|
-
({ node, encoded }) => previous?.nodes.get(node.id)?.encoded !== encoded
|
|
14463
|
-
).map(({ node }) => node);
|
|
14464
|
-
const removed = [...previous?.nodes.keys() ?? []].filter(
|
|
14465
|
-
(id) => !next.nodes.has(id)
|
|
14466
|
-
);
|
|
14467
|
-
if (previous && set.length === 0 && removed.length === 0) {
|
|
14468
|
-
return void 0;
|
|
14469
|
-
}
|
|
14470
|
-
return { reset: !previous, set, removed };
|
|
14471
|
-
}
|
|
14472
|
-
function send(slot, change2) {
|
|
14473
|
-
return call("Ui", UiRequest.toBinary({ player: slot, change: change2 })) !== void 0;
|
|
14474
|
-
}
|
|
14475
|
-
function isElement(child) {
|
|
14476
|
-
return typeof child === "object" && child !== null && !Array.isArray(child);
|
|
14477
|
-
}
|
|
14478
|
-
function isList(child) {
|
|
14479
|
-
return Array.isArray(child);
|
|
14480
|
-
}
|
|
14481
|
-
function text(children) {
|
|
14482
|
-
if (children === null || children === void 0 || typeof children === "boolean") {
|
|
14483
|
-
return "";
|
|
14484
|
-
}
|
|
14485
|
-
if (isList(children)) {
|
|
14486
|
-
return children.map(text).join("");
|
|
14487
|
-
}
|
|
14488
|
-
return isElement(children) ? "" : String(children);
|
|
14489
|
-
}
|
|
14490
|
-
var aligns = {
|
|
14491
|
-
left: 0 /* START */,
|
|
14492
|
-
top: 0 /* START */,
|
|
14493
|
-
center: 1 /* CENTER */,
|
|
14494
|
-
right: 2 /* END */,
|
|
14495
|
-
bottom: 2 /* END */
|
|
14496
|
-
};
|
|
14497
|
-
function align(value) {
|
|
14498
|
-
return value === void 0 ? void 0 : aligns[value];
|
|
14499
|
-
}
|
|
14500
|
-
var hudParts = {
|
|
14501
|
-
levelUp: 1 /* LEVEL_UP */,
|
|
14502
|
-
ownHealth: 2 /* OWN_HEALTH */,
|
|
14503
|
-
topBar: 3 /* TOP_BAR */,
|
|
14504
|
-
ammo: 4 /* AMMO */,
|
|
14505
|
-
souls: 5 /* SOULS */,
|
|
14506
|
-
minimap: 6 /* MINIMAP */,
|
|
14507
|
-
abilities: 7 /* ABILITIES */,
|
|
14508
|
-
status: 8 /* STATUS */,
|
|
14509
|
-
stats: 9 /* STATS */
|
|
14510
|
-
};
|
|
14511
|
-
var faces = {
|
|
14512
|
-
body: 1 /* BODY */,
|
|
14513
|
-
block: 2 /* BLOCK */,
|
|
14514
|
-
serif: 3 /* SERIF */
|
|
14515
|
-
};
|
|
14516
|
-
var looks = {
|
|
14517
|
-
small: 0 /* SMALL */,
|
|
14518
|
-
card: 1 /* CARD */,
|
|
14519
|
-
icon: 2 /* ICON */,
|
|
14520
|
-
vertical: 3 /* VERTICAL */,
|
|
14521
|
-
topBar: 4 /* TOP_BAR */,
|
|
14522
|
-
minimap: 5 /* MINIMAP */
|
|
14523
|
-
};
|
|
14524
|
-
var scalings = {
|
|
14525
|
-
fit: 1 /* FIT */,
|
|
14526
|
-
cover: 2 /* COVER */,
|
|
14527
|
-
stretch: 3 /* STRETCH */,
|
|
14528
|
-
fitWidth: 4 /* FIT_WIDTH */,
|
|
14529
|
-
fitHeight: 5 /* FIT_HEIGHT */,
|
|
14530
|
-
none: 6 /* NONE */
|
|
14531
|
-
};
|
|
14532
|
-
function scaling(value) {
|
|
14533
|
-
return value === void 0 ? void 0 : scalings[value];
|
|
14534
|
-
}
|
|
14535
|
-
var flows = {
|
|
14536
|
-
down: 1 /* DOWN */,
|
|
14537
|
-
right: 2 /* RIGHT */,
|
|
14538
|
-
downWrap: 3 /* DOWN_WRAP */,
|
|
14539
|
-
rightWrap: 4 /* RIGHT_WRAP */
|
|
14540
|
-
};
|
|
14541
|
-
var overflows = {
|
|
14542
|
-
squish: 1 /* SQUISH */,
|
|
14543
|
-
clip: 2 /* CLIP */,
|
|
14544
|
-
scroll: 3 /* SCROLL */,
|
|
14545
|
-
show: 4 /* SHOW */
|
|
14546
|
-
};
|
|
14547
|
-
function overflow(value) {
|
|
14548
|
-
return value === void 0 ? void 0 : overflows[value];
|
|
14549
|
-
}
|
|
14550
|
-
var shapes = {
|
|
14551
|
-
down: 0 /* DOWN */,
|
|
14552
|
-
right: 1 /* RIGHT */,
|
|
14553
|
-
up: 2 /* UP */,
|
|
14554
|
-
left: 3 /* LEFT */,
|
|
14555
|
-
radial: 4 /* RADIAL */
|
|
14556
|
-
};
|
|
14557
|
-
var weights = {
|
|
14558
|
-
thin: 1 /* THIN */,
|
|
14559
|
-
light: 2 /* LIGHT */,
|
|
14560
|
-
normal: 3 /* NORMAL */,
|
|
14561
|
-
medium: 4 /* MEDIUM */,
|
|
14562
|
-
semiBold: 5 /* SEMI_BOLD */,
|
|
14563
|
-
bold: 6 /* BOLD */,
|
|
14564
|
-
black: 7 /* BLACK */
|
|
14565
|
-
};
|
|
14566
|
-
var textOverflows = {
|
|
14567
|
-
ellipsis: 1 /* ELLIPSIS */,
|
|
14568
|
-
shrink: 2 /* SHRINK */,
|
|
14569
|
-
clip: 3 /* CLIP */
|
|
14570
|
-
};
|
|
14571
|
-
var decorations = {
|
|
14572
|
-
underline: 1 /* UNDERLINE */,
|
|
14573
|
-
strike: 2 /* STRIKE */
|
|
14574
|
-
};
|
|
14575
|
-
var easings = {
|
|
14576
|
-
out: 0 /* EASE_OUT */,
|
|
14577
|
-
in: 1 /* EASE_IN */,
|
|
14578
|
-
inOut: 2 /* EASE_IN_OUT */,
|
|
14579
|
-
linear: 3 /* LINEAR */
|
|
14580
|
-
};
|
|
14581
|
-
function wireStyle(style) {
|
|
14582
|
-
if (!style) {
|
|
14583
|
-
return void 0;
|
|
14584
|
-
}
|
|
14585
|
-
return {
|
|
14586
|
-
width: length(style.width),
|
|
14587
|
-
height: length(style.height),
|
|
14588
|
-
flow: style.flow === void 0 ? void 0 : flows[style.flow],
|
|
14589
|
-
horizontalAlign: align(style.horizontalAlign),
|
|
14590
|
-
verticalAlign: align(style.verticalAlign),
|
|
14591
|
-
margin: edges(style.margin),
|
|
14592
|
-
padding: edges(style.padding),
|
|
14593
|
-
background: color(style.background),
|
|
14594
|
-
color: color(style.color),
|
|
14595
|
-
fontSize: style.fontSize,
|
|
14596
|
-
bold: style.bold,
|
|
14597
|
-
textAlign: align(style.textAlign),
|
|
14598
|
-
borderRadius: style.borderRadius,
|
|
14599
|
-
opacity: style.opacity,
|
|
14600
|
-
face: style.face === void 0 ? void 0 : faces[style.face],
|
|
14601
|
-
uppercase: style.uppercase,
|
|
14602
|
-
letterSpacing: style.letterSpacing,
|
|
14603
|
-
shadow: style.shadow,
|
|
14604
|
-
borderWidth: style.borderWidth,
|
|
14605
|
-
borderColor: color(style.borderColor),
|
|
14606
|
-
x: length(style.x),
|
|
14607
|
-
y: length(style.y),
|
|
14608
|
-
minWidth: length(style.minWidth),
|
|
14609
|
-
maxWidth: length(style.maxWidth),
|
|
14610
|
-
minHeight: length(style.minHeight),
|
|
14611
|
-
maxHeight: length(style.maxHeight),
|
|
14612
|
-
zIndex: style.zIndex,
|
|
14613
|
-
overflowX: overflow(style.overflowX ?? style.overflow),
|
|
14614
|
-
overflowY: overflow(style.overflowY ?? style.overflow),
|
|
14615
|
-
gradient: gradient(style.gradient),
|
|
14616
|
-
boxShadow: shadow(style.boxShadow),
|
|
14617
|
-
textShadow: shadow(style.textShadow),
|
|
14618
|
-
tint: color(style.tint),
|
|
14619
|
-
saturation: style.saturation,
|
|
14620
|
-
brightness: style.brightness,
|
|
14621
|
-
contrast: style.contrast,
|
|
14622
|
-
blur: style.blur,
|
|
14623
|
-
italic: style.italic,
|
|
14624
|
-
weight: style.weight === void 0 ? void 0 : weights[style.weight],
|
|
14625
|
-
lineHeight: style.lineHeight,
|
|
14626
|
-
noWrap: style.noWrap,
|
|
14627
|
-
textOverflow: style.textOverflow === void 0 ? void 0 : textOverflows[style.textOverflow],
|
|
14628
|
-
decoration: style.decoration === void 0 ? void 0 : decorations[style.decoration],
|
|
14629
|
-
transform: transform(style),
|
|
14630
|
-
transition: transition(style.transition)
|
|
14631
|
-
};
|
|
14632
|
-
}
|
|
14633
|
-
function gradient(value) {
|
|
14634
|
-
if (!value) {
|
|
14635
|
-
return void 0;
|
|
14636
|
-
}
|
|
14637
|
-
const last = Math.max(1, value.colors.length - 1);
|
|
14638
|
-
return {
|
|
14639
|
-
shape: value.shape === void 0 ? void 0 : shapes[value.shape],
|
|
14640
|
-
stops: value.colors.map((each, index) => ({
|
|
14641
|
-
at: value.at?.[index] ?? index / last,
|
|
14642
|
-
color: color(each)
|
|
14643
|
-
}))
|
|
14644
|
-
};
|
|
14645
|
-
}
|
|
14646
|
-
function shadow(value) {
|
|
14647
|
-
if (!value) {
|
|
14648
|
-
return void 0;
|
|
14649
|
-
}
|
|
14650
|
-
return {
|
|
14651
|
-
x: value.x,
|
|
14652
|
-
y: value.y,
|
|
14653
|
-
blur: value.blur,
|
|
14654
|
-
spread: value.spread,
|
|
14655
|
-
color: color(value.color),
|
|
14656
|
-
inset: value.inset
|
|
14657
|
-
};
|
|
14658
|
-
}
|
|
14659
|
-
function transform(style) {
|
|
14660
|
-
const { translate, scale: scale2, rotate, origin } = style;
|
|
14661
|
-
if (!translate && scale2 === void 0 && rotate === void 0 && !origin) {
|
|
14662
|
-
return void 0;
|
|
14663
|
-
}
|
|
14664
|
-
const scales = typeof scale2 === "number" ? [scale2, scale2] : scale2;
|
|
14665
|
-
return {
|
|
14666
|
-
translateX: translate?.[0],
|
|
14667
|
-
translateY: translate?.[1],
|
|
14668
|
-
scaleX: scales?.[0],
|
|
14669
|
-
scaleY: scales?.[1],
|
|
14670
|
-
rotate,
|
|
14671
|
-
originX: origin?.[0],
|
|
14672
|
-
originY: origin?.[1]
|
|
14673
|
-
};
|
|
14674
|
-
}
|
|
14675
|
-
function transition(value) {
|
|
14676
|
-
if (value === void 0) {
|
|
14677
|
-
return void 0;
|
|
14678
|
-
}
|
|
14679
|
-
if (typeof value === "number") {
|
|
14680
|
-
return { seconds: value };
|
|
14681
|
-
}
|
|
14682
|
-
return {
|
|
14683
|
-
seconds: value.seconds,
|
|
14684
|
-
delay: value.delay,
|
|
14685
|
-
easing: value.easing === void 0 ? void 0 : easings[value.easing]
|
|
14686
|
-
};
|
|
14687
|
-
}
|
|
14688
|
-
function length(value) {
|
|
14689
|
-
if (value === void 0) {
|
|
14690
|
-
return void 0;
|
|
14691
|
-
}
|
|
14692
|
-
if (typeof value === "number") {
|
|
14693
|
-
return { value: { case: "pixels", value } };
|
|
14694
|
-
}
|
|
14695
|
-
if (value === "fit") {
|
|
14696
|
-
return { value: { case: "fitChildren", value: true } };
|
|
14697
|
-
}
|
|
14698
|
-
if (value === "fill") {
|
|
14699
|
-
return { value: { case: "fill", value: 1 } };
|
|
14700
|
-
}
|
|
14701
|
-
return { value: { case: "percent", value: Number.parseFloat(value) } };
|
|
14702
|
-
}
|
|
14703
|
-
function edges(value) {
|
|
14704
|
-
if (value === void 0) {
|
|
14705
|
-
return void 0;
|
|
14706
|
-
}
|
|
14707
|
-
if (typeof value === "number") {
|
|
14708
|
-
return { top: value, right: value, bottom: value, left: value };
|
|
14709
|
-
}
|
|
14710
|
-
if (value.length === 2) {
|
|
14711
|
-
return { top: value[0], right: value[1], bottom: value[0], left: value[1] };
|
|
14712
|
-
}
|
|
14713
|
-
return { top: value[0], right: value[1], bottom: value[2], left: value[3] };
|
|
14714
|
-
}
|
|
14715
|
-
function color(value) {
|
|
14716
|
-
const hex = value?.replace(/^#/, "");
|
|
14717
|
-
if (!hex || !/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {
|
|
14718
|
-
return void 0;
|
|
14719
|
-
}
|
|
14720
|
-
return Number.parseInt(hex.length === 6 ? `${hex}ff` : hex, 16) >>> 0;
|
|
14721
|
-
}
|
|
14722
|
-
|
|
14723
|
-
// js/src/vector.ts
|
|
14724
|
-
var vector_exports = {};
|
|
14725
|
-
__export(vector_exports, {
|
|
14726
|
-
add: () => add,
|
|
14727
|
-
aimAt: () => aimAt,
|
|
14728
|
-
at: () => at,
|
|
14729
|
-
distance: () => distance,
|
|
14730
|
-
dot: () => dot,
|
|
14731
|
-
flatDistance: () => flatDistance,
|
|
14732
|
-
forward: () => forward,
|
|
14733
|
-
length: () => length2,
|
|
14734
|
-
lerp: () => lerp2,
|
|
14735
|
-
level: () => level,
|
|
14736
|
-
normalize: () => normalize,
|
|
14737
|
-
scale: () => scale,
|
|
14738
|
-
sub: () => sub,
|
|
14739
|
-
toward: () => toward,
|
|
14740
|
-
yawToward: () => yawToward
|
|
14741
|
-
});
|
|
14742
|
-
function at(x, y, z) {
|
|
14743
|
-
return { x, y, z };
|
|
14744
|
-
}
|
|
14745
|
-
function add(a, b) {
|
|
14746
|
-
return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
|
|
14747
|
-
}
|
|
14748
|
-
function sub(a, b) {
|
|
14749
|
-
return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
|
|
14750
|
-
}
|
|
14751
|
-
function scale(a, s) {
|
|
14752
|
-
return { x: a.x * s, y: a.y * s, z: a.z * s };
|
|
14753
|
-
}
|
|
14754
|
-
function dot(a, b) {
|
|
14755
|
-
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
14756
|
-
}
|
|
14757
|
-
function length2(a) {
|
|
14758
|
-
return Math.hypot(a.x, a.y, a.z);
|
|
14759
|
-
}
|
|
14760
|
-
function normalize(a) {
|
|
14761
|
-
const size = length2(a);
|
|
14762
|
-
return size > 0 ? scale(a, 1 / size) : { x: 1, y: 0, z: 0 };
|
|
14763
|
-
}
|
|
14764
|
-
function lerp2(a, b, t) {
|
|
14765
|
-
return {
|
|
14766
|
-
x: a.x + (b.x - a.x) * t,
|
|
14767
|
-
y: a.y + (b.y - a.y) * t,
|
|
14768
|
-
z: a.z + (b.z - a.z) * t
|
|
14769
|
-
};
|
|
14770
|
-
}
|
|
14771
|
-
function distance(a, b) {
|
|
14772
|
-
return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);
|
|
14773
|
-
}
|
|
14774
|
-
function flatDistance(a, b) {
|
|
14775
|
-
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
14776
|
-
}
|
|
14777
|
-
function toward(from, to) {
|
|
14778
|
-
const span = distance(from, to);
|
|
14779
|
-
return span > 0 ? scale(sub(to, from), 1 / span) : { x: 0, y: 0, z: 0 };
|
|
14780
|
-
}
|
|
14781
|
-
function yawToward(from, to) {
|
|
14782
|
-
return Math.atan2(to.y - from.y, to.x - from.x) * 180 / Math.PI;
|
|
14783
|
-
}
|
|
14784
|
-
function level(yaw) {
|
|
14785
|
-
return { pitch: 0, yaw, roll: 0 };
|
|
14786
|
-
}
|
|
14787
|
-
function aimAt(from, to) {
|
|
14788
|
-
const across = flatDistance(from, to);
|
|
14789
|
-
return {
|
|
14790
|
-
pitch: -Math.atan2(to.z - from.z, across) * 180 / Math.PI,
|
|
14791
|
-
yaw: yawToward(from, to),
|
|
14792
|
-
roll: 0
|
|
14793
|
-
};
|
|
14794
|
-
}
|
|
14795
|
-
function forward(angles2) {
|
|
14796
|
-
const pitch = angles2.pitch * Math.PI / 180;
|
|
14797
|
-
const yaw = angles2.yaw * Math.PI / 180;
|
|
14798
|
-
return {
|
|
14799
|
-
x: Math.cos(pitch) * Math.cos(yaw),
|
|
14800
|
-
y: Math.cos(pitch) * Math.sin(yaw),
|
|
14801
|
-
z: -Math.sin(pitch)
|
|
14802
|
-
};
|
|
14803
|
-
}
|
|
14804
|
-
|
|
14805
|
-
// js/src/bits.ts
|
|
14806
|
-
var Buttons = {
|
|
14807
|
-
/** attack is the primary fire button. */
|
|
14808
|
-
attack: 1n,
|
|
14809
|
-
/**
|
|
14810
|
-
* jump is the jump key, Space by default (IN_MANTLE). Blocking it stops the
|
|
14811
|
-
* native jump and mantle; the jumping client still predicts the jump and is
|
|
14812
|
-
* corrected.
|
|
14813
|
-
*/
|
|
14814
|
-
jump: 1n << 48n,
|
|
14815
|
-
/** crouch is the crouch key, Ctrl by default. */
|
|
14816
|
-
crouch: 1n << 2n,
|
|
14817
|
-
/** dash is the dash key, Shift by default. */
|
|
14818
|
-
dash: 1n << 16n,
|
|
14819
|
-
/** use is the interact key. */
|
|
14820
|
-
use: 1n << 5n,
|
|
14821
|
-
/** altFire is the zoom and alternate fire button, right mouse by default. */
|
|
14822
|
-
altFire: 1n << 11n,
|
|
14823
|
-
/** reload is the reload key. */
|
|
14824
|
-
reload: 1n << 13n,
|
|
14825
|
-
/** melee is the light melee key, Q by default. */
|
|
14826
|
-
melee: 1n << 32n,
|
|
14827
|
-
/** ability1 to ability3 are the hero's first three ability keys. */
|
|
14828
|
-
ability1: 1n << 33n,
|
|
14829
|
-
ability2: 1n << 34n,
|
|
14830
|
-
ability3: 1n << 35n,
|
|
14831
|
-
/** ultimate is the hero's ultimate ability key, the fourth. */
|
|
14832
|
-
ultimate: 1n << 36n,
|
|
14833
|
-
/** parry is the melee parry button. */
|
|
14834
|
-
parry: 1n << 42n
|
|
14835
|
-
};
|
|
14836
|
-
var Layers = {
|
|
14837
|
-
/** solid is the world and solid objects. */
|
|
14838
|
-
solid: 1n << 0n,
|
|
14839
|
-
/** hitbox is the hit boxes of heroes and units. */
|
|
14840
|
-
hitbox: 1n << 1n,
|
|
14841
|
-
/** trigger is invisible volumes that react to touch. */
|
|
14842
|
-
trigger: 1n << 2n,
|
|
14843
|
-
/** playerClip is walls that only stop heroes. */
|
|
14844
|
-
playerClip: 1n << 4n,
|
|
14845
|
-
/** player is player-controlled heroes. */
|
|
14846
|
-
player: 1n << 18n,
|
|
14847
|
-
/** npc is units that are not players. */
|
|
14848
|
-
npc: 1n << 19n,
|
|
14849
|
-
/** staticLevel is the map's built geometry, foliage included. */
|
|
14850
|
-
staticLevel: 1n << 30n,
|
|
14851
|
-
/** hero, trooper and building are those units' bodies. */
|
|
14852
|
-
hero: 1n << 37n,
|
|
14853
|
-
trooper: 1n << 38n,
|
|
14854
|
-
building: 1n << 40n
|
|
14855
|
-
};
|
|
14856
|
-
|
|
14857
|
-
// js/src/curve.ts
|
|
14858
|
-
var curve_exports = {};
|
|
14859
|
-
__export(curve_exports, {
|
|
14860
|
-
chain: () => chain,
|
|
14861
|
-
durationOf: () => durationOf,
|
|
14862
|
-
ease: () => ease,
|
|
14863
|
-
hold: () => hold,
|
|
14864
|
-
keyframes: () => keyframes,
|
|
14865
|
-
line: () => line,
|
|
14866
|
-
orbit: () => orbit,
|
|
14867
|
-
pingPong: () => pingPong,
|
|
14868
|
-
repeat: () => repeat,
|
|
14869
|
-
reverse: () => reverse,
|
|
14870
|
-
shaped: () => shaped,
|
|
14871
|
-
through: () => through,
|
|
14872
|
-
valueAt: () => valueAt,
|
|
14873
|
-
wave: () => wave
|
|
14874
|
-
});
|
|
14875
|
-
var ease = {
|
|
14876
|
-
/** linear moves at an even pace. */
|
|
14877
|
-
linear: shaped((t) => t, {}),
|
|
14878
|
-
/** bias is the game's bias curve; see LerpShape. */
|
|
14879
|
-
bias: (b) => shaped((t) => bias(t, b), { bias: b }),
|
|
14880
|
-
/** gain is the game's gain curve; see LerpShape. */
|
|
14881
|
-
gain: (g) => shaped((t) => gain(t, g), { gain: g }),
|
|
14882
|
-
/** in starts slow and speeds up. */
|
|
14883
|
-
in: shaped((t) => t * t * t),
|
|
14884
|
-
/** out starts fast and slows to a stop. */
|
|
14885
|
-
out: shaped((t) => 1 - (1 - t) ** 3),
|
|
14886
|
-
/** inOut starts and ends slow. */
|
|
14887
|
-
inOut: shaped((t) => t < 0.5 ? 4 * t * t * t : 1 - (2 - 2 * t) ** 3 / 2),
|
|
14888
|
-
/** sine starts and ends slow, more gently than inOut. */
|
|
14889
|
-
sine: shaped((t) => (1 - Math.cos(Math.PI * t)) / 2),
|
|
14890
|
-
/** back passes its end a little and settles back onto it. */
|
|
14891
|
-
back: shaped((t) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2),
|
|
14892
|
-
/** elastic overshoots its end and rings down onto it. */
|
|
14893
|
-
elastic: shaped(
|
|
14894
|
-
(t) => t <= 0 || t >= 1 ? t : 2 ** (-10 * t) * Math.sin((t * 10 - 0.75) * 2 * Math.PI / 3) + 1
|
|
14895
|
-
),
|
|
14896
|
-
/** bounce drops onto its end and bounces to rest. */
|
|
14897
|
-
bounce: shaped((t) => {
|
|
14898
|
-
const k = 7.5625;
|
|
14899
|
-
if (t < 1 / 2.75) return k * t * t;
|
|
14900
|
-
if (t < 2 / 2.75) return k * (t - 1.5 / 2.75) ** 2 + 0.75;
|
|
14901
|
-
if (t < 2.5 / 2.75) return k * (t - 2.25 / 2.75) ** 2 + 0.9375;
|
|
14902
|
-
return k * (t - 2.625 / 2.75) ** 2 + 0.984375;
|
|
14903
|
-
})
|
|
14904
|
-
};
|
|
14905
|
-
function shaped(at2, lerp3) {
|
|
14906
|
-
return { at: at2, lerp: lerp3 };
|
|
14907
|
-
}
|
|
14908
|
-
function line(from, to, duration, shape = ease.linear) {
|
|
14909
|
-
return [{ duration, lerp: shape.lerp, at: (u) => mix(from, to, shape.at(u)) }];
|
|
14910
|
-
}
|
|
14911
|
-
function hold(value, duration) {
|
|
14912
|
-
return [{ duration, lerp: {}, at: () => value }];
|
|
14913
|
-
}
|
|
14914
|
-
function keyframes(keys, options = {}) {
|
|
14915
|
-
const spans = [];
|
|
14916
|
-
const [first] = keys;
|
|
14917
|
-
if (first && first.at > 0) spans.push(...hold(first.value, first.at));
|
|
14918
|
-
keys.forEach((to, i) => {
|
|
14919
|
-
const from = keys[i - 1];
|
|
14920
|
-
if (!from || to.at <= from.at) return;
|
|
14921
|
-
const duration = to.at - from.at;
|
|
14922
|
-
const shape = to.ease ?? ease.linear;
|
|
14923
|
-
if (!options.smooth) {
|
|
14924
|
-
spans.push(...line(from.value, to.value, duration, shape));
|
|
14925
|
-
return;
|
|
14926
|
-
}
|
|
14927
|
-
const before = keys[i - 2]?.value ?? from.value;
|
|
14928
|
-
const after2 = keys[i + 1]?.value ?? to.value;
|
|
14929
|
-
spans.push({
|
|
14930
|
-
duration,
|
|
14931
|
-
at: (u) => spline(before, from.value, to.value, after2, shape.at(u))
|
|
14932
|
-
});
|
|
14933
|
-
});
|
|
14934
|
-
return spans;
|
|
14935
|
-
}
|
|
14936
|
-
function through(points, options) {
|
|
14937
|
-
let at2 = 0;
|
|
14938
|
-
let last = points[0];
|
|
14939
|
-
const keys = points.map((value) => {
|
|
14940
|
-
if (last !== void 0) at2 += distance2(last, value) / options.speed;
|
|
14941
|
-
last = value;
|
|
14942
|
-
return { at: at2, value, ease: options.ease };
|
|
14943
|
-
});
|
|
14944
|
-
return keyframes(keys, options);
|
|
14945
|
-
}
|
|
14946
|
-
function orbit(options) {
|
|
14947
|
-
const { center, radius, duration } = options;
|
|
14948
|
-
const turns = options.turns ?? 1;
|
|
14949
|
-
const start = (options.start ?? 0) * Math.PI / 180;
|
|
14950
|
-
const rise = options.rise ?? 0;
|
|
14951
|
-
const shape = options.ease ?? ease.linear;
|
|
14952
|
-
return [
|
|
14953
|
-
{
|
|
14954
|
-
duration,
|
|
14955
|
-
at: (u) => {
|
|
14956
|
-
const t = shape.at(u);
|
|
14957
|
-
const angle = start + t * turns * 2 * Math.PI;
|
|
14958
|
-
return {
|
|
14959
|
-
x: center.x + radius * Math.cos(angle),
|
|
14960
|
-
y: center.y + radius * Math.sin(angle),
|
|
14961
|
-
z: center.z + rise * t
|
|
14962
|
-
};
|
|
14963
|
-
}
|
|
14964
|
-
}
|
|
14965
|
-
];
|
|
14966
|
-
}
|
|
14967
|
-
function wave(options) {
|
|
14968
|
-
const { amplitude, frequency, duration, decay } = options;
|
|
14969
|
-
return [
|
|
14970
|
-
{
|
|
14971
|
-
duration,
|
|
14972
|
-
at: (u) => amplitude * (decay ? 1 - u : 1) * Math.sin(2 * Math.PI * frequency * duration * u)
|
|
14973
|
-
}
|
|
14974
|
-
];
|
|
14975
|
-
}
|
|
14976
|
-
function chain(...curves) {
|
|
14977
|
-
return curves.flat();
|
|
14978
|
-
}
|
|
14979
|
-
function reverse(curve) {
|
|
14980
|
-
return curve.map((span) => ({
|
|
14981
|
-
duration: span.duration,
|
|
14982
|
-
lerp: span.lerp?.bias === void 0 ? span.lerp : void 0,
|
|
14983
|
-
at: (u) => span.at(1 - u)
|
|
14984
|
-
})).reverse();
|
|
14985
|
-
}
|
|
14986
|
-
function repeat(curve, times) {
|
|
14987
|
-
return Array.from({ length: Math.max(0, times) }, () => curve).flat();
|
|
14988
|
-
}
|
|
14989
|
-
function pingPong(curve) {
|
|
14990
|
-
return chain(curve, reverse(curve));
|
|
14991
|
-
}
|
|
14992
|
-
function durationOf(curve) {
|
|
14993
|
-
return curve.reduce((sum, span) => sum + Math.max(0, span.duration), 0);
|
|
14994
|
-
}
|
|
14995
|
-
function valueAt(curve, seconds) {
|
|
14996
|
-
let left = seconds;
|
|
14997
|
-
for (const span of curve) {
|
|
14998
|
-
if (span.duration <= 0) continue;
|
|
14999
|
-
if (left <= span.duration) return span.at(Math.max(0, left) / span.duration);
|
|
15000
|
-
left -= span.duration;
|
|
15001
|
-
}
|
|
15002
|
-
return curve.at(-1)?.at(1);
|
|
15003
|
-
}
|
|
15004
|
-
function bias(t, b) {
|
|
15005
|
-
return t ** (Math.log(b) / Math.log(0.5));
|
|
15006
|
-
}
|
|
15007
|
-
function gain(t, g) {
|
|
15008
|
-
return t < 0.5 ? bias(2 * t, 1 - g) / 2 : 1 - bias(2 - 2 * t, 1 - g) / 2;
|
|
15009
|
-
}
|
|
15010
|
-
function mix(a, b, t) {
|
|
15011
|
-
if (typeof a === "number" && typeof b === "number") return a + (b - a) * t;
|
|
15012
|
-
const [p, q] = [vector2(a), vector2(b)];
|
|
15013
|
-
return {
|
|
15014
|
-
x: p.x + (q.x - p.x) * t,
|
|
15015
|
-
y: p.y + (q.y - p.y) * t,
|
|
15016
|
-
z: p.z + (q.z - p.z) * t
|
|
15017
|
-
};
|
|
15018
|
-
}
|
|
15019
|
-
function spline(p0, p1, p2, p3, t) {
|
|
15020
|
-
const f = (a2, b2, c2, d2) => 0.5 * (2 * b2 + (c2 - a2) * t + (2 * a2 - 5 * b2 + 4 * c2 - d2) * t * t + (3 * b2 - a2 - 3 * c2 + d2) * t * t * t);
|
|
15021
|
-
if (typeof p0 === "number" && typeof p1 === "number" && typeof p2 === "number" && typeof p3 === "number") {
|
|
15022
|
-
return f(p0, p1, p2, p3);
|
|
15023
|
-
}
|
|
15024
|
-
const [a, b, c, d] = [vector2(p0), vector2(p1), vector2(p2), vector2(p3)];
|
|
15025
|
-
return {
|
|
15026
|
-
x: f(a.x, b.x, c.x, d.x),
|
|
15027
|
-
y: f(a.y, b.y, c.y, d.y),
|
|
15028
|
-
z: f(a.z, b.z, c.z, d.z)
|
|
15029
|
-
};
|
|
15030
|
-
}
|
|
15031
|
-
function distance2(a, b) {
|
|
15032
|
-
if (typeof a === "number" && typeof b === "number") return Math.abs(b - a);
|
|
15033
|
-
const [p, q] = [vector2(a), vector2(b)];
|
|
15034
|
-
return Math.hypot(q.x - p.x, q.y - p.y, q.z - p.z);
|
|
15035
|
-
}
|
|
15036
|
-
function vector2(value) {
|
|
15037
|
-
return typeof value === "number" ? { x: value, y: 0, z: 0 } : value;
|
|
15038
|
-
}
|
|
15039
|
-
|
|
15040
|
-
// js/src/camera.ts
|
|
15041
|
-
function setOrbitCamera(player, enabled) {
|
|
15042
|
-
const pawn = player.pawn();
|
|
15043
|
-
if (!pawn?.entity) return false;
|
|
15044
|
-
const flag = writeField(
|
|
15045
|
-
pawn.entity,
|
|
15046
|
-
"CCitadelPlayerPawn",
|
|
15047
|
-
"m_bInHideoutZone",
|
|
15048
|
-
"bool",
|
|
15049
|
-
enabled
|
|
15050
|
-
);
|
|
15051
|
-
const zoom = holdModifierState(
|
|
15052
|
-
pawn.entity,
|
|
15053
|
-
"MODIFIER_STATE_HIDEOUT_ZONE",
|
|
15054
|
-
enabled
|
|
15055
|
-
);
|
|
15056
|
-
if (enabled) return flag && zoom;
|
|
15057
|
-
const orbit2 = fireInput(pawn.entity, "RemoveModifier", {
|
|
15058
|
-
text: "modifier_citadel_orbit_camera"
|
|
15059
|
-
});
|
|
15060
|
-
return flag && zoom && orbit2;
|
|
15061
|
-
}
|
|
15062
|
-
var moves = 0;
|
|
15063
|
-
function playCamera(player, options) {
|
|
15064
|
-
const tracks = [];
|
|
15065
|
-
for (const [param, curve] of Object.entries(options.tracks)) {
|
|
15066
|
-
if (curve) tracks.push({ param, curve });
|
|
15067
|
-
}
|
|
15068
|
-
return playTracks(player, options, tracks);
|
|
15069
|
-
}
|
|
15070
|
-
function playTracks(player, options, tracks) {
|
|
15071
|
-
const context = options.context ?? `modlock.camera.${++moves}`;
|
|
15072
|
-
const length3 = Math.max(0, ...tracks.map((track) => durationOf(track.curve)));
|
|
15073
|
-
const send2 = (delay) => tracks.every(
|
|
15074
|
-
({ param, curve }) => sendCurve(player, { ...options, context, param, delay }, curve)
|
|
15075
|
-
);
|
|
15076
|
-
let timer;
|
|
15077
|
-
const stop = () => {
|
|
15078
|
-
timer?.cancel();
|
|
15079
|
-
return player.clearCamera(context);
|
|
15080
|
-
};
|
|
15081
|
-
let sent = send2(options.delay);
|
|
15082
|
-
if (sent && options.loop && length3 > 0) {
|
|
15083
|
-
sent = send2(void 0);
|
|
15084
|
-
timer = every(length3, () => {
|
|
15085
|
-
if (!send2(void 0)) stop();
|
|
15086
|
-
});
|
|
15087
|
-
}
|
|
15088
|
-
if (!sent) {
|
|
15089
|
-
stop();
|
|
15090
|
-
return void 0;
|
|
15091
|
-
}
|
|
15092
|
-
return {
|
|
15093
|
-
context,
|
|
15094
|
-
duration: options.loop ? Infinity : (options.delay ?? 0) + length3,
|
|
15095
|
-
cancel: stop
|
|
15096
|
-
};
|
|
15097
|
-
}
|
|
15098
|
-
function cameraPulse(player, options) {
|
|
15099
|
-
const { param, by, ease: shape = ease.linear } = options;
|
|
15100
|
-
const rest = zero2(by);
|
|
15101
|
-
const curve = chain(
|
|
15102
|
-
line(rest, by, options.in, shape),
|
|
15103
|
-
hold(by, options.hold),
|
|
15104
|
-
reverse(line(rest, by, options.out, shape))
|
|
15105
|
-
);
|
|
15106
|
-
return playTracks(player, { ...options, relative: true }, [{ param, curve }]);
|
|
15107
|
-
}
|
|
15108
|
-
function cameraShake(player, options) {
|
|
15109
|
-
const { amplitude, duration } = options;
|
|
15110
|
-
const curve = wave({
|
|
15111
|
-
amplitude,
|
|
15112
|
-
duration,
|
|
15113
|
-
frequency: options.frequency ?? 8,
|
|
15114
|
-
decay: true
|
|
15115
|
-
});
|
|
15116
|
-
const param = options.param ?? "horizontalOffset";
|
|
15117
|
-
return playTracks(player, { ...options, relative: true }, [{ param, curve }]);
|
|
15118
|
-
}
|
|
15119
|
-
function sendCurve(player, options, curve) {
|
|
15120
|
-
const { context, param, relative, priority, target } = options;
|
|
15121
|
-
const rate = options.rate ?? 30;
|
|
15122
|
-
let delay = options.delay;
|
|
15123
|
-
const lerp3 = (start, end, duration, shape = {}) => {
|
|
15124
|
-
const sent = player.moveCamera({
|
|
15125
|
-
context,
|
|
15126
|
-
param,
|
|
15127
|
-
motion: { lerp: { start, end, duration, ...shape } },
|
|
15128
|
-
delay,
|
|
15129
|
-
relative,
|
|
15130
|
-
priority,
|
|
15131
|
-
target
|
|
15132
|
-
});
|
|
15133
|
-
delay = void 0;
|
|
15134
|
-
return sent;
|
|
15135
|
-
};
|
|
15136
|
-
return curve.every((span) => {
|
|
15137
|
-
if (span.duration <= 0) return true;
|
|
15138
|
-
if (span.lerp) {
|
|
15139
|
-
return lerp3(span.at(0), span.at(1), span.duration, span.lerp);
|
|
15140
|
-
}
|
|
15141
|
-
const steps = Math.max(1, Math.ceil(span.duration * rate));
|
|
15142
|
-
for (let i = 0; i < steps; i++) {
|
|
15143
|
-
const sent = lerp3(
|
|
15144
|
-
span.at(i / steps),
|
|
15145
|
-
span.at((i + 1) / steps),
|
|
15146
|
-
span.duration / steps
|
|
15147
|
-
);
|
|
15148
|
-
if (!sent) return false;
|
|
15149
|
-
}
|
|
15150
|
-
return true;
|
|
15151
|
-
});
|
|
15152
|
-
}
|
|
15153
|
-
function zero2(value) {
|
|
15154
|
-
return typeof value === "number" ? 0 : { x: 0, y: 0, z: 0 };
|
|
15155
|
-
}
|
|
15156
|
-
|
|
15157
|
-
// js/src/format.ts
|
|
15158
|
-
var format_exports = {};
|
|
15159
|
-
__export(format_exports, {
|
|
15160
|
-
clip: () => clip,
|
|
15161
|
-
clock: () => clock,
|
|
15162
|
-
count: () => count,
|
|
15163
|
-
grouped: () => grouped,
|
|
15164
|
-
ordinal: () => ordinal,
|
|
15165
|
-
percent: () => percent,
|
|
15166
|
-
stopwatch: () => stopwatch
|
|
15167
|
-
});
|
|
15168
|
-
function clock(seconds) {
|
|
15169
|
-
const whole = Math.max(0, Math.ceil(seconds));
|
|
15170
|
-
return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
|
|
15171
|
-
}
|
|
15172
|
-
function stopwatch(seconds) {
|
|
15173
|
-
const hundredths = Math.max(0, Math.floor(seconds * 100));
|
|
15174
|
-
const minutes = Math.floor(hundredths / 6e3);
|
|
15175
|
-
const rest = hundredths % 6e3 / 100;
|
|
15176
|
-
return `${minutes}:${rest.toFixed(2).padStart(5, "0")}`;
|
|
15177
|
-
}
|
|
15178
|
-
function percent(part, whole) {
|
|
15179
|
-
if (!(whole > 0)) {
|
|
15180
|
-
return "-";
|
|
15181
|
-
}
|
|
15182
|
-
return `${Math.round(Math.max(0, Math.min(part / whole, 1)) * 100)}%`;
|
|
15183
|
-
}
|
|
15184
|
-
function grouped(value) {
|
|
15185
|
-
return String(Math.round(value)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15186
|
-
}
|
|
15187
|
-
function ordinal(place2) {
|
|
15188
|
-
const tens = place2 % 100;
|
|
15189
|
-
const suffix = tens >= 11 && tens <= 13 ? "th" : ["th", "st", "nd", "rd"][place2 % 10] ?? "th";
|
|
15190
|
-
return `${place2}${suffix}`;
|
|
15191
|
-
}
|
|
15192
|
-
function count(number, thing, plural = `${thing}s`) {
|
|
15193
|
-
return `${grouped(number)} ${number === 1 ? thing : plural}`;
|
|
15194
|
-
}
|
|
15195
|
-
function clip(text2, width) {
|
|
15196
|
-
if (text2.length <= width) return text2;
|
|
15197
|
-
const cut = text2.slice(0, width - 1);
|
|
15198
|
-
const space = cut.lastIndexOf(" ");
|
|
15199
|
-
return `${(space > 0 ? cut.slice(0, space) : cut).trimEnd()}\u2026`;
|
|
15200
|
-
}
|
|
15201
|
-
|
|
15202
14367
|
// js/src/heroes.ts
|
|
15203
14368
|
var heroes = [
|
|
15204
14369
|
{
|
|
@@ -15465,17 +14630,1229 @@ var heroes = [
|
|
|
15465
14630
|
title: "Yamato",
|
|
15466
14631
|
portrait: "file://{images}/heroes/yamato_sm.psd"
|
|
15467
14632
|
}
|
|
15468
|
-
];
|
|
15469
|
-
function findHero(typed) {
|
|
15470
|
-
return findTitled(heroes, typed);
|
|
14633
|
+
];
|
|
14634
|
+
function findHero(typed) {
|
|
14635
|
+
return findTitled(heroes, typed);
|
|
14636
|
+
}
|
|
14637
|
+
function findTitled(list, typed) {
|
|
14638
|
+
const key = typed.toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
14639
|
+
if (key === "") {
|
|
14640
|
+
return void 0;
|
|
14641
|
+
}
|
|
14642
|
+
const plain = (entry) => entry.title.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
14643
|
+
return list.find((entry) => entry.name === key || plain(entry) === key) ?? list.find((entry) => plain(entry).startsWith(key)) ?? list.find((entry) => plain(entry).includes(key));
|
|
14644
|
+
}
|
|
14645
|
+
|
|
14646
|
+
// js/src/ui.ts
|
|
14647
|
+
function jsx(type, props, key) {
|
|
14648
|
+
const named = key === void 0 ? void 0 : String(key);
|
|
14649
|
+
if (typeof type === "function") {
|
|
14650
|
+
return { type: fragment, props: { children: type(props) }, key: named };
|
|
14651
|
+
}
|
|
14652
|
+
return { type, props, key: named };
|
|
14653
|
+
}
|
|
14654
|
+
var fragment = "fragment";
|
|
14655
|
+
var jsxs = jsx;
|
|
14656
|
+
function Fragment(props) {
|
|
14657
|
+
return props.children;
|
|
14658
|
+
}
|
|
14659
|
+
function show(player, root) {
|
|
14660
|
+
views.set(player.slot, { ...view(player), root });
|
|
14661
|
+
return draw(player);
|
|
14662
|
+
}
|
|
14663
|
+
function hideHud(player, parts) {
|
|
14664
|
+
views.set(player.slot, { ...view(player), hud: parts });
|
|
14665
|
+
return draw(player);
|
|
14666
|
+
}
|
|
14667
|
+
function freeCursor(player, free) {
|
|
14668
|
+
const current = view(player);
|
|
14669
|
+
views.set(player.slot, {
|
|
14670
|
+
...current,
|
|
14671
|
+
cursor: free,
|
|
14672
|
+
asks: free ? current.asks + 1 : current.asks
|
|
14673
|
+
});
|
|
14674
|
+
return draw(player);
|
|
14675
|
+
}
|
|
14676
|
+
function abilityBarPresses(player, onPress) {
|
|
14677
|
+
views.set(player.slot, {
|
|
14678
|
+
...view(player),
|
|
14679
|
+
bar: onPress ? { handler: onPress } : void 0
|
|
14680
|
+
});
|
|
14681
|
+
return draw(player);
|
|
14682
|
+
}
|
|
14683
|
+
function abilityDisplay(viewer, rows = []) {
|
|
14684
|
+
views.set(viewer.slot, { ...view(viewer), display: rows.slice(0, 64) });
|
|
14685
|
+
return draw(viewer);
|
|
14686
|
+
}
|
|
14687
|
+
function displayRows(viewer, rows) {
|
|
14688
|
+
if (rows.length === 0) return [];
|
|
14689
|
+
const names = new Map(players().map((c) => [c.player.slot, c.name]));
|
|
14690
|
+
return rows.map((row2) => {
|
|
14691
|
+
const hero = row2.player.pawn()?.hero;
|
|
14692
|
+
return {
|
|
14693
|
+
player: row2.player.slot,
|
|
14694
|
+
// A Steam name is at most 32 characters, within the host's 128 bytes.
|
|
14695
|
+
name: (names.get(row2.player.slot) ?? "").slice(0, 32),
|
|
14696
|
+
hero: heroes.find((each) => each.id === hero)?.name ?? "",
|
|
14697
|
+
own: row2.player.slot === viewer.slot,
|
|
14698
|
+
abilities: row2.abilities.slice(0, 4).map((shown) => ({
|
|
14699
|
+
ability: shown?.name ? itemId(shown.name) : 0,
|
|
14700
|
+
image: shown?.image ?? "",
|
|
14701
|
+
upgrades: shown?.upgrades ?? 0
|
|
14702
|
+
}))
|
|
14703
|
+
};
|
|
14704
|
+
});
|
|
14705
|
+
}
|
|
14706
|
+
var abilityBarNode = /^ability:([0-3])$/;
|
|
14707
|
+
function cursorFree(player) {
|
|
14708
|
+
const pawn = player.pawn();
|
|
14709
|
+
if (pawn === void 0) return void 0;
|
|
14710
|
+
return readField(
|
|
14711
|
+
pawn.entity,
|
|
14712
|
+
"CCitadelPlayer_MovementServices",
|
|
14713
|
+
"m_bHasFreeCursor",
|
|
14714
|
+
"bool"
|
|
14715
|
+
);
|
|
14716
|
+
}
|
|
14717
|
+
function sheet(path) {
|
|
14718
|
+
if (!path.endsWith(".css") || !path.split("/").every((part) => sheetPart.test(part) && part !== "..")) {
|
|
14719
|
+
return false;
|
|
14720
|
+
}
|
|
14721
|
+
if (sheets.includes(path)) {
|
|
14722
|
+
return true;
|
|
14723
|
+
}
|
|
14724
|
+
sheets.push(path);
|
|
14725
|
+
for (const current of views.values()) {
|
|
14726
|
+
draw(current.player);
|
|
14727
|
+
}
|
|
14728
|
+
return true;
|
|
14729
|
+
}
|
|
14730
|
+
var sheetPart = /^[\w.-]+$/;
|
|
14731
|
+
var sheets = [];
|
|
14732
|
+
function route(player, name, value) {
|
|
14733
|
+
const routes = new Map(view(player).routes);
|
|
14734
|
+
const encoded = value === void 0 ? void 0 : JSON.stringify(value);
|
|
14735
|
+
if (!routeName.test(name) || value !== void 0 && encoded === void 0) {
|
|
14736
|
+
return false;
|
|
14737
|
+
}
|
|
14738
|
+
if (encoded === void 0) {
|
|
14739
|
+
routes.delete(name);
|
|
14740
|
+
} else {
|
|
14741
|
+
routes.set(name, encoded);
|
|
14742
|
+
}
|
|
14743
|
+
views.set(player.slot, { ...view(player), routes });
|
|
14744
|
+
return draw(player);
|
|
14745
|
+
}
|
|
14746
|
+
var routeName = /^[\w.-]+$/;
|
|
14747
|
+
function hide(player) {
|
|
14748
|
+
views.delete(player.slot);
|
|
14749
|
+
screens.delete(player.slot);
|
|
14750
|
+
return send(player.slot, { reset: true });
|
|
14751
|
+
}
|
|
14752
|
+
function toast(player, text2, seconds = 4) {
|
|
14753
|
+
const current = view(player);
|
|
14754
|
+
const notice = { id: nextNotice++, text: text2, until: now2 + seconds };
|
|
14755
|
+
views.set(player.slot, {
|
|
14756
|
+
...current,
|
|
14757
|
+
notices: [...current.notices, notice].slice(-maxNotices)
|
|
14758
|
+
});
|
|
14759
|
+
return draw(player);
|
|
14760
|
+
}
|
|
14761
|
+
function uiSound(player, sound, options = {}) {
|
|
14762
|
+
const current = view(player);
|
|
14763
|
+
const cue = { number: nextCue++, sound, seconds: options.seconds ?? 0 };
|
|
14764
|
+
views.set(player.slot, {
|
|
14765
|
+
...current,
|
|
14766
|
+
cues: [...current.cues, cue].slice(-maxCues)
|
|
14767
|
+
});
|
|
14768
|
+
return draw(player);
|
|
14769
|
+
}
|
|
14770
|
+
function press(player, node) {
|
|
14771
|
+
const bar = abilityBarNode.exec(node);
|
|
14772
|
+
if (bar) {
|
|
14773
|
+
views.get(player.slot)?.bar?.handler(player, Number(bar[1]));
|
|
14774
|
+
return;
|
|
14775
|
+
}
|
|
14776
|
+
const pressed = screens.get(player.slot)?.presses.get(node);
|
|
14777
|
+
if (pressed) {
|
|
14778
|
+
pressed.handler(player);
|
|
14779
|
+
}
|
|
14780
|
+
}
|
|
14781
|
+
function change(player, node, value) {
|
|
14782
|
+
if (typeof value === "object" && value !== null) {
|
|
14783
|
+
screens.get(player.slot)?.wheels.get(node)?.handler(player, value);
|
|
14784
|
+
return;
|
|
14785
|
+
}
|
|
14786
|
+
const changed = screens.get(player.slot)?.changes.get(node);
|
|
14787
|
+
if (changed) {
|
|
14788
|
+
changed.handler(player, value);
|
|
14789
|
+
}
|
|
14790
|
+
}
|
|
14791
|
+
function tick(seconds) {
|
|
14792
|
+
now2 = seconds;
|
|
14793
|
+
for (const current of views.values()) {
|
|
14794
|
+
if (current.notices.length === 0) {
|
|
14795
|
+
continue;
|
|
14796
|
+
}
|
|
14797
|
+
current.notices = current.notices.filter((notice) => notice.until > now2);
|
|
14798
|
+
draw(current.player);
|
|
14799
|
+
}
|
|
14800
|
+
}
|
|
14801
|
+
var views = /* @__PURE__ */ new Map();
|
|
14802
|
+
var now2 = 0;
|
|
14803
|
+
var nextNotice = 0;
|
|
14804
|
+
var nextCue = 1;
|
|
14805
|
+
var maxCues = 8;
|
|
14806
|
+
var maxNotices = 4;
|
|
14807
|
+
var noticeMotion = {
|
|
14808
|
+
enter: { opacity: 0, translate: [-16, 0] },
|
|
14809
|
+
exit: { opacity: 0 },
|
|
14810
|
+
transition: { seconds: 0.25, easing: "out" }
|
|
14811
|
+
};
|
|
14812
|
+
function view(player) {
|
|
14813
|
+
return views.get(player.slot) ?? {
|
|
14814
|
+
player,
|
|
14815
|
+
root: void 0,
|
|
14816
|
+
hud: [],
|
|
14817
|
+
cursor: false,
|
|
14818
|
+
asks: 0,
|
|
14819
|
+
routes: /* @__PURE__ */ new Map(),
|
|
14820
|
+
cues: [],
|
|
14821
|
+
bar: void 0,
|
|
14822
|
+
display: [],
|
|
14823
|
+
notices: []
|
|
14824
|
+
};
|
|
14825
|
+
}
|
|
14826
|
+
function draw(player) {
|
|
14827
|
+
const current = view(player);
|
|
14828
|
+
const root = [
|
|
14829
|
+
current.root,
|
|
14830
|
+
current.notices.length !== 0 && notices(current.notices)
|
|
14831
|
+
];
|
|
14832
|
+
const previous = screens.get(player.slot);
|
|
14833
|
+
const hud = current.hud.map((part) => hudParts[part]);
|
|
14834
|
+
const display = displayRows(player, current.display);
|
|
14835
|
+
const next = render(
|
|
14836
|
+
previous,
|
|
14837
|
+
root,
|
|
14838
|
+
hud,
|
|
14839
|
+
current.cursor,
|
|
14840
|
+
current.asks,
|
|
14841
|
+
current.routes,
|
|
14842
|
+
current.cues,
|
|
14843
|
+
current.bar !== void 0,
|
|
14844
|
+
display
|
|
14845
|
+
);
|
|
14846
|
+
const change2 = diff(previous, next);
|
|
14847
|
+
if (change2 && !send(player.slot, change2)) {
|
|
14848
|
+
const whole = render(
|
|
14849
|
+
void 0,
|
|
14850
|
+
root,
|
|
14851
|
+
hud,
|
|
14852
|
+
current.cursor,
|
|
14853
|
+
current.asks,
|
|
14854
|
+
current.routes,
|
|
14855
|
+
current.cues,
|
|
14856
|
+
current.bar !== void 0,
|
|
14857
|
+
display
|
|
14858
|
+
);
|
|
14859
|
+
if (!send(player.slot, diff(void 0, whole))) {
|
|
14860
|
+
screens.delete(player.slot);
|
|
14861
|
+
return false;
|
|
14862
|
+
}
|
|
14863
|
+
screens.set(player.slot, whole);
|
|
14864
|
+
return true;
|
|
14865
|
+
}
|
|
14866
|
+
screens.set(player.slot, next);
|
|
14867
|
+
return true;
|
|
14868
|
+
}
|
|
14869
|
+
function notices(stack) {
|
|
14870
|
+
const style = {
|
|
14871
|
+
width: "fit",
|
|
14872
|
+
height: "fit",
|
|
14873
|
+
flow: "down",
|
|
14874
|
+
horizontalAlign: "left",
|
|
14875
|
+
verticalAlign: "bottom",
|
|
14876
|
+
margin: [0, 0, 260, 24],
|
|
14877
|
+
transition: noticeMotion.transition
|
|
14878
|
+
};
|
|
14879
|
+
const labels = stack.map(
|
|
14880
|
+
(notice) => jsx(
|
|
14881
|
+
"label",
|
|
14882
|
+
{
|
|
14883
|
+
style: {
|
|
14884
|
+
horizontalAlign: "left",
|
|
14885
|
+
margin: [4, 0, 0, 0],
|
|
14886
|
+
padding: [5, 10],
|
|
14887
|
+
background: "#101418d8",
|
|
14888
|
+
color: "#f2f2f2",
|
|
14889
|
+
fontSize: 16,
|
|
14890
|
+
borderRadius: 4,
|
|
14891
|
+
transition: noticeMotion.transition
|
|
14892
|
+
},
|
|
14893
|
+
enter: noticeMotion.enter,
|
|
14894
|
+
exit: noticeMotion.exit,
|
|
14895
|
+
children: notice.text
|
|
14896
|
+
},
|
|
14897
|
+
notice.id
|
|
14898
|
+
)
|
|
14899
|
+
);
|
|
14900
|
+
return jsx("panel", { style, exit: noticeMotion.exit, children: labels });
|
|
14901
|
+
}
|
|
14902
|
+
var screens = /* @__PURE__ */ new Map();
|
|
14903
|
+
function render(previous, root, hud, cursor, asks, routes, cues, bar, display) {
|
|
14904
|
+
const layout = new Layout(previous);
|
|
14905
|
+
layout.add({
|
|
14906
|
+
id: "",
|
|
14907
|
+
kind: 0 /* PANEL */,
|
|
14908
|
+
children: place(layout, root, "/"),
|
|
14909
|
+
hideHud: [...hud],
|
|
14910
|
+
freeCursor: cursor,
|
|
14911
|
+
freeCursorAsks: asks,
|
|
14912
|
+
sheets: [...sheets],
|
|
14913
|
+
cues: [...cues],
|
|
14914
|
+
abilityBarPresses: bar,
|
|
14915
|
+
abilityDisplay: [...display]
|
|
14916
|
+
});
|
|
14917
|
+
for (const [name, data] of routes) {
|
|
14918
|
+
layout.add({ id: `route:${name}`, kind: 5 /* ROUTE */, route: name, data });
|
|
14919
|
+
}
|
|
14920
|
+
return layout.screen;
|
|
14921
|
+
}
|
|
14922
|
+
var Layout = class {
|
|
14923
|
+
screen;
|
|
14924
|
+
previous;
|
|
14925
|
+
/** The layout continues previous's id counter and keeps its ids. */
|
|
14926
|
+
constructor(previous) {
|
|
14927
|
+
this.previous = previous;
|
|
14928
|
+
this.screen = {
|
|
14929
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
14930
|
+
ids: /* @__PURE__ */ new Map(),
|
|
14931
|
+
presses: /* @__PURE__ */ new Map(),
|
|
14932
|
+
changes: /* @__PURE__ */ new Map(),
|
|
14933
|
+
wheels: /* @__PURE__ */ new Map(),
|
|
14934
|
+
next: previous?.next ?? 0
|
|
14935
|
+
};
|
|
14936
|
+
}
|
|
14937
|
+
/** add records a node. */
|
|
14938
|
+
add(node) {
|
|
14939
|
+
const value = node.steamId === void 0 ? node : { ...node, steamId: String(node.steamId) };
|
|
14940
|
+
const encoded = JSON.stringify(value);
|
|
14941
|
+
this.screen.nodes.set(node.id, { node, encoded });
|
|
14942
|
+
}
|
|
14943
|
+
/** id returns the node id for the element at place. */
|
|
14944
|
+
id(place2) {
|
|
14945
|
+
let found = this.previous?.ids.get(place2);
|
|
14946
|
+
if (found === void 0) {
|
|
14947
|
+
found = (this.screen.next++).toString(36);
|
|
14948
|
+
}
|
|
14949
|
+
this.screen.ids.set(place2, found);
|
|
14950
|
+
return found;
|
|
14951
|
+
}
|
|
14952
|
+
};
|
|
14953
|
+
function place(layout, child, at2) {
|
|
14954
|
+
if (child === null || child === void 0 || typeof child === "boolean") {
|
|
14955
|
+
return [];
|
|
14956
|
+
}
|
|
14957
|
+
if (isList(child)) {
|
|
14958
|
+
return child.flatMap((item2, index) => {
|
|
14959
|
+
const key = isElement(item2) ? item2.key : void 0;
|
|
14960
|
+
return place(
|
|
14961
|
+
layout,
|
|
14962
|
+
item2,
|
|
14963
|
+
key === void 0 ? `${at2},${index}` : `${at2},=${key}`
|
|
14964
|
+
);
|
|
14965
|
+
});
|
|
14966
|
+
}
|
|
14967
|
+
if (!isElement(child)) {
|
|
14968
|
+
const node2 = {
|
|
14969
|
+
id: layout.id(at2),
|
|
14970
|
+
kind: 1 /* LABEL */,
|
|
14971
|
+
text: String(child)
|
|
14972
|
+
};
|
|
14973
|
+
layout.add(node2);
|
|
14974
|
+
return [node2.id];
|
|
14975
|
+
}
|
|
14976
|
+
if (child.type === fragment) {
|
|
14977
|
+
return place(layout, child.props.children, `${at2}>`);
|
|
14978
|
+
}
|
|
14979
|
+
const props = child.props;
|
|
14980
|
+
const node = {
|
|
14981
|
+
id: layout.id(at2),
|
|
14982
|
+
style: wireStyle(props.style),
|
|
14983
|
+
hover: wireStyle(props.hover),
|
|
14984
|
+
tooltip: props.tooltip,
|
|
14985
|
+
item: props.item ? itemId(props.item) : void 0,
|
|
14986
|
+
ability: props.ability?.name ? itemId(props.ability.name) : void 0,
|
|
14987
|
+
abilityPlayer: props.ability?.name ? props.ability.player.slot : void 0,
|
|
14988
|
+
hoverSound: props.hoverSound,
|
|
14989
|
+
enter: wireStyle(props.enter),
|
|
14990
|
+
exit: wireStyle(props.exit),
|
|
14991
|
+
cycle: cycle(props.cycle),
|
|
14992
|
+
classes: classes(props.class)
|
|
14993
|
+
};
|
|
14994
|
+
switch (child.type) {
|
|
14995
|
+
case "label":
|
|
14996
|
+
node.kind = 1 /* LABEL */;
|
|
14997
|
+
node.text = text(props.children);
|
|
14998
|
+
node.token = props.token;
|
|
14999
|
+
node.variables = variables(props.variables);
|
|
15000
|
+
break;
|
|
15001
|
+
case "avatar":
|
|
15002
|
+
node.kind = 8 /* AVATAR */;
|
|
15003
|
+
node.steamId = props.steamId;
|
|
15004
|
+
break;
|
|
15005
|
+
case "entry":
|
|
15006
|
+
case "slider":
|
|
15007
|
+
case "toggle":
|
|
15008
|
+
case "dropdown":
|
|
15009
|
+
input(layout, node, child.type, props);
|
|
15010
|
+
break;
|
|
15011
|
+
case "image":
|
|
15012
|
+
node.kind = 2 /* IMAGE */;
|
|
15013
|
+
node.image = props.src ?? "";
|
|
15014
|
+
node.scaling = scaling(props.scaling);
|
|
15015
|
+
break;
|
|
15016
|
+
case "hero":
|
|
15017
|
+
node.kind = 6 /* HERO_IMAGE */;
|
|
15018
|
+
node.hero = props.hero;
|
|
15019
|
+
node.heroLook = props.look === void 0 ? void 0 : looks[props.look];
|
|
15020
|
+
node.scaling = scaling(props.scaling);
|
|
15021
|
+
break;
|
|
15022
|
+
case "button":
|
|
15023
|
+
node.kind = 3 /* BUTTON */;
|
|
15024
|
+
node.sound = props.sound;
|
|
15025
|
+
node.disabled = props.disabled;
|
|
15026
|
+
if (props.onPress && !props.disabled) {
|
|
15027
|
+
layout.screen.presses.set(node.id, { handler: props.onPress });
|
|
15028
|
+
}
|
|
15029
|
+
node.children = place(layout, props.children, `${at2}/`);
|
|
15030
|
+
break;
|
|
15031
|
+
case "layout":
|
|
15032
|
+
node.kind = 4 /* LAYOUT */;
|
|
15033
|
+
node.layout = props.src ?? "";
|
|
15034
|
+
node.data = props.data === void 0 ? "" : JSON.stringify(props.data) ?? "";
|
|
15035
|
+
break;
|
|
15036
|
+
default:
|
|
15037
|
+
node.kind = 0 /* PANEL */;
|
|
15038
|
+
node.children = place(layout, props.children, `${at2}/`);
|
|
15039
|
+
}
|
|
15040
|
+
layout.add(node);
|
|
15041
|
+
return [node.id];
|
|
15042
|
+
}
|
|
15043
|
+
function classes(names) {
|
|
15044
|
+
const list = (names ?? "").split(" ").filter((name) => name !== "");
|
|
15045
|
+
return list.length === 0 ? void 0 : list;
|
|
15046
|
+
}
|
|
15047
|
+
function input(layout, node, kind, props) {
|
|
15048
|
+
node.kind = 7 /* INPUT */;
|
|
15049
|
+
node.disabled = props.disabled;
|
|
15050
|
+
if (props.onChange && !props.disabled) {
|
|
15051
|
+
layout.screen.changes.set(node.id, { handler: props.onChange });
|
|
15052
|
+
}
|
|
15053
|
+
switch (kind) {
|
|
15054
|
+
case "entry":
|
|
15055
|
+
node.input = {
|
|
15056
|
+
case: "textEntry",
|
|
15057
|
+
value: {
|
|
15058
|
+
text: String(props.value ?? ""),
|
|
15059
|
+
placeholder: props.placeholder,
|
|
15060
|
+
maxLength: props.maxLength
|
|
15061
|
+
}
|
|
15062
|
+
};
|
|
15063
|
+
break;
|
|
15064
|
+
case "slider":
|
|
15065
|
+
if (props.onWheel && !props.disabled) {
|
|
15066
|
+
layout.screen.wheels.set(node.id, { handler: props.onWheel });
|
|
15067
|
+
}
|
|
15068
|
+
node.input = {
|
|
15069
|
+
case: "slider",
|
|
15070
|
+
value: {
|
|
15071
|
+
value: Number(props.value ?? 0),
|
|
15072
|
+
min: props.min,
|
|
15073
|
+
max: props.max,
|
|
15074
|
+
step: props.step,
|
|
15075
|
+
wheel: !!props.onWheel && !props.disabled
|
|
15076
|
+
}
|
|
15077
|
+
};
|
|
15078
|
+
break;
|
|
15079
|
+
case "toggle":
|
|
15080
|
+
node.text = text(props.children);
|
|
15081
|
+
node.input = { case: "toggle", value: { on: props.on } };
|
|
15082
|
+
break;
|
|
15083
|
+
case "dropdown":
|
|
15084
|
+
node.input = {
|
|
15085
|
+
case: "dropdown",
|
|
15086
|
+
value: {
|
|
15087
|
+
options: [...props.options ?? []],
|
|
15088
|
+
selected: props.selected
|
|
15089
|
+
}
|
|
15090
|
+
};
|
|
15091
|
+
}
|
|
15092
|
+
}
|
|
15093
|
+
function variables(value) {
|
|
15094
|
+
if (!value) {
|
|
15095
|
+
return void 0;
|
|
15096
|
+
}
|
|
15097
|
+
const encoded = {};
|
|
15098
|
+
for (const [name, filled] of Object.entries(value)) {
|
|
15099
|
+
encoded[name] = String(filled);
|
|
15100
|
+
}
|
|
15101
|
+
return encoded;
|
|
15102
|
+
}
|
|
15103
|
+
function cycle(value) {
|
|
15104
|
+
if (!value) {
|
|
15105
|
+
return void 0;
|
|
15106
|
+
}
|
|
15107
|
+
return {
|
|
15108
|
+
style: wireStyle(value.style),
|
|
15109
|
+
seconds: value.seconds,
|
|
15110
|
+
count: value.count
|
|
15111
|
+
};
|
|
15112
|
+
}
|
|
15113
|
+
function diff(previous, next) {
|
|
15114
|
+
const set = [...next.nodes.values()].filter(
|
|
15115
|
+
({ node, encoded }) => previous?.nodes.get(node.id)?.encoded !== encoded
|
|
15116
|
+
).map(({ node }) => node);
|
|
15117
|
+
const removed = [...previous?.nodes.keys() ?? []].filter(
|
|
15118
|
+
(id) => !next.nodes.has(id)
|
|
15119
|
+
);
|
|
15120
|
+
if (previous && set.length === 0 && removed.length === 0) {
|
|
15121
|
+
return void 0;
|
|
15122
|
+
}
|
|
15123
|
+
return { reset: !previous, set, removed };
|
|
15124
|
+
}
|
|
15125
|
+
function send(slot, change2) {
|
|
15126
|
+
return call("Ui", UiRequest.toBinary({ player: slot, change: change2 })) !== void 0;
|
|
15127
|
+
}
|
|
15128
|
+
function isElement(child) {
|
|
15129
|
+
return typeof child === "object" && child !== null && !Array.isArray(child);
|
|
15130
|
+
}
|
|
15131
|
+
function isList(child) {
|
|
15132
|
+
return Array.isArray(child);
|
|
15133
|
+
}
|
|
15134
|
+
function text(children) {
|
|
15135
|
+
if (children === null || children === void 0 || typeof children === "boolean") {
|
|
15136
|
+
return "";
|
|
15137
|
+
}
|
|
15138
|
+
if (isList(children)) {
|
|
15139
|
+
return children.map(text).join("");
|
|
15140
|
+
}
|
|
15141
|
+
return isElement(children) ? "" : String(children);
|
|
15142
|
+
}
|
|
15143
|
+
var aligns = {
|
|
15144
|
+
left: 0 /* START */,
|
|
15145
|
+
top: 0 /* START */,
|
|
15146
|
+
center: 1 /* CENTER */,
|
|
15147
|
+
right: 2 /* END */,
|
|
15148
|
+
bottom: 2 /* END */
|
|
15149
|
+
};
|
|
15150
|
+
function align(value) {
|
|
15151
|
+
return value === void 0 ? void 0 : aligns[value];
|
|
15152
|
+
}
|
|
15153
|
+
var hudParts = {
|
|
15154
|
+
levelUp: 1 /* LEVEL_UP */,
|
|
15155
|
+
ownHealth: 2 /* OWN_HEALTH */,
|
|
15156
|
+
topBar: 3 /* TOP_BAR */,
|
|
15157
|
+
ammo: 4 /* AMMO */,
|
|
15158
|
+
souls: 5 /* SOULS */,
|
|
15159
|
+
minimap: 6 /* MINIMAP */,
|
|
15160
|
+
abilities: 7 /* ABILITIES */,
|
|
15161
|
+
status: 8 /* STATUS */,
|
|
15162
|
+
stats: 9 /* STATS */,
|
|
15163
|
+
heroPicker: 10 /* HERO_PICKER */,
|
|
15164
|
+
brokerCountdown: 11 /* BROKER_COUNTDOWN */,
|
|
15165
|
+
all: 12 /* ALL */
|
|
15166
|
+
};
|
|
15167
|
+
var faces = {
|
|
15168
|
+
body: 1 /* BODY */,
|
|
15169
|
+
block: 2 /* BLOCK */,
|
|
15170
|
+
serif: 3 /* SERIF */
|
|
15171
|
+
};
|
|
15172
|
+
var looks = {
|
|
15173
|
+
small: 0 /* SMALL */,
|
|
15174
|
+
card: 1 /* CARD */,
|
|
15175
|
+
icon: 2 /* ICON */,
|
|
15176
|
+
vertical: 3 /* VERTICAL */,
|
|
15177
|
+
topBar: 4 /* TOP_BAR */,
|
|
15178
|
+
minimap: 5 /* MINIMAP */
|
|
15179
|
+
};
|
|
15180
|
+
var scalings = {
|
|
15181
|
+
fit: 1 /* FIT */,
|
|
15182
|
+
cover: 2 /* COVER */,
|
|
15183
|
+
stretch: 3 /* STRETCH */,
|
|
15184
|
+
fitWidth: 4 /* FIT_WIDTH */,
|
|
15185
|
+
fitHeight: 5 /* FIT_HEIGHT */,
|
|
15186
|
+
none: 6 /* NONE */
|
|
15187
|
+
};
|
|
15188
|
+
function scaling(value) {
|
|
15189
|
+
return value === void 0 ? void 0 : scalings[value];
|
|
15190
|
+
}
|
|
15191
|
+
var flows = {
|
|
15192
|
+
down: 1 /* DOWN */,
|
|
15193
|
+
right: 2 /* RIGHT */,
|
|
15194
|
+
downWrap: 3 /* DOWN_WRAP */,
|
|
15195
|
+
rightWrap: 4 /* RIGHT_WRAP */
|
|
15196
|
+
};
|
|
15197
|
+
var overflows = {
|
|
15198
|
+
squish: 1 /* SQUISH */,
|
|
15199
|
+
clip: 2 /* CLIP */,
|
|
15200
|
+
scroll: 3 /* SCROLL */,
|
|
15201
|
+
show: 4 /* SHOW */
|
|
15202
|
+
};
|
|
15203
|
+
function overflow(value) {
|
|
15204
|
+
return value === void 0 ? void 0 : overflows[value];
|
|
15205
|
+
}
|
|
15206
|
+
var shapes = {
|
|
15207
|
+
down: 0 /* DOWN */,
|
|
15208
|
+
right: 1 /* RIGHT */,
|
|
15209
|
+
up: 2 /* UP */,
|
|
15210
|
+
left: 3 /* LEFT */,
|
|
15211
|
+
radial: 4 /* RADIAL */
|
|
15212
|
+
};
|
|
15213
|
+
var weights = {
|
|
15214
|
+
thin: 1 /* THIN */,
|
|
15215
|
+
light: 2 /* LIGHT */,
|
|
15216
|
+
normal: 3 /* NORMAL */,
|
|
15217
|
+
medium: 4 /* MEDIUM */,
|
|
15218
|
+
semiBold: 5 /* SEMI_BOLD */,
|
|
15219
|
+
bold: 6 /* BOLD */,
|
|
15220
|
+
black: 7 /* BLACK */
|
|
15221
|
+
};
|
|
15222
|
+
var textOverflows = {
|
|
15223
|
+
ellipsis: 1 /* ELLIPSIS */,
|
|
15224
|
+
shrink: 2 /* SHRINK */,
|
|
15225
|
+
clip: 3 /* CLIP */
|
|
15226
|
+
};
|
|
15227
|
+
var decorations = {
|
|
15228
|
+
underline: 1 /* UNDERLINE */,
|
|
15229
|
+
strike: 2 /* STRIKE */
|
|
15230
|
+
};
|
|
15231
|
+
var easings = {
|
|
15232
|
+
out: 0 /* EASE_OUT */,
|
|
15233
|
+
in: 1 /* EASE_IN */,
|
|
15234
|
+
inOut: 2 /* EASE_IN_OUT */,
|
|
15235
|
+
linear: 3 /* LINEAR */
|
|
15236
|
+
};
|
|
15237
|
+
function wireStyle(style) {
|
|
15238
|
+
if (!style) {
|
|
15239
|
+
return void 0;
|
|
15240
|
+
}
|
|
15241
|
+
return {
|
|
15242
|
+
width: length(style.width),
|
|
15243
|
+
height: length(style.height),
|
|
15244
|
+
flow: style.flow === void 0 ? void 0 : flows[style.flow],
|
|
15245
|
+
horizontalAlign: align(style.horizontalAlign),
|
|
15246
|
+
verticalAlign: align(style.verticalAlign),
|
|
15247
|
+
margin: edges(style.margin),
|
|
15248
|
+
padding: edges(style.padding),
|
|
15249
|
+
background: color(style.background),
|
|
15250
|
+
color: color(style.color),
|
|
15251
|
+
fontSize: style.fontSize,
|
|
15252
|
+
bold: style.bold,
|
|
15253
|
+
textAlign: align(style.textAlign),
|
|
15254
|
+
borderRadius: style.borderRadius,
|
|
15255
|
+
opacity: style.opacity,
|
|
15256
|
+
face: style.face === void 0 ? void 0 : faces[style.face],
|
|
15257
|
+
uppercase: style.uppercase,
|
|
15258
|
+
letterSpacing: style.letterSpacing,
|
|
15259
|
+
shadow: style.shadow,
|
|
15260
|
+
borderWidth: style.borderWidth,
|
|
15261
|
+
borderColor: color(style.borderColor),
|
|
15262
|
+
x: length(style.x),
|
|
15263
|
+
y: length(style.y),
|
|
15264
|
+
minWidth: length(style.minWidth),
|
|
15265
|
+
maxWidth: length(style.maxWidth),
|
|
15266
|
+
minHeight: length(style.minHeight),
|
|
15267
|
+
maxHeight: length(style.maxHeight),
|
|
15268
|
+
zIndex: style.zIndex,
|
|
15269
|
+
overflowX: overflow(style.overflowX ?? style.overflow),
|
|
15270
|
+
overflowY: overflow(style.overflowY ?? style.overflow),
|
|
15271
|
+
gradient: gradient(style.gradient),
|
|
15272
|
+
boxShadow: shadow(style.boxShadow),
|
|
15273
|
+
textShadow: shadow(style.textShadow),
|
|
15274
|
+
tint: color(style.tint),
|
|
15275
|
+
saturation: style.saturation,
|
|
15276
|
+
brightness: style.brightness,
|
|
15277
|
+
contrast: style.contrast,
|
|
15278
|
+
blur: style.blur,
|
|
15279
|
+
italic: style.italic,
|
|
15280
|
+
weight: style.weight === void 0 ? void 0 : weights[style.weight],
|
|
15281
|
+
lineHeight: style.lineHeight,
|
|
15282
|
+
noWrap: style.noWrap,
|
|
15283
|
+
textOverflow: style.textOverflow === void 0 ? void 0 : textOverflows[style.textOverflow],
|
|
15284
|
+
decoration: style.decoration === void 0 ? void 0 : decorations[style.decoration],
|
|
15285
|
+
transform: transform(style),
|
|
15286
|
+
transition: transition(style.transition)
|
|
15287
|
+
};
|
|
15288
|
+
}
|
|
15289
|
+
function gradient(value) {
|
|
15290
|
+
if (!value) {
|
|
15291
|
+
return void 0;
|
|
15292
|
+
}
|
|
15293
|
+
const last = Math.max(1, value.colors.length - 1);
|
|
15294
|
+
return {
|
|
15295
|
+
shape: value.shape === void 0 ? void 0 : shapes[value.shape],
|
|
15296
|
+
stops: value.colors.map((each, index) => ({
|
|
15297
|
+
at: value.at?.[index] ?? index / last,
|
|
15298
|
+
color: color(each)
|
|
15299
|
+
}))
|
|
15300
|
+
};
|
|
15301
|
+
}
|
|
15302
|
+
function shadow(value) {
|
|
15303
|
+
if (!value) {
|
|
15304
|
+
return void 0;
|
|
15305
|
+
}
|
|
15306
|
+
return {
|
|
15307
|
+
x: value.x,
|
|
15308
|
+
y: value.y,
|
|
15309
|
+
blur: value.blur,
|
|
15310
|
+
spread: value.spread,
|
|
15311
|
+
color: color(value.color),
|
|
15312
|
+
inset: value.inset
|
|
15313
|
+
};
|
|
15314
|
+
}
|
|
15315
|
+
function transform(style) {
|
|
15316
|
+
const { translate, scale: scale2, rotate, origin } = style;
|
|
15317
|
+
if (!translate && scale2 === void 0 && rotate === void 0 && !origin) {
|
|
15318
|
+
return void 0;
|
|
15319
|
+
}
|
|
15320
|
+
const scales = typeof scale2 === "number" ? [scale2, scale2] : scale2;
|
|
15321
|
+
return {
|
|
15322
|
+
translateX: translate?.[0],
|
|
15323
|
+
translateY: translate?.[1],
|
|
15324
|
+
scaleX: scales?.[0],
|
|
15325
|
+
scaleY: scales?.[1],
|
|
15326
|
+
rotate,
|
|
15327
|
+
originX: origin?.[0],
|
|
15328
|
+
originY: origin?.[1]
|
|
15329
|
+
};
|
|
15330
|
+
}
|
|
15331
|
+
function transition(value) {
|
|
15332
|
+
if (value === void 0) {
|
|
15333
|
+
return void 0;
|
|
15334
|
+
}
|
|
15335
|
+
if (typeof value === "number") {
|
|
15336
|
+
return { seconds: value };
|
|
15337
|
+
}
|
|
15338
|
+
return {
|
|
15339
|
+
seconds: value.seconds,
|
|
15340
|
+
delay: value.delay,
|
|
15341
|
+
easing: value.easing === void 0 ? void 0 : easings[value.easing]
|
|
15342
|
+
};
|
|
15343
|
+
}
|
|
15344
|
+
function length(value) {
|
|
15345
|
+
if (value === void 0) {
|
|
15346
|
+
return void 0;
|
|
15347
|
+
}
|
|
15348
|
+
if (typeof value === "number") {
|
|
15349
|
+
return { value: { case: "pixels", value } };
|
|
15350
|
+
}
|
|
15351
|
+
if (value === "fit") {
|
|
15352
|
+
return { value: { case: "fitChildren", value: true } };
|
|
15353
|
+
}
|
|
15354
|
+
if (value === "fill") {
|
|
15355
|
+
return { value: { case: "fill", value: 1 } };
|
|
15356
|
+
}
|
|
15357
|
+
return { value: { case: "percent", value: Number.parseFloat(value) } };
|
|
15358
|
+
}
|
|
15359
|
+
function edges(value) {
|
|
15360
|
+
if (value === void 0) {
|
|
15361
|
+
return void 0;
|
|
15362
|
+
}
|
|
15363
|
+
if (typeof value === "number") {
|
|
15364
|
+
return { top: value, right: value, bottom: value, left: value };
|
|
15365
|
+
}
|
|
15366
|
+
if (value.length === 2) {
|
|
15367
|
+
return { top: value[0], right: value[1], bottom: value[0], left: value[1] };
|
|
15368
|
+
}
|
|
15369
|
+
return { top: value[0], right: value[1], bottom: value[2], left: value[3] };
|
|
15370
|
+
}
|
|
15371
|
+
function color(value) {
|
|
15372
|
+
const hex = value?.replace(/^#/, "");
|
|
15373
|
+
if (!hex || !/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex)) {
|
|
15374
|
+
return void 0;
|
|
15375
|
+
}
|
|
15376
|
+
return Number.parseInt(hex.length === 6 ? `${hex}ff` : hex, 16) >>> 0;
|
|
15377
|
+
}
|
|
15378
|
+
|
|
15379
|
+
// js/src/vector.ts
|
|
15380
|
+
var vector_exports = {};
|
|
15381
|
+
__export(vector_exports, {
|
|
15382
|
+
add: () => add,
|
|
15383
|
+
aimAt: () => aimAt,
|
|
15384
|
+
at: () => at,
|
|
15385
|
+
distance: () => distance,
|
|
15386
|
+
dot: () => dot,
|
|
15387
|
+
flatDistance: () => flatDistance,
|
|
15388
|
+
forward: () => forward,
|
|
15389
|
+
length: () => length2,
|
|
15390
|
+
lerp: () => lerp2,
|
|
15391
|
+
level: () => level,
|
|
15392
|
+
normalize: () => normalize,
|
|
15393
|
+
scale: () => scale,
|
|
15394
|
+
sub: () => sub,
|
|
15395
|
+
toward: () => toward,
|
|
15396
|
+
yawToward: () => yawToward
|
|
15397
|
+
});
|
|
15398
|
+
function at(x, y, z) {
|
|
15399
|
+
return { x, y, z };
|
|
15400
|
+
}
|
|
15401
|
+
function add(a, b) {
|
|
15402
|
+
return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
|
|
15403
|
+
}
|
|
15404
|
+
function sub(a, b) {
|
|
15405
|
+
return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
|
|
15406
|
+
}
|
|
15407
|
+
function scale(a, s) {
|
|
15408
|
+
return { x: a.x * s, y: a.y * s, z: a.z * s };
|
|
15409
|
+
}
|
|
15410
|
+
function dot(a, b) {
|
|
15411
|
+
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
15412
|
+
}
|
|
15413
|
+
function length2(a) {
|
|
15414
|
+
return Math.hypot(a.x, a.y, a.z);
|
|
15415
|
+
}
|
|
15416
|
+
function normalize(a) {
|
|
15417
|
+
const size = length2(a);
|
|
15418
|
+
return size > 0 ? scale(a, 1 / size) : { x: 1, y: 0, z: 0 };
|
|
15419
|
+
}
|
|
15420
|
+
function lerp2(a, b, t) {
|
|
15421
|
+
return {
|
|
15422
|
+
x: a.x + (b.x - a.x) * t,
|
|
15423
|
+
y: a.y + (b.y - a.y) * t,
|
|
15424
|
+
z: a.z + (b.z - a.z) * t
|
|
15425
|
+
};
|
|
15426
|
+
}
|
|
15427
|
+
function distance(a, b) {
|
|
15428
|
+
return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);
|
|
15429
|
+
}
|
|
15430
|
+
function flatDistance(a, b) {
|
|
15431
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
15432
|
+
}
|
|
15433
|
+
function toward(from, to) {
|
|
15434
|
+
const span = distance(from, to);
|
|
15435
|
+
return span > 0 ? scale(sub(to, from), 1 / span) : { x: 0, y: 0, z: 0 };
|
|
15436
|
+
}
|
|
15437
|
+
function yawToward(from, to) {
|
|
15438
|
+
return Math.atan2(to.y - from.y, to.x - from.x) * 180 / Math.PI;
|
|
15439
|
+
}
|
|
15440
|
+
function level(yaw) {
|
|
15441
|
+
return { pitch: 0, yaw, roll: 0 };
|
|
15442
|
+
}
|
|
15443
|
+
function aimAt(from, to) {
|
|
15444
|
+
const across = flatDistance(from, to);
|
|
15445
|
+
return {
|
|
15446
|
+
pitch: -Math.atan2(to.z - from.z, across) * 180 / Math.PI,
|
|
15447
|
+
yaw: yawToward(from, to),
|
|
15448
|
+
roll: 0
|
|
15449
|
+
};
|
|
15450
|
+
}
|
|
15451
|
+
function forward(angles2) {
|
|
15452
|
+
const pitch = angles2.pitch * Math.PI / 180;
|
|
15453
|
+
const yaw = angles2.yaw * Math.PI / 180;
|
|
15454
|
+
return {
|
|
15455
|
+
x: Math.cos(pitch) * Math.cos(yaw),
|
|
15456
|
+
y: Math.cos(pitch) * Math.sin(yaw),
|
|
15457
|
+
z: -Math.sin(pitch)
|
|
15458
|
+
};
|
|
15459
|
+
}
|
|
15460
|
+
|
|
15461
|
+
// js/src/bits.ts
|
|
15462
|
+
var Buttons = {
|
|
15463
|
+
/** attack is the primary fire button. */
|
|
15464
|
+
attack: 1n,
|
|
15465
|
+
/**
|
|
15466
|
+
* jump is the jump key, Space by default (IN_MANTLE). Blocking it stops the
|
|
15467
|
+
* native jump and mantle; the jumping client still predicts the jump and is
|
|
15468
|
+
* corrected.
|
|
15469
|
+
*/
|
|
15470
|
+
jump: 1n << 48n,
|
|
15471
|
+
/** crouch is the crouch key, Ctrl by default. */
|
|
15472
|
+
crouch: 1n << 2n,
|
|
15473
|
+
/** dash is the dash key, Shift by default. */
|
|
15474
|
+
dash: 1n << 16n,
|
|
15475
|
+
/** use is the interact key. */
|
|
15476
|
+
use: 1n << 5n,
|
|
15477
|
+
/** altFire is the zoom and alternate fire button, right mouse by default. */
|
|
15478
|
+
altFire: 1n << 11n,
|
|
15479
|
+
/** reload is the reload key. */
|
|
15480
|
+
reload: 1n << 13n,
|
|
15481
|
+
/** melee is the light melee key, Q by default. */
|
|
15482
|
+
melee: 1n << 32n,
|
|
15483
|
+
/** ability1 to ability3 are the hero's first three ability keys. */
|
|
15484
|
+
ability1: 1n << 33n,
|
|
15485
|
+
ability2: 1n << 34n,
|
|
15486
|
+
ability3: 1n << 35n,
|
|
15487
|
+
/** ultimate is the hero's ultimate ability key, the fourth. */
|
|
15488
|
+
ultimate: 1n << 36n,
|
|
15489
|
+
/** parry is the melee parry button. */
|
|
15490
|
+
parry: 1n << 42n
|
|
15491
|
+
};
|
|
15492
|
+
var Layers = {
|
|
15493
|
+
/** solid is the world and solid objects. */
|
|
15494
|
+
solid: 1n << 0n,
|
|
15495
|
+
/** hitbox is the hit boxes of heroes and units. */
|
|
15496
|
+
hitbox: 1n << 1n,
|
|
15497
|
+
/** trigger is invisible volumes that react to touch. */
|
|
15498
|
+
trigger: 1n << 2n,
|
|
15499
|
+
/** playerClip is walls that only stop heroes. */
|
|
15500
|
+
playerClip: 1n << 4n,
|
|
15501
|
+
/** player is player-controlled heroes. */
|
|
15502
|
+
player: 1n << 18n,
|
|
15503
|
+
/** npc is units that are not players. */
|
|
15504
|
+
npc: 1n << 19n,
|
|
15505
|
+
/** staticLevel is the map's built geometry, foliage included. */
|
|
15506
|
+
staticLevel: 1n << 30n,
|
|
15507
|
+
/** hero, trooper and building are those units' bodies. */
|
|
15508
|
+
hero: 1n << 37n,
|
|
15509
|
+
trooper: 1n << 38n,
|
|
15510
|
+
building: 1n << 40n
|
|
15511
|
+
};
|
|
15512
|
+
|
|
15513
|
+
// js/src/curve.ts
|
|
15514
|
+
var curve_exports = {};
|
|
15515
|
+
__export(curve_exports, {
|
|
15516
|
+
chain: () => chain,
|
|
15517
|
+
durationOf: () => durationOf,
|
|
15518
|
+
ease: () => ease,
|
|
15519
|
+
hold: () => hold,
|
|
15520
|
+
keyframes: () => keyframes,
|
|
15521
|
+
line: () => line,
|
|
15522
|
+
orbit: () => orbit,
|
|
15523
|
+
pingPong: () => pingPong,
|
|
15524
|
+
repeat: () => repeat,
|
|
15525
|
+
reverse: () => reverse,
|
|
15526
|
+
shaped: () => shaped,
|
|
15527
|
+
through: () => through,
|
|
15528
|
+
valueAt: () => valueAt,
|
|
15529
|
+
wave: () => wave
|
|
15530
|
+
});
|
|
15531
|
+
var ease = {
|
|
15532
|
+
/** linear moves at an even pace. */
|
|
15533
|
+
linear: shaped((t) => t, {}),
|
|
15534
|
+
/** bias is the game's bias curve; see LerpShape. */
|
|
15535
|
+
bias: (b) => shaped((t) => bias(t, b), { bias: b }),
|
|
15536
|
+
/** gain is the game's gain curve; see LerpShape. */
|
|
15537
|
+
gain: (g) => shaped((t) => gain(t, g), { gain: g }),
|
|
15538
|
+
/** in starts slow and speeds up. */
|
|
15539
|
+
in: shaped((t) => t * t * t),
|
|
15540
|
+
/** out starts fast and slows to a stop. */
|
|
15541
|
+
out: shaped((t) => 1 - (1 - t) ** 3),
|
|
15542
|
+
/** inOut starts and ends slow. */
|
|
15543
|
+
inOut: shaped((t) => t < 0.5 ? 4 * t * t * t : 1 - (2 - 2 * t) ** 3 / 2),
|
|
15544
|
+
/** sine starts and ends slow, more gently than inOut. */
|
|
15545
|
+
sine: shaped((t) => (1 - Math.cos(Math.PI * t)) / 2),
|
|
15546
|
+
/** back passes its end a little and settles back onto it. */
|
|
15547
|
+
back: shaped((t) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2),
|
|
15548
|
+
/** elastic overshoots its end and rings down onto it. */
|
|
15549
|
+
elastic: shaped(
|
|
15550
|
+
(t) => t <= 0 || t >= 1 ? t : 2 ** (-10 * t) * Math.sin((t * 10 - 0.75) * 2 * Math.PI / 3) + 1
|
|
15551
|
+
),
|
|
15552
|
+
/** bounce drops onto its end and bounces to rest. */
|
|
15553
|
+
bounce: shaped((t) => {
|
|
15554
|
+
const k = 7.5625;
|
|
15555
|
+
if (t < 1 / 2.75) return k * t * t;
|
|
15556
|
+
if (t < 2 / 2.75) return k * (t - 1.5 / 2.75) ** 2 + 0.75;
|
|
15557
|
+
if (t < 2.5 / 2.75) return k * (t - 2.25 / 2.75) ** 2 + 0.9375;
|
|
15558
|
+
return k * (t - 2.625 / 2.75) ** 2 + 0.984375;
|
|
15559
|
+
})
|
|
15560
|
+
};
|
|
15561
|
+
function shaped(at2, lerp3) {
|
|
15562
|
+
return { at: at2, lerp: lerp3 };
|
|
15563
|
+
}
|
|
15564
|
+
function line(from, to, duration, shape = ease.linear) {
|
|
15565
|
+
return [{ duration, lerp: shape.lerp, at: (u) => mix(from, to, shape.at(u)) }];
|
|
15566
|
+
}
|
|
15567
|
+
function hold(value, duration) {
|
|
15568
|
+
return [{ duration, lerp: {}, at: () => value }];
|
|
15569
|
+
}
|
|
15570
|
+
function keyframes(keys, options = {}) {
|
|
15571
|
+
const spans = [];
|
|
15572
|
+
const [first] = keys;
|
|
15573
|
+
if (first && first.at > 0) spans.push(...hold(first.value, first.at));
|
|
15574
|
+
keys.forEach((to, i) => {
|
|
15575
|
+
const from = keys[i - 1];
|
|
15576
|
+
if (!from || to.at <= from.at) return;
|
|
15577
|
+
const duration = to.at - from.at;
|
|
15578
|
+
const shape = to.ease ?? ease.linear;
|
|
15579
|
+
if (!options.smooth) {
|
|
15580
|
+
spans.push(...line(from.value, to.value, duration, shape));
|
|
15581
|
+
return;
|
|
15582
|
+
}
|
|
15583
|
+
const before = keys[i - 2]?.value ?? from.value;
|
|
15584
|
+
const after2 = keys[i + 1]?.value ?? to.value;
|
|
15585
|
+
spans.push({
|
|
15586
|
+
duration,
|
|
15587
|
+
at: (u) => spline(before, from.value, to.value, after2, shape.at(u))
|
|
15588
|
+
});
|
|
15589
|
+
});
|
|
15590
|
+
return spans;
|
|
15591
|
+
}
|
|
15592
|
+
function through(points, options) {
|
|
15593
|
+
let at2 = 0;
|
|
15594
|
+
let last = points[0];
|
|
15595
|
+
const keys = points.map((value) => {
|
|
15596
|
+
if (last !== void 0) at2 += distance2(last, value) / options.speed;
|
|
15597
|
+
last = value;
|
|
15598
|
+
return { at: at2, value, ease: options.ease };
|
|
15599
|
+
});
|
|
15600
|
+
return keyframes(keys, options);
|
|
15601
|
+
}
|
|
15602
|
+
function orbit(options) {
|
|
15603
|
+
const { center, radius, duration } = options;
|
|
15604
|
+
const turns = options.turns ?? 1;
|
|
15605
|
+
const start = (options.start ?? 0) * Math.PI / 180;
|
|
15606
|
+
const rise = options.rise ?? 0;
|
|
15607
|
+
const shape = options.ease ?? ease.linear;
|
|
15608
|
+
return [
|
|
15609
|
+
{
|
|
15610
|
+
duration,
|
|
15611
|
+
at: (u) => {
|
|
15612
|
+
const t = shape.at(u);
|
|
15613
|
+
const angle = start + t * turns * 2 * Math.PI;
|
|
15614
|
+
return {
|
|
15615
|
+
x: center.x + radius * Math.cos(angle),
|
|
15616
|
+
y: center.y + radius * Math.sin(angle),
|
|
15617
|
+
z: center.z + rise * t
|
|
15618
|
+
};
|
|
15619
|
+
}
|
|
15620
|
+
}
|
|
15621
|
+
];
|
|
15622
|
+
}
|
|
15623
|
+
function wave(options) {
|
|
15624
|
+
const { amplitude, frequency, duration, decay } = options;
|
|
15625
|
+
return [
|
|
15626
|
+
{
|
|
15627
|
+
duration,
|
|
15628
|
+
at: (u) => amplitude * (decay ? 1 - u : 1) * Math.sin(2 * Math.PI * frequency * duration * u)
|
|
15629
|
+
}
|
|
15630
|
+
];
|
|
15631
|
+
}
|
|
15632
|
+
function chain(...curves) {
|
|
15633
|
+
return curves.flat();
|
|
15634
|
+
}
|
|
15635
|
+
function reverse(curve) {
|
|
15636
|
+
return curve.map((span) => ({
|
|
15637
|
+
duration: span.duration,
|
|
15638
|
+
lerp: span.lerp?.bias === void 0 ? span.lerp : void 0,
|
|
15639
|
+
at: (u) => span.at(1 - u)
|
|
15640
|
+
})).reverse();
|
|
15641
|
+
}
|
|
15642
|
+
function repeat(curve, times) {
|
|
15643
|
+
return Array.from({ length: Math.max(0, times) }, () => curve).flat();
|
|
15644
|
+
}
|
|
15645
|
+
function pingPong(curve) {
|
|
15646
|
+
return chain(curve, reverse(curve));
|
|
15647
|
+
}
|
|
15648
|
+
function durationOf(curve) {
|
|
15649
|
+
return curve.reduce((sum, span) => sum + Math.max(0, span.duration), 0);
|
|
15650
|
+
}
|
|
15651
|
+
function valueAt(curve, seconds) {
|
|
15652
|
+
let left = seconds;
|
|
15653
|
+
for (const span of curve) {
|
|
15654
|
+
if (span.duration <= 0) continue;
|
|
15655
|
+
if (left <= span.duration) return span.at(Math.max(0, left) / span.duration);
|
|
15656
|
+
left -= span.duration;
|
|
15657
|
+
}
|
|
15658
|
+
return curve.at(-1)?.at(1);
|
|
15471
15659
|
}
|
|
15472
|
-
function
|
|
15473
|
-
|
|
15474
|
-
|
|
15660
|
+
function bias(t, b) {
|
|
15661
|
+
return t ** (Math.log(b) / Math.log(0.5));
|
|
15662
|
+
}
|
|
15663
|
+
function gain(t, g) {
|
|
15664
|
+
return t < 0.5 ? bias(2 * t, 1 - g) / 2 : 1 - bias(2 - 2 * t, 1 - g) / 2;
|
|
15665
|
+
}
|
|
15666
|
+
function mix(a, b, t) {
|
|
15667
|
+
if (typeof a === "number" && typeof b === "number") return a + (b - a) * t;
|
|
15668
|
+
const [p, q] = [vector2(a), vector2(b)];
|
|
15669
|
+
return {
|
|
15670
|
+
x: p.x + (q.x - p.x) * t,
|
|
15671
|
+
y: p.y + (q.y - p.y) * t,
|
|
15672
|
+
z: p.z + (q.z - p.z) * t
|
|
15673
|
+
};
|
|
15674
|
+
}
|
|
15675
|
+
function spline(p0, p1, p2, p3, t) {
|
|
15676
|
+
const f = (a2, b2, c2, d2) => 0.5 * (2 * b2 + (c2 - a2) * t + (2 * a2 - 5 * b2 + 4 * c2 - d2) * t * t + (3 * b2 - a2 - 3 * c2 + d2) * t * t * t);
|
|
15677
|
+
if (typeof p0 === "number" && typeof p1 === "number" && typeof p2 === "number" && typeof p3 === "number") {
|
|
15678
|
+
return f(p0, p1, p2, p3);
|
|
15679
|
+
}
|
|
15680
|
+
const [a, b, c, d] = [vector2(p0), vector2(p1), vector2(p2), vector2(p3)];
|
|
15681
|
+
return {
|
|
15682
|
+
x: f(a.x, b.x, c.x, d.x),
|
|
15683
|
+
y: f(a.y, b.y, c.y, d.y),
|
|
15684
|
+
z: f(a.z, b.z, c.z, d.z)
|
|
15685
|
+
};
|
|
15686
|
+
}
|
|
15687
|
+
function distance2(a, b) {
|
|
15688
|
+
if (typeof a === "number" && typeof b === "number") return Math.abs(b - a);
|
|
15689
|
+
const [p, q] = [vector2(a), vector2(b)];
|
|
15690
|
+
return Math.hypot(q.x - p.x, q.y - p.y, q.z - p.z);
|
|
15691
|
+
}
|
|
15692
|
+
function vector2(value) {
|
|
15693
|
+
return typeof value === "number" ? { x: value, y: 0, z: 0 } : value;
|
|
15694
|
+
}
|
|
15695
|
+
|
|
15696
|
+
// js/src/camera.ts
|
|
15697
|
+
function setOrbitCamera(player, enabled) {
|
|
15698
|
+
const pawn = player.pawn();
|
|
15699
|
+
if (!pawn?.entity) return false;
|
|
15700
|
+
const flag = writeField(
|
|
15701
|
+
pawn.entity,
|
|
15702
|
+
"CCitadelPlayerPawn",
|
|
15703
|
+
"m_bInHideoutZone",
|
|
15704
|
+
"bool",
|
|
15705
|
+
enabled
|
|
15706
|
+
);
|
|
15707
|
+
const zoom = holdModifierState(
|
|
15708
|
+
pawn.entity,
|
|
15709
|
+
"MODIFIER_STATE_HIDEOUT_ZONE",
|
|
15710
|
+
enabled
|
|
15711
|
+
);
|
|
15712
|
+
if (enabled) return flag && zoom;
|
|
15713
|
+
const orbit2 = fireInput(pawn.entity, "RemoveModifier", {
|
|
15714
|
+
text: "modifier_citadel_orbit_camera"
|
|
15715
|
+
});
|
|
15716
|
+
return flag && zoom && orbit2;
|
|
15717
|
+
}
|
|
15718
|
+
var moves = 0;
|
|
15719
|
+
function playCamera(player, options) {
|
|
15720
|
+
const tracks = [];
|
|
15721
|
+
for (const [param, curve] of Object.entries(options.tracks)) {
|
|
15722
|
+
if (curve) tracks.push({ param, curve });
|
|
15723
|
+
}
|
|
15724
|
+
return playTracks(player, options, tracks);
|
|
15725
|
+
}
|
|
15726
|
+
function playTracks(player, options, tracks) {
|
|
15727
|
+
const context = options.context ?? `modlock.camera.${++moves}`;
|
|
15728
|
+
const length3 = Math.max(0, ...tracks.map((track) => durationOf(track.curve)));
|
|
15729
|
+
const send2 = (delay) => tracks.every(
|
|
15730
|
+
({ param, curve }) => sendCurve(player, { ...options, context, param, delay }, curve)
|
|
15731
|
+
);
|
|
15732
|
+
let timer;
|
|
15733
|
+
const stop = () => {
|
|
15734
|
+
timer?.cancel();
|
|
15735
|
+
return player.clearCamera(context);
|
|
15736
|
+
};
|
|
15737
|
+
let sent = send2(options.delay);
|
|
15738
|
+
if (sent && options.loop && length3 > 0) {
|
|
15739
|
+
sent = send2(void 0);
|
|
15740
|
+
timer = every(length3, () => {
|
|
15741
|
+
if (!send2(void 0)) stop();
|
|
15742
|
+
});
|
|
15743
|
+
}
|
|
15744
|
+
if (!sent) {
|
|
15745
|
+
stop();
|
|
15475
15746
|
return void 0;
|
|
15476
15747
|
}
|
|
15477
|
-
|
|
15478
|
-
|
|
15748
|
+
return {
|
|
15749
|
+
context,
|
|
15750
|
+
duration: options.loop ? Infinity : (options.delay ?? 0) + length3,
|
|
15751
|
+
cancel: stop
|
|
15752
|
+
};
|
|
15753
|
+
}
|
|
15754
|
+
function cameraPulse(player, options) {
|
|
15755
|
+
const { param, by, ease: shape = ease.linear } = options;
|
|
15756
|
+
const rest = zero2(by);
|
|
15757
|
+
const curve = chain(
|
|
15758
|
+
line(rest, by, options.in, shape),
|
|
15759
|
+
hold(by, options.hold),
|
|
15760
|
+
reverse(line(rest, by, options.out, shape))
|
|
15761
|
+
);
|
|
15762
|
+
return playTracks(player, { ...options, relative: true }, [{ param, curve }]);
|
|
15763
|
+
}
|
|
15764
|
+
function cameraShake(player, options) {
|
|
15765
|
+
const { amplitude, duration } = options;
|
|
15766
|
+
const curve = wave({
|
|
15767
|
+
amplitude,
|
|
15768
|
+
duration,
|
|
15769
|
+
frequency: options.frequency ?? 8,
|
|
15770
|
+
decay: true
|
|
15771
|
+
});
|
|
15772
|
+
const param = options.param ?? "horizontalOffset";
|
|
15773
|
+
return playTracks(player, { ...options, relative: true }, [{ param, curve }]);
|
|
15774
|
+
}
|
|
15775
|
+
function sendCurve(player, options, curve) {
|
|
15776
|
+
const { context, param, relative, priority, target } = options;
|
|
15777
|
+
const rate = options.rate ?? 30;
|
|
15778
|
+
let delay = options.delay;
|
|
15779
|
+
const lerp3 = (start, end, duration, shape = {}) => {
|
|
15780
|
+
const sent = player.moveCamera({
|
|
15781
|
+
context,
|
|
15782
|
+
param,
|
|
15783
|
+
motion: { lerp: { start, end, duration, ...shape } },
|
|
15784
|
+
delay,
|
|
15785
|
+
relative,
|
|
15786
|
+
priority,
|
|
15787
|
+
target
|
|
15788
|
+
});
|
|
15789
|
+
delay = void 0;
|
|
15790
|
+
return sent;
|
|
15791
|
+
};
|
|
15792
|
+
return curve.every((span) => {
|
|
15793
|
+
if (span.duration <= 0) return true;
|
|
15794
|
+
if (span.lerp) {
|
|
15795
|
+
return lerp3(span.at(0), span.at(1), span.duration, span.lerp);
|
|
15796
|
+
}
|
|
15797
|
+
const steps = Math.max(1, Math.ceil(span.duration * rate));
|
|
15798
|
+
for (let i = 0; i < steps; i++) {
|
|
15799
|
+
const sent = lerp3(
|
|
15800
|
+
span.at(i / steps),
|
|
15801
|
+
span.at((i + 1) / steps),
|
|
15802
|
+
span.duration / steps
|
|
15803
|
+
);
|
|
15804
|
+
if (!sent) return false;
|
|
15805
|
+
}
|
|
15806
|
+
return true;
|
|
15807
|
+
});
|
|
15808
|
+
}
|
|
15809
|
+
function zero2(value) {
|
|
15810
|
+
return typeof value === "number" ? 0 : { x: 0, y: 0, z: 0 };
|
|
15811
|
+
}
|
|
15812
|
+
|
|
15813
|
+
// js/src/format.ts
|
|
15814
|
+
var format_exports = {};
|
|
15815
|
+
__export(format_exports, {
|
|
15816
|
+
clip: () => clip,
|
|
15817
|
+
clock: () => clock,
|
|
15818
|
+
count: () => count,
|
|
15819
|
+
grouped: () => grouped,
|
|
15820
|
+
ordinal: () => ordinal,
|
|
15821
|
+
percent: () => percent,
|
|
15822
|
+
stopwatch: () => stopwatch
|
|
15823
|
+
});
|
|
15824
|
+
function clock(seconds) {
|
|
15825
|
+
const whole = Math.max(0, Math.ceil(seconds));
|
|
15826
|
+
return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
|
|
15827
|
+
}
|
|
15828
|
+
function stopwatch(seconds) {
|
|
15829
|
+
const hundredths = Math.max(0, Math.floor(seconds * 100));
|
|
15830
|
+
const minutes = Math.floor(hundredths / 6e3);
|
|
15831
|
+
const rest = hundredths % 6e3 / 100;
|
|
15832
|
+
return `${minutes}:${rest.toFixed(2).padStart(5, "0")}`;
|
|
15833
|
+
}
|
|
15834
|
+
function percent(part, whole) {
|
|
15835
|
+
if (!(whole > 0)) {
|
|
15836
|
+
return "-";
|
|
15837
|
+
}
|
|
15838
|
+
return `${Math.round(Math.max(0, Math.min(part / whole, 1)) * 100)}%`;
|
|
15839
|
+
}
|
|
15840
|
+
function grouped(value) {
|
|
15841
|
+
return String(Math.round(value)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
15842
|
+
}
|
|
15843
|
+
function ordinal(place2) {
|
|
15844
|
+
const tens = place2 % 100;
|
|
15845
|
+
const suffix = tens >= 11 && tens <= 13 ? "th" : ["th", "st", "nd", "rd"][place2 % 10] ?? "th";
|
|
15846
|
+
return `${place2}${suffix}`;
|
|
15847
|
+
}
|
|
15848
|
+
function count(number, thing, plural = `${thing}s`) {
|
|
15849
|
+
return `${grouped(number)} ${number === 1 ? thing : plural}`;
|
|
15850
|
+
}
|
|
15851
|
+
function clip(text2, width) {
|
|
15852
|
+
if (text2.length <= width) return text2;
|
|
15853
|
+
const cut = text2.slice(0, width - 1);
|
|
15854
|
+
const space = cut.lastIndexOf(" ");
|
|
15855
|
+
return `${(space > 0 ? cut.slice(0, space) : cut).trimEnd()}\u2026`;
|
|
15479
15856
|
}
|
|
15480
15857
|
|
|
15481
15858
|
// js/src/items.gen.ts
|
|
@@ -18164,6 +18541,8 @@ export {
|
|
|
18164
18541
|
Text,
|
|
18165
18542
|
TopStrip,
|
|
18166
18543
|
WorldObject,
|
|
18544
|
+
abilityBarPresses,
|
|
18545
|
+
abilityDisplay,
|
|
18167
18546
|
addBot,
|
|
18168
18547
|
after,
|
|
18169
18548
|
afterMatch,
|
|
@@ -18292,6 +18671,7 @@ export {
|
|
|
18292
18671
|
trace,
|
|
18293
18672
|
trackTicks,
|
|
18294
18673
|
triggers,
|
|
18674
|
+
uiSound,
|
|
18295
18675
|
vector_exports as vector,
|
|
18296
18676
|
watchInput,
|
|
18297
18677
|
watchProjectiles,
|