yolkbot 1.4.8 → 1.5.0
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/README.md +1 -1
- package/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/dist/api.d.ts +34 -16
- package/dist/api.js +164 -121
- package/dist/bot/GamePlayer.d.ts +2 -2
- package/dist/bot/GamePlayer.js +15 -5
- package/dist/bot.d.ts +121 -83
- package/dist/bot.js +624 -1077
- package/dist/comm/CommIn.js +14 -17
- package/dist/comm/CommOut.js +15 -15
- package/dist/constants/CommCode.js +1 -1
- package/dist/constants/findItemById.js +2 -1
- package/dist/constants/guns.d.ts +16 -41
- package/dist/constants/guns.js +137 -259
- package/dist/constants/index.d.ts +7 -9
- package/dist/constants/index.js +15 -13
- package/dist/dispatches/BanPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/BootPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/ChatDispatch.d.ts +3 -1
- package/dist/dispatches/ChatDispatch.js +3 -3
- package/dist/dispatches/FireDispatch.d.ts +3 -1
- package/dist/dispatches/GameOptionsDispatch.d.ts +3 -1
- package/dist/dispatches/GoToAmmoDispatch.d.ts +2 -0
- package/dist/dispatches/GoToAmmoDispatch.js +15 -16
- package/dist/dispatches/GoToCoopDispatch.d.ts +2 -0
- package/dist/dispatches/GoToCoopDispatch.js +19 -20
- package/dist/dispatches/GoToGrenadeDispatch.d.ts +2 -0
- package/dist/dispatches/GoToGrenadeDispatch.js +15 -16
- package/dist/dispatches/GoToPlayerDispatch.d.ts +3 -1
- package/dist/dispatches/GoToPlayerDispatch.js +16 -21
- package/dist/dispatches/GoToSpatulaDispatch.d.ts +2 -0
- package/dist/dispatches/GoToSpatulaDispatch.js +11 -14
- package/dist/dispatches/LookAtDispatch.d.ts +3 -1
- package/dist/dispatches/LookAtDispatch.js +8 -6
- package/dist/dispatches/LookAtPosDispatch.d.ts +3 -1
- package/dist/dispatches/LookAtPosDispatch.js +1 -1
- package/dist/dispatches/MeleeDispatch.d.ts +2 -0
- package/dist/dispatches/MeleeDispatch.js +4 -4
- package/dist/dispatches/MovementDispatch.d.ts +3 -1
- package/dist/dispatches/MovementDispatch.js +1 -1
- package/dist/dispatches/PauseDispatch.d.ts +2 -0
- package/dist/dispatches/ReloadDispatch.d.ts +2 -0
- package/dist/dispatches/ReloadDispatch.js +17 -10
- package/dist/dispatches/ReportPlayerDispatch.d.ts +4 -2
- package/dist/dispatches/ReportPlayerDispatch.js +8 -6
- package/dist/dispatches/ResetGameDispatch.d.ts +2 -0
- package/dist/dispatches/SaveLoadoutDispatch.d.ts +4 -2
- package/dist/dispatches/SaveLoadoutDispatch.js +9 -8
- package/dist/dispatches/SpawnDispatch.d.ts +2 -0
- package/dist/dispatches/SpawnDispatch.js +5 -1
- package/dist/dispatches/SwapWeaponDispatch.d.ts +3 -1
- package/dist/dispatches/SwapWeaponDispatch.js +1 -1
- package/dist/dispatches/SwitchTeamDispatch.d.ts +2 -0
- package/dist/dispatches/SwitchTeamDispatch.js +2 -1
- package/dist/dispatches/ThrowGrenadeDispatch.d.ts +3 -1
- package/dist/dispatches/index.d.ts +105 -182
- package/dist/dispatches/index.js +24 -25
- package/dist/enums.d.ts +154 -0
- package/dist/enums.js +114 -0
- package/dist/env/fetch.d.ts +15 -0
- package/dist/env/fetch.js +113 -79
- package/dist/env/globals.d.ts +9 -0
- package/dist/env/globals.js +11 -9
- package/dist/index.d.ts +31 -0
- package/dist/index.js +24 -14
- package/dist/packets/addPlayer.js +63 -0
- package/dist/packets/beginShellStreak.js +44 -0
- package/dist/packets/challengeCompleted.js +16 -0
- package/dist/packets/changeCharacter.js +46 -0
- package/dist/packets/chat.js +10 -0
- package/dist/packets/collectItem.js +26 -0
- package/dist/packets/die.js +40 -0
- package/dist/packets/endShellStreak.js +21 -0
- package/dist/packets/eventModifier.js +8 -0
- package/dist/packets/explode.js +19 -0
- package/dist/packets/fire.js +21 -0
- package/dist/packets/gameAction.js +33 -0
- package/dist/packets/gameJoined.js +64 -0
- package/dist/packets/gameOptions.js +27 -0
- package/dist/packets/hitMe.js +12 -0
- package/dist/packets/hitMeHardBoiled.js +18 -0
- package/dist/packets/hitThem.js +12 -0
- package/dist/packets/melee.js +8 -0
- package/dist/packets/metaGameState.js +62 -0
- package/dist/packets/pause.js +17 -0
- package/dist/packets/ping.js +19 -0
- package/dist/packets/playerInfo.js +15 -0
- package/dist/packets/reload.js +17 -0
- package/dist/packets/removePlayer.js +10 -0
- package/dist/packets/respawn.js +31 -0
- package/dist/packets/socketReady.js +16 -0
- package/dist/packets/spawnItem.js +11 -0
- package/dist/packets/swapWeapon.js +11 -0
- package/dist/packets/switchTeam.js +13 -0
- package/dist/packets/syncMe.js +25 -0
- package/dist/packets/syncThem.js +63 -0
- package/dist/packets/throwGrenade.js +17 -0
- package/dist/packets/updateBalance.js +8 -0
- package/dist/pathing/astar.js +33 -20
- package/dist/pathing/mapnode.d.ts +3 -1
- package/dist/pathing/mapnode.js +170 -65
- package/dist/socket.d.ts +21 -6
- package/dist/socket.js +48 -38
- package/dist/util.d.ts +4 -1
- package/dist/util.js +102 -44
- package/dist/wasm/bytes.d.ts +1 -1
- package/dist/wasm/bytes.js +1 -1
- package/dist/wasm/direct.d.ts +1 -1
- package/dist/wasm/direct.js +13 -13
- package/dist/wasm/legacy.d.ts +7 -6
- package/dist/wasm/legacy.js +14 -8
- package/package.json +43 -30
- package/dist/comm/index.d.ts +0 -12
- package/dist/comm/index.js +0 -11
- package/dist/constants/changelog.d.ts +0 -7
- package/dist/constants/housePromo.d.ts +0 -40
- package/dist/constants/language.d.ts +0 -3
- package/dist/constants/notices.d.ts +0 -4
- package/dist/constants/shellNews.d.ts +0 -12
- package/dist/constants/shellYoutube.d.ts +0 -12
- package/dist/constants/shopItems.d.ts +0 -15
- package/dist/constants/sounds.d.ts +0 -10
- package/dist/matchmaker.d.ts +0 -50
- package/dist/matchmaker.js +0 -141
- package/dist/pathing/binaryheap.d.ts +0 -18
- package/dist/pathing/binaryheap.js +0 -79
- package/dist/wasm/util.d.ts +0 -9
- package/dist/wasm/util.js +0 -19
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yolkbot",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "1.
|
|
3
|
+
"description": "yolkbot builds your dream shell shockers bot.",
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shell shockers",
|
|
7
|
-
"
|
|
7
|
+
"league bot",
|
|
8
8
|
"blue wizard",
|
|
9
9
|
"yolkbot"
|
|
10
10
|
],
|
|
11
11
|
"homepage": "https://yolkbot.xyz",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/yolkorg/yolkbot/issues",
|
|
14
|
-
"email": "
|
|
14
|
+
"email": "hello@villainsrule.xyz"
|
|
15
15
|
},
|
|
16
16
|
"author": "1ust",
|
|
17
17
|
"repository": {
|
|
@@ -29,32 +29,33 @@
|
|
|
29
29
|
],
|
|
30
30
|
"exports": {
|
|
31
31
|
"./package.json": "./package.json",
|
|
32
|
-
".":
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
35
|
+
},
|
|
33
36
|
"./api": {
|
|
34
37
|
"import": "./dist/api.js",
|
|
35
38
|
"types": "./dist/api.d.ts"
|
|
36
39
|
},
|
|
37
|
-
"./
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"./comm": {
|
|
41
|
-
"import": "./dist/comm/index.js",
|
|
42
|
-
"types": "./dist/comm/index.d.ts"
|
|
40
|
+
"./bot": {
|
|
41
|
+
"import": "./dist/bot.js",
|
|
42
|
+
"types": "./dist/bot.d.ts"
|
|
43
43
|
},
|
|
44
|
-
"./
|
|
45
|
-
"import": "./dist/
|
|
46
|
-
"types": "./dist/
|
|
44
|
+
"./enums": {
|
|
45
|
+
"import": "./dist/enums.js",
|
|
46
|
+
"types": "./dist/enums.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./socket": {
|
|
49
|
+
"import": "./dist/socket.js",
|
|
50
|
+
"types": "./dist/socket.d.ts"
|
|
47
51
|
},
|
|
48
52
|
"./util": {
|
|
49
53
|
"import": "./dist/util.js",
|
|
50
54
|
"types": "./dist/util.d.ts"
|
|
51
55
|
},
|
|
52
|
-
"./
|
|
53
|
-
"./
|
|
54
|
-
"./
|
|
55
|
-
"import": "./dist/bot.js",
|
|
56
|
-
"types": "./dist/bot.d.ts"
|
|
57
|
-
},
|
|
56
|
+
"./browser": "./browser/build/module.js",
|
|
57
|
+
"./browser/*": "./browser/build/*.js",
|
|
58
|
+
"./browser/*.js": "./browser/build/*.js",
|
|
58
59
|
"./bot/*": {
|
|
59
60
|
"import": "./dist/bot/*.js",
|
|
60
61
|
"types": "./dist/bot/*.d.ts"
|
|
@@ -63,6 +64,14 @@
|
|
|
63
64
|
"import": "./dist/bot/*.js",
|
|
64
65
|
"types": "./dist/bot/*.d.ts"
|
|
65
66
|
},
|
|
67
|
+
"./comm/*": {
|
|
68
|
+
"import": "./dist/comm/*.js",
|
|
69
|
+
"types": "./dist/comm/*.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./comm/*.js": {
|
|
72
|
+
"import": "./dist/comm/*.js",
|
|
73
|
+
"types": "./dist/comm/*.d.ts"
|
|
74
|
+
},
|
|
66
75
|
"./constants": {
|
|
67
76
|
"import": "./dist/constants/index.js",
|
|
68
77
|
"types": "./dist/constants/index.d.ts"
|
|
@@ -99,9 +108,13 @@
|
|
|
99
108
|
"import": "./dist/dispatches/*.js",
|
|
100
109
|
"types": "./dist/dispatches/*.d.ts"
|
|
101
110
|
},
|
|
102
|
-
"./
|
|
103
|
-
"import": "./dist/
|
|
104
|
-
"types": "./dist/
|
|
111
|
+
"./pathing/*": {
|
|
112
|
+
"import": "./dist/pathing/*.js",
|
|
113
|
+
"types": "./dist/pathing/*.d.ts"
|
|
114
|
+
},
|
|
115
|
+
"./pathing/*.js": {
|
|
116
|
+
"import": "./dist/pathing/*.js",
|
|
117
|
+
"types": "./dist/pathing/*.d.ts"
|
|
105
118
|
},
|
|
106
119
|
"./wasm": {
|
|
107
120
|
"import": "./dist/wasm/direct.js",
|
|
@@ -118,31 +131,31 @@
|
|
|
118
131
|
},
|
|
119
132
|
"typesVersions": {
|
|
120
133
|
"*": {
|
|
134
|
+
".": ["dist/index.d.ts"],
|
|
121
135
|
"api": ["dist/api.d.ts"],
|
|
122
|
-
"comm": ["dist/comm/index.d.ts"],
|
|
123
|
-
"matchmaker": ["dist/matchmaker.d.ts"],
|
|
124
|
-
"util": ["dist/util.d.ts"],
|
|
125
136
|
"bot": ["dist/bot/*.d.ts"],
|
|
137
|
+
"enums": ["dist/enums.d.ts"],
|
|
138
|
+
"socket": ["dist/socket.d.ts"],
|
|
139
|
+
"util": ["dist/util.d.ts"],
|
|
126
140
|
"bot/*": ["dist/bot/*.d.ts"],
|
|
141
|
+
"comm/*": ["dist/comm/*.d.ts"],
|
|
127
142
|
"constants": ["dist/constants/*.d.ts"],
|
|
128
143
|
"constants/*": ["dist/constants/*.d.ts"],
|
|
129
144
|
"dispatch": ["dist/dispatches.d.ts"],
|
|
130
145
|
"dispatch/*": ["dist/dispatches/*.d.ts"],
|
|
131
146
|
"dispatches": ["dist/dispatches.d.ts"],
|
|
132
147
|
"dispatches/*": ["dist/dispatches/*.d.ts"],
|
|
148
|
+
"pathing/*": ["dist/pathing/*.d.ts"],
|
|
133
149
|
"wasm": ["dist/wasm/direct.d.ts"],
|
|
134
150
|
"wasm/*": ["dist/wasm/*.d.ts"]
|
|
135
151
|
}
|
|
136
152
|
},
|
|
137
153
|
"dependencies": {
|
|
138
|
-
"wwws": "^1.1.
|
|
154
|
+
"wwws": "^1.1.5"
|
|
139
155
|
},
|
|
140
156
|
"devDependencies": {
|
|
141
157
|
"@stylistic/eslint-plugin": "^4.4.1",
|
|
142
158
|
"@types/bun": "^1.3.5",
|
|
143
159
|
"eslint": "^9.39.2"
|
|
144
|
-
},
|
|
145
|
-
"scripts": {
|
|
146
|
-
"lint": "bunx --bun eslint . --fix"
|
|
147
160
|
}
|
|
148
161
|
}
|
package/dist/comm/index.d.ts
DELETED
package/dist/comm/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export interface HousePromoItem {
|
|
2
|
-
imageExt: string;
|
|
3
|
-
link?: string[];
|
|
4
|
-
label: string;
|
|
5
|
-
active: boolean;
|
|
6
|
-
id: string;
|
|
7
|
-
weighted: boolean;
|
|
8
|
-
hideOnCG: boolean;
|
|
9
|
-
linksTo: string;
|
|
10
|
-
linksToVipStore?: string;
|
|
11
|
-
linksToTaggedItems?: string;
|
|
12
|
-
linksToCreateGame?: string;
|
|
13
|
-
linkToTwitch?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface HousePromoAd {
|
|
17
|
-
ad: string;
|
|
18
|
-
weighted: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ShellLogo {
|
|
22
|
-
imageExt: string;
|
|
23
|
-
label: string;
|
|
24
|
-
active: boolean;
|
|
25
|
-
id: string;
|
|
26
|
-
weighted: boolean;
|
|
27
|
-
hideOnCG: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface HousePromo {
|
|
31
|
-
big: HousePromoItem[];
|
|
32
|
-
small: HousePromoItem[];
|
|
33
|
-
bigBanner: HousePromoItem[];
|
|
34
|
-
houseAdPercentChance: number;
|
|
35
|
-
specialItemsTag: string;
|
|
36
|
-
featuredSocialMedia: string;
|
|
37
|
-
premFeatured: string;
|
|
38
|
-
smHouseAds: HousePromoAd[];
|
|
39
|
-
shellLogo: ShellLogo[];
|
|
40
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface ShopItem {
|
|
2
|
-
itemIds: number[] | null;
|
|
3
|
-
sku: string;
|
|
4
|
-
name: string;
|
|
5
|
-
price: number;
|
|
6
|
-
salePrice: number | null;
|
|
7
|
-
flagText: string;
|
|
8
|
-
type: 'currency' | 'item' | 'subscription' | 'pass' | 'bundle';
|
|
9
|
-
inStore: number;
|
|
10
|
-
currency: number;
|
|
11
|
-
isActive: boolean;
|
|
12
|
-
id: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const ShopItems: ShopItem[];
|
package/dist/matchmaker.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { API } from './api';
|
|
2
|
-
import { Region } from './constants/regions';
|
|
3
|
-
import yolkws from './socket';
|
|
4
|
-
|
|
5
|
-
interface MatchmakerParams {
|
|
6
|
-
api?: API;
|
|
7
|
-
proxy?: string;
|
|
8
|
-
instance?: string;
|
|
9
|
-
protocol?: string;
|
|
10
|
-
noLogin?: boolean;
|
|
11
|
-
sessionId?: string;
|
|
12
|
-
noExitOnError?: boolean;
|
|
13
|
-
connectionTimeout?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface MatchmakerCommand {
|
|
17
|
-
command: string;
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare class Matchmaker {
|
|
22
|
-
connected: boolean;
|
|
23
|
-
onceConnected: Function[];
|
|
24
|
-
|
|
25
|
-
api: API;
|
|
26
|
-
|
|
27
|
-
proxy: string | null;
|
|
28
|
-
sessionId: string;
|
|
29
|
-
|
|
30
|
-
onListeners: Map<string, Function[]>;
|
|
31
|
-
onceListeners: Map<string, Function[]>;
|
|
32
|
-
|
|
33
|
-
regionList: Region[];
|
|
34
|
-
ws: yolkws;
|
|
35
|
-
|
|
36
|
-
constructor(params?: MatchmakerParams);
|
|
37
|
-
|
|
38
|
-
send(msg: MatchmakerCommand): void;
|
|
39
|
-
|
|
40
|
-
getRegions(): Promise<Region[]>;
|
|
41
|
-
|
|
42
|
-
waitForConnect(): Promise<void>;
|
|
43
|
-
close(): void;
|
|
44
|
-
|
|
45
|
-
on(event: string, callback: Function): void;
|
|
46
|
-
once(event: string, callback: Function): void;
|
|
47
|
-
off(event: string, callback: Function): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default Matchmaker;
|
package/dist/matchmaker.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import API from "./api.js";
|
|
2
|
-
import { validate } from "./wasm/direct.js";
|
|
3
|
-
import globals from "./env/globals.js";
|
|
4
|
-
import yolkws from "./socket.js";
|
|
5
|
-
|
|
6
|
-
export class Matchmaker {
|
|
7
|
-
connected = false;
|
|
8
|
-
onceConnected = [];
|
|
9
|
-
regionList = [];
|
|
10
|
-
proxy = null;
|
|
11
|
-
sessionId = "";
|
|
12
|
-
onListeners = new Map;
|
|
13
|
-
onceListeners = new Map;
|
|
14
|
-
#noExitOnError = false;
|
|
15
|
-
#forceClose = false;
|
|
16
|
-
constructor(params = {}) {
|
|
17
|
-
this.#noExitOnError = params.noExitOnError || false;
|
|
18
|
-
if (!params.instance)
|
|
19
|
-
params.instance = "shellshock.io";
|
|
20
|
-
if (!params.protocol)
|
|
21
|
-
params.protocol = "wss";
|
|
22
|
-
if (params.api)
|
|
23
|
-
this.api = params.api;
|
|
24
|
-
else
|
|
25
|
-
this.api = new API({
|
|
26
|
-
proxy: params.proxy,
|
|
27
|
-
protocol: params.protocol,
|
|
28
|
-
instance: params.instance,
|
|
29
|
-
connectionTimeout: params.connectionTimeout
|
|
30
|
-
});
|
|
31
|
-
if (params.sessionId || params.noLogin)
|
|
32
|
-
this.sessionId = params.sessionId;
|
|
33
|
-
else
|
|
34
|
-
this.#createSessionId();
|
|
35
|
-
if (params.proxy && globals.isBrowser)
|
|
36
|
-
this.#processError("proxies do not work and hence are not supported in the browser");
|
|
37
|
-
else if (params.proxy)
|
|
38
|
-
this.proxy = params.proxy;
|
|
39
|
-
this.#createSocket(params.instance, params.protocol, params.noLogin, params.connectionTimeout);
|
|
40
|
-
}
|
|
41
|
-
async#createSocket(instance, protocol, noLogin, connectionTimeout) {
|
|
42
|
-
this.ws = new yolkws(`${protocol}://${instance}/matchmaker/`, this.proxy);
|
|
43
|
-
this.ws.connectionTimeout = connectionTimeout || 5000;
|
|
44
|
-
const didConnect = await this.ws.tryConnect();
|
|
45
|
-
if (!didConnect)
|
|
46
|
-
return this.#processError("WebSocket did not connect...");
|
|
47
|
-
this.ws.onmessage = async (e) => {
|
|
48
|
-
const data = JSON.parse(e.data);
|
|
49
|
-
if (data.command === "validateUUID")
|
|
50
|
-
return this.ws.send(JSON.stringify({ command: "validateUUID", hash: await validate(data.uuid) }));
|
|
51
|
-
this.#emit("msg", data);
|
|
52
|
-
};
|
|
53
|
-
this.ws.onclose = () => {
|
|
54
|
-
this.connected = false;
|
|
55
|
-
if (!this.#forceClose)
|
|
56
|
-
this.#createSocket(instance, protocol, noLogin, connectionTimeout);
|
|
57
|
-
};
|
|
58
|
-
this.connected = true;
|
|
59
|
-
if (this.sessionId || noLogin)
|
|
60
|
-
this.onceConnected.forEach((func) => func());
|
|
61
|
-
}
|
|
62
|
-
async#createSessionId() {
|
|
63
|
-
const anonLogin = await this.api.loginAnonymously();
|
|
64
|
-
if (!anonLogin || typeof anonLogin === "string")
|
|
65
|
-
this.#emit("authFail", anonLogin);
|
|
66
|
-
this.sessionId = anonLogin.sessionId;
|
|
67
|
-
if (this.connected)
|
|
68
|
-
this.onceConnected.forEach((func) => func());
|
|
69
|
-
}
|
|
70
|
-
send(msg) {
|
|
71
|
-
this.ws.send(JSON.stringify(msg));
|
|
72
|
-
}
|
|
73
|
-
async waitForConnect() {
|
|
74
|
-
return new Promise((res) => {
|
|
75
|
-
if (this.connected) {
|
|
76
|
-
res();
|
|
77
|
-
} else {
|
|
78
|
-
this.onceConnected.push(res);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
async getRegions() {
|
|
83
|
-
await this.waitForConnect();
|
|
84
|
-
const that = this;
|
|
85
|
-
return new Promise((res) => {
|
|
86
|
-
const listener = (data2) => {
|
|
87
|
-
if (data2.command === "regionList") {
|
|
88
|
-
this.regionList = data2.regionList;
|
|
89
|
-
this.off("msg", listener);
|
|
90
|
-
res(data2.regionList);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
this.on("msg", listener);
|
|
94
|
-
this.ws.onerror = (e2) => that.#processError("failed to get regions", e2);
|
|
95
|
-
this.ws.send(JSON.stringify({ command: "regionList" }));
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
close() {
|
|
99
|
-
this.#forceClose = true;
|
|
100
|
-
this.connected = false;
|
|
101
|
-
this.ws.close();
|
|
102
|
-
}
|
|
103
|
-
on(event, callback) {
|
|
104
|
-
if (!this.onListeners.has(event)) {
|
|
105
|
-
this.onListeners.set(event, []);
|
|
106
|
-
}
|
|
107
|
-
this.onListeners.get(event).push(callback);
|
|
108
|
-
}
|
|
109
|
-
once(event, callback) {
|
|
110
|
-
if (!this.onceListeners.has(event)) {
|
|
111
|
-
this.onceListeners.set(event, []);
|
|
112
|
-
}
|
|
113
|
-
this.onceListeners.get(event).push(callback);
|
|
114
|
-
}
|
|
115
|
-
off(event, callback) {
|
|
116
|
-
if (this.onListeners.has(event)) {
|
|
117
|
-
this.onListeners.set(event, this.onListeners.get(event).filter((func) => func !== callback));
|
|
118
|
-
}
|
|
119
|
-
if (this.onceListeners.has(event)) {
|
|
120
|
-
this.onceListeners.set(event, this.onceListeners.get(event).filter((func) => func !== callback));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
#emit(event, ...args) {
|
|
124
|
-
if (this.onListeners.has(event)) {
|
|
125
|
-
this.onListeners.get(event).forEach((func) => func(...args));
|
|
126
|
-
}
|
|
127
|
-
if (this.onceListeners.has(event)) {
|
|
128
|
-
this.onceListeners.get(event).forEach((func) => func(...args));
|
|
129
|
-
this.onceListeners.delete(event);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
#processError(error) {
|
|
133
|
-
if (this.onListeners.has("error"))
|
|
134
|
-
this.#emit("error", error);
|
|
135
|
-
else if (this.#noExitOnError)
|
|
136
|
-
console.error(error);
|
|
137
|
-
else
|
|
138
|
-
throw new Error(error);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export default Matchmaker;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare class BinaryHeap<T> {
|
|
2
|
-
content: T[];
|
|
3
|
-
scoreFunction: (element: T) => number;
|
|
4
|
-
|
|
5
|
-
constructor(scoreFunction: (element: T) => number);
|
|
6
|
-
|
|
7
|
-
push(element: T): void;
|
|
8
|
-
rescoreElement(node: T): void;
|
|
9
|
-
pop(): T;
|
|
10
|
-
remove(node: T): void;
|
|
11
|
-
size(): number;
|
|
12
|
-
bubbleUp(n: number): void;
|
|
13
|
-
includes(n: T): boolean;
|
|
14
|
-
sinkDown(n: number): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default BinaryHeap;
|
|
18
|
-
export { BinaryHeap };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
class BinaryHeap {
|
|
2
|
-
constructor(scoreFunction) {
|
|
3
|
-
this.content = [];
|
|
4
|
-
this.scoreFunction = scoreFunction;
|
|
5
|
-
}
|
|
6
|
-
push(element) {
|
|
7
|
-
this.content.push(element);
|
|
8
|
-
this.bubbleUp(this.content.length - 1);
|
|
9
|
-
}
|
|
10
|
-
rescoreElement(node) {
|
|
11
|
-
this.sinkDown(this.content.indexOf(node));
|
|
12
|
-
}
|
|
13
|
-
pop() {
|
|
14
|
-
const result = this.content[0];
|
|
15
|
-
const end = this.content.pop();
|
|
16
|
-
if (this.content.length > 0) {
|
|
17
|
-
this.content[0] = end;
|
|
18
|
-
this.sinkDown(0);
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
remove(node) {
|
|
23
|
-
const length = this.content.length;
|
|
24
|
-
for (let i = 0;i < length; i++) {
|
|
25
|
-
if (this.content[i] !== node)
|
|
26
|
-
continue;
|
|
27
|
-
const end = this.content.pop();
|
|
28
|
-
if (i === length - 1)
|
|
29
|
-
break;
|
|
30
|
-
this.content[i] = end;
|
|
31
|
-
this.bubbleUp(i);
|
|
32
|
-
this.sinkDown(i);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
size() {
|
|
37
|
-
return this.content.length;
|
|
38
|
-
}
|
|
39
|
-
bubbleUp(n) {
|
|
40
|
-
const element = this.content[n], score = this.scoreFunction(element);
|
|
41
|
-
while (n > 0) {
|
|
42
|
-
const parentN = Math.floor((n + 1) / 2) - 1, parent = this.content[parentN];
|
|
43
|
-
if (score >= this.scoreFunction(parent))
|
|
44
|
-
break;
|
|
45
|
-
this.content[parentN] = element;
|
|
46
|
-
this.content[n] = parent;
|
|
47
|
-
n = parentN;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
includes(n) {
|
|
51
|
-
return this.content.includes(n);
|
|
52
|
-
}
|
|
53
|
-
sinkDown(n) {
|
|
54
|
-
const length = this.content.length, element = this.content[n], elemScore = this.scoreFunction(element);
|
|
55
|
-
while (true) {
|
|
56
|
-
const child2N = (n + 1) * 2, child1N = child2N - 1;
|
|
57
|
-
let swap = null;
|
|
58
|
-
let child1Score;
|
|
59
|
-
if (child1N < length) {
|
|
60
|
-
const child1 = this.content[child1N];
|
|
61
|
-
child1Score = this.scoreFunction(child1);
|
|
62
|
-
if (child1Score < elemScore)
|
|
63
|
-
swap = child1N;
|
|
64
|
-
}
|
|
65
|
-
if (child2N < length) {
|
|
66
|
-
const child2 = this.content[child2N], child2Score = this.scoreFunction(child2);
|
|
67
|
-
if (child2Score < (swap === null ? elemScore : child1Score))
|
|
68
|
-
swap = child2N;
|
|
69
|
-
}
|
|
70
|
-
if (swap === null)
|
|
71
|
-
break;
|
|
72
|
-
this.content[n] = this.content[swap];
|
|
73
|
-
this.content[swap] = element;
|
|
74
|
-
n = swap;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
export default BinaryHeap;
|
|
79
|
-
export { BinaryHeap };
|
package/dist/wasm/util.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface MovementXY {
|
|
2
|
-
movementX: number;
|
|
3
|
-
movementY: number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export declare const sensitivity: number;
|
|
7
|
-
|
|
8
|
-
export declare const normalizeYaw: (yaw: number) => number;
|
|
9
|
-
export declare const calculateMovements: (currentYaw: number, currentPitch: number, targetYaw: number, targetPitch: number) => MovementXY;
|
package/dist/wasm/util.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const sensitivity = 0.0025;
|
|
2
|
-
export const normalizeYaw = (yaw) => {
|
|
3
|
-
while (yaw < 0)
|
|
4
|
-
yaw += 2 * Math.PI;
|
|
5
|
-
while (yaw >= 2 * Math.PI)
|
|
6
|
-
yaw -= 2 * Math.PI;
|
|
7
|
-
return yaw;
|
|
8
|
-
};
|
|
9
|
-
export const calculateMovements = (currentYaw, currentPitch, targetYaw, targetPitch) => {
|
|
10
|
-
const normalizedCurrentYaw = normalizeYaw(currentYaw);
|
|
11
|
-
const normalizedTargetYaw = normalizeYaw(targetYaw);
|
|
12
|
-
let yawDiff = normalizedTargetYaw - normalizedCurrentYaw;
|
|
13
|
-
if (Math.abs(yawDiff) > Math.PI)
|
|
14
|
-
yawDiff = yawDiff > 0 ? yawDiff - 2 * Math.PI : yawDiff + 2 * Math.PI;
|
|
15
|
-
const pitchDiff = targetPitch - currentPitch;
|
|
16
|
-
const movementX = Math.round(-yawDiff / sensitivity);
|
|
17
|
-
const movementY = Math.round(-pitchDiff / sensitivity);
|
|
18
|
-
return { movementX, movementY };
|
|
19
|
-
};
|