yolkbot 1.5.7 → 1.5.9

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.
Files changed (85) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +1 -244
  4. package/dist/bot/GamePlayer.js +1 -84
  5. package/dist/bot.js +1 -1226
  6. package/dist/comm/CommIn.js +1 -76
  7. package/dist/comm/CommOut.js +1 -60
  8. package/dist/constants/CloseCode.js +1 -27
  9. package/dist/constants/CommCode.js +1 -53
  10. package/dist/constants/challenges.js +1 -1821
  11. package/dist/constants/findItemById.js +1 -3
  12. package/dist/constants/guns.js +1 -155
  13. package/dist/constants/index.js +1 -141
  14. package/dist/constants/items.js +1 -45979
  15. package/dist/constants/maps.js +1 -1289
  16. package/dist/constants/regions.js +1 -30
  17. package/dist/dispatches/BanPlayerDispatch.js +1 -32
  18. package/dist/dispatches/BootPlayerDispatch.js +1 -21
  19. package/dist/dispatches/ChatDispatch.js +1 -32
  20. package/dist/dispatches/FireDispatch.js +1 -15
  21. package/dist/dispatches/GameOptionsDispatch.js +1 -66
  22. package/dist/dispatches/GoToAmmoDispatch.js +1 -37
  23. package/dist/dispatches/GoToCoopDispatch.js +1 -37
  24. package/dist/dispatches/GoToGrenadeDispatch.js +1 -37
  25. package/dist/dispatches/GoToPlayerDispatch.js +1 -34
  26. package/dist/dispatches/GoToSpatulaDispatch.js +1 -23
  27. package/dist/dispatches/LookAtDispatch.js +1 -37
  28. package/dist/dispatches/LookAtPosDispatch.js +1 -29
  29. package/dist/dispatches/MeleeDispatch.js +1 -26
  30. package/dist/dispatches/MovementDispatch.js +1 -26
  31. package/dist/dispatches/PauseDispatch.js +1 -18
  32. package/dist/dispatches/ReloadDispatch.js +1 -35
  33. package/dist/dispatches/ReportPlayerDispatch.js +1 -44
  34. package/dist/dispatches/ResetGameDispatch.js +1 -19
  35. package/dist/dispatches/SaveLoadoutDispatch.js +1 -106
  36. package/dist/dispatches/SpawnDispatch.js +1 -26
  37. package/dist/dispatches/SwapWeaponDispatch.js +1 -25
  38. package/dist/dispatches/SwitchTeamDispatch.js +1 -34
  39. package/dist/dispatches/ThrowGrenadeDispatch.js +1 -21
  40. package/dist/dispatches/index.js +1 -73
  41. package/dist/enums.js +1 -114
  42. package/dist/env/fetch.js +8 -129
  43. package/dist/env/globals.js +1 -17
  44. package/dist/index.js +1 -22
  45. package/dist/packets/addPlayer.js +1 -63
  46. package/dist/packets/beginShellStreak.js +1 -44
  47. package/dist/packets/challengeCompleted.js +1 -16
  48. package/dist/packets/changeCharacter.js +1 -46
  49. package/dist/packets/chat.js +1 -10
  50. package/dist/packets/collectItem.js +1 -26
  51. package/dist/packets/die.js +1 -40
  52. package/dist/packets/endShellStreak.js +1 -21
  53. package/dist/packets/eventModifier.js +1 -8
  54. package/dist/packets/explode.js +1 -19
  55. package/dist/packets/fire.js +1 -21
  56. package/dist/packets/gameAction.js +1 -33
  57. package/dist/packets/gameJoined.js +1 -64
  58. package/dist/packets/gameOptions.js +1 -27
  59. package/dist/packets/hitMe.js +1 -12
  60. package/dist/packets/hitMeHardBoiled.js +1 -18
  61. package/dist/packets/hitThem.js +1 -12
  62. package/dist/packets/melee.js +1 -8
  63. package/dist/packets/metaGameState.js +1 -62
  64. package/dist/packets/pause.js +1 -17
  65. package/dist/packets/ping.js +1 -19
  66. package/dist/packets/playerInfo.js +1 -15
  67. package/dist/packets/reload.js +1 -17
  68. package/dist/packets/removePlayer.js +1 -10
  69. package/dist/packets/respawn.js +1 -31
  70. package/dist/packets/socketReady.js +1 -16
  71. package/dist/packets/spawnItem.js +1 -11
  72. package/dist/packets/swapWeapon.js +1 -11
  73. package/dist/packets/switchTeam.js +1 -13
  74. package/dist/packets/syncMe.js +1 -25
  75. package/dist/packets/syncThem.js +1 -63
  76. package/dist/packets/throwGrenade.js +1 -17
  77. package/dist/packets/updateBalance.js +1 -8
  78. package/dist/pathing/astar.js +1 -68
  79. package/dist/pathing/mapnode.js +1 -284
  80. package/dist/socket.js +1 -107
  81. package/dist/util.js +1 -128
  82. package/dist/wasm/bytes.js +1 -8
  83. package/dist/wasm/direct.js +1 -84
  84. package/dist/wasm/legacy.js +1 -176
  85. package/package.json +2 -7
@@ -1,19 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
- import { Intents } from "../enums.js";
4
- const processPingPacket = (bot) => {
5
- if (!bot.intents.includes(Intents.PING))
6
- return;
7
- if (bot.pingTimeoutId)
8
- clearTimeout(bot.pingTimeoutId);
9
- const oldPing = bot.ping ?? 0;
10
- bot.ping = bot.lastPingTime ? Date.now() - bot.lastPingTime : 0;
11
- bot.$emit("pingUpdate", oldPing, bot.ping);
12
- bot.pingTimeoutId = setTimeout(() => {
13
- const out = new CommOut;
14
- out.packInt8(CommCode.ping);
15
- out.send(bot.game.socket);
16
- bot.lastPingTime = Date.now();
17
- }, 1000);
18
- };
19
- export default processPingPacket;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";import{Intents}from"../enums.js";const processPingPacket=(bot)=>{if(!bot.intents.includes(Intents.PING))return;if(bot.pingTimeoutId)clearTimeout(bot.pingTimeoutId);const oldPing=bot.ping??0;bot.ping=bot.lastPingTime?Date.now()-bot.lastPingTime:0;bot.$emit("pingUpdate",oldPing,bot.ping);bot.pingTimeoutId=setTimeout(()=>{const out=new CommOut;out.packInt8(CommCode.ping);out.send(bot.game.socket);bot.lastPingTime=Date.now()},1000)};export default processPingPacket;
@@ -1,15 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processPlayerInfoPacket = (bot) => {
3
- const playerId = CommIn.unPackInt8U();
4
- const playerDBId = CommIn.unPackString(128);
5
- const playerIp = CommIn.unPackString(32);
6
- const player = bot.players[playerId];
7
- if (!player)
8
- return;
9
- player.admin = {
10
- ip: playerIp,
11
- dbId: playerDBId
12
- };
13
- bot.$emit("playerInfo", player, playerIp, playerDBId);
14
- };
15
- export default processPlayerInfoPacket;
1
+ import CommIn from"../comm/CommIn.js";const processPlayerInfoPacket=(bot)=>{const playerId=CommIn.unPackInt8U();const playerDBId=CommIn.unPackString(128);const playerIp=CommIn.unPackString(32);const player=bot.players[playerId];if(!player)return;player.admin={ip:playerIp,dbId:playerDBId};bot.$emit("playerInfo",player,playerIp,playerDBId)};export default processPlayerInfoPacket;
@@ -1,17 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processReloadPacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const player = bot.players[id];
5
- if (!player)
6
- return;
7
- const playerActiveWeapon = player.weapons[player.activeGun];
8
- if (playerActiveWeapon.ammo) {
9
- const maxLoad = Math.min(playerActiveWeapon.ammo.capacity, playerActiveWeapon.ammo.reload);
10
- const needed = Math.max(0, maxLoad - playerActiveWeapon.ammo.rounds);
11
- const newRounds = Math.min(needed, playerActiveWeapon.ammo.store);
12
- playerActiveWeapon.ammo.rounds += newRounds;
13
- playerActiveWeapon.ammo.store -= newRounds;
14
- }
15
- bot.$emit("playerReload", player, playerActiveWeapon);
16
- };
17
- export default processReloadPacket;
1
+ import CommIn from"../comm/CommIn.js";const processReloadPacket=(bot)=>{const id=CommIn.unPackInt8U();const player=bot.players[id];if(!player)return;const playerActiveWeapon=player.weapons[player.activeGun];if(playerActiveWeapon.ammo){const maxLoad=Math.min(playerActiveWeapon.ammo.capacity,playerActiveWeapon.ammo.reload);const needed=Math.max(0,maxLoad-playerActiveWeapon.ammo.rounds);const newRounds=Math.min(needed,playerActiveWeapon.ammo.store);playerActiveWeapon.ammo.rounds+=newRounds;playerActiveWeapon.ammo.store-=newRounds}bot.$emit("playerReload",player,playerActiveWeapon)};export default processReloadPacket;
@@ -1,10 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processRemovePlayerPacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- if (!bot.players[id])
5
- return;
6
- const removedPlayer = structuredClone(bot.players[id]);
7
- delete bot.players[id];
8
- bot.$emit("playerLeave", removedPlayer);
9
- };
10
- export default processRemovePlayerPacket;
1
+ import CommIn from"../comm/CommIn.js";const processRemovePlayerPacket=(bot)=>{const id=CommIn.unPackInt8U();if(!bot.players[id])return;const removedPlayer=structuredClone(bot.players[id]);delete bot.players[id];bot.$emit("playerLeave",removedPlayer)};export default processRemovePlayerPacket;
@@ -1,31 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processRespawnPacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const seed = CommIn.unPackInt16U();
5
- const x = CommIn.unPackFloat();
6
- const y = CommIn.unPackFloat();
7
- const z = CommIn.unPackFloat();
8
- const primaryRounds = CommIn.unPackInt8U();
9
- const primaryStore = CommIn.unPackInt8U();
10
- const secondaryRounds = CommIn.unPackInt8U();
11
- const secondaryStore = CommIn.unPackInt8U();
12
- const grenades = CommIn.unPackInt8U();
13
- const player = bot.players[id];
14
- if (player) {
15
- player.playing = true;
16
- player.randomSeed = seed;
17
- if (player.weapons[0] && player.weapons[0].ammo)
18
- player.weapons[0].ammo.rounds = primaryRounds;
19
- if (player.weapons[0] && player.weapons[0].ammo)
20
- player.weapons[0].ammo.store = primaryStore;
21
- if (player.weapons[1] && player.weapons[1].ammo)
22
- player.weapons[1].ammo.rounds = secondaryRounds;
23
- if (player.weapons[1] && player.weapons[1].ammo)
24
- player.weapons[1].ammo.store = secondaryStore;
25
- player.grenades = grenades;
26
- player.position = { x, y, z };
27
- player.spawnShield = 120;
28
- bot.$emit("playerRespawn", player);
29
- }
30
- };
31
- export default processRespawnPacket;
1
+ import CommIn from"../comm/CommIn.js";const processRespawnPacket=(bot)=>{const id=CommIn.unPackInt8U();const seed=CommIn.unPackInt16U();const x=CommIn.unPackFloat();const y=CommIn.unPackFloat();const z=CommIn.unPackFloat();const primaryRounds=CommIn.unPackInt8U();const primaryStore=CommIn.unPackInt8U();const secondaryRounds=CommIn.unPackInt8U();const secondaryStore=CommIn.unPackInt8U();const grenades=CommIn.unPackInt8U();const player=bot.players[id];if(player){player.playing=true;player.randomSeed=seed;if(player.weapons[0]&&player.weapons[0].ammo)player.weapons[0].ammo.rounds=primaryRounds;if(player.weapons[0]&&player.weapons[0].ammo)player.weapons[0].ammo.store=primaryStore;if(player.weapons[1]&&player.weapons[1].ammo)player.weapons[1].ammo.rounds=secondaryRounds;if(player.weapons[1]&&player.weapons[1].ammo)player.weapons[1].ammo.store=secondaryStore;player.grenades=grenades;player.position={x,y,z};player.spawnShield=120;bot.$emit("playerRespawn",player)}};export default processRespawnPacket;
@@ -1,16 +1 @@
1
- import CommOut from "../comm/CommOut.js";
2
- import CommCode from "../constants/CommCode.js";
3
- import { Intents } from "../enums.js";
4
- const processSocketReadyPacket = (bot) => {
5
- const out = new CommOut;
6
- out.packInt8(bot.intents.includes(Intents.OBSERVE_GAME) ? CommCode.observeGame : CommCode.joinGame);
7
- out.packString(bot.game.raw.uuid);
8
- out.packInt8(+bot.intents.includes(Intents.VIP_HIDE_BADGE));
9
- out.packInt8(bot.state.weaponIdx || bot.account.loadout?.classIdx || 0);
10
- out.packString(bot.state.name);
11
- out.packInt32(bot.account.session);
12
- out.packString(bot.account.sessionId);
13
- out.packString(bot.account.firebaseId);
14
- out.send(bot.game.socket);
15
- };
16
- export default processSocketReadyPacket;
1
+ import CommOut from"../comm/CommOut.js";import CommCode from"../constants/CommCode.js";import{Intents}from"../enums.js";const processSocketReadyPacket=(bot)=>{const out=new CommOut;out.packInt8(bot.intents.includes(Intents.OBSERVE_GAME)?CommCode.observeGame:CommCode.joinGame);out.packString(bot.game.raw.uuid);out.packInt8(+bot.intents.includes(Intents.VIP_HIDE_BADGE));out.packInt8(bot.state.weaponIdx||bot.account.loadout?.classIdx||0);out.packString(bot.state.name);out.packInt32(bot.account.session);out.packString(bot.account.sessionId);out.packString(bot.account.firebaseId);out.send(bot.game.socket)};export default processSocketReadyPacket;
@@ -1,11 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processSpawnItemPacket = (bot) => {
3
- const id = CommIn.unPackInt16U();
4
- const type = CommIn.unPackInt8U();
5
- const x = CommIn.unPackFloat();
6
- const y = CommIn.unPackFloat();
7
- const z = CommIn.unPackFloat();
8
- bot.game.collectibles[type].push({ id, x, y, z });
9
- bot.$emit("spawnItem", type, { x, y, z }, id);
10
- };
11
- export default processSpawnItemPacket;
1
+ import CommIn from"../comm/CommIn.js";const processSpawnItemPacket=(bot)=>{const id=CommIn.unPackInt16U();const type=CommIn.unPackInt8U();const x=CommIn.unPackFloat();const y=CommIn.unPackFloat();const z=CommIn.unPackFloat();bot.game.collectibles[type].push({id,x,y,z});bot.$emit("spawnItem",type,{x,y,z},id)};export default processSpawnItemPacket;
@@ -1,11 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processSwapWeaponPacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const newWeaponId = CommIn.unPackInt8U();
5
- const player = bot.players[id];
6
- if (player) {
7
- player.activeGun = newWeaponId;
8
- bot.$emit("playerSwapWeapon", player, newWeaponId);
9
- }
10
- };
11
- export default processSwapWeaponPacket;
1
+ import CommIn from"../comm/CommIn.js";const processSwapWeaponPacket=(bot)=>{const id=CommIn.unPackInt8U();const newWeaponId=CommIn.unPackInt8U();const player=bot.players[id];if(player){player.activeGun=newWeaponId;bot.$emit("playerSwapWeapon",player,newWeaponId)}};export default processSwapWeaponPacket;
@@ -1,13 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processSwitchTeamPacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const toTeam = CommIn.unPackInt8U();
5
- const player = bot.players[id];
6
- if (!player)
7
- return;
8
- const oldTeam = player.team;
9
- player.team = toTeam;
10
- player.streak = 0;
11
- bot.$emit("playerSwitchTeam", player, oldTeam, toTeam);
12
- };
13
- export default processSwitchTeamPacket;
1
+ import CommIn from"../comm/CommIn.js";const processSwitchTeamPacket=(bot)=>{const id=CommIn.unPackInt8U();const toTeam=CommIn.unPackInt8U();const player=bot.players[id];if(!player)return;const oldTeam=player.team;player.team=toTeam;player.streak=0;bot.$emit("playerSwitchTeam",player,oldTeam,toTeam)};export default processSwitchTeamPacket;
@@ -1,25 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processSyncMePacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const player = bot.players[id];
5
- CommIn.unPackInt8U();
6
- const serverStateIdx = CommIn.unPackInt8U();
7
- const newX = CommIn.unPackFloat();
8
- const newY = CommIn.unPackFloat();
9
- const newZ = CommIn.unPackFloat();
10
- bot.me.climbing = !!CommIn.unPackInt8U();
11
- CommIn.unPackInt8U();
12
- CommIn.unPackInt8U();
13
- if (!player)
14
- return;
15
- bot.state.serverStateIdx = serverStateIdx;
16
- const oldX = player.position.x;
17
- const oldY = player.position.y;
18
- const oldZ = player.position.z;
19
- player.position.x = newX;
20
- player.position.y = newY;
21
- player.position.z = newZ;
22
- if (oldX !== newX || oldY !== newY || oldZ !== newZ)
23
- bot.$emit("playerMove", player, { x: oldX, y: oldY, z: oldZ }, { x: newX, y: newY, z: newZ });
24
- };
25
- export default processSyncMePacket;
1
+ import CommIn from"../comm/CommIn.js";const processSyncMePacket=(bot)=>{const id=CommIn.unPackInt8U();const player=bot.players[id];CommIn.unPackInt8U();const serverStateIdx=CommIn.unPackInt8U();const newX=CommIn.unPackFloat();const newY=CommIn.unPackFloat();const newZ=CommIn.unPackFloat();bot.me.climbing=!!CommIn.unPackInt8U();CommIn.unPackInt8U();CommIn.unPackInt8U();if(!player)return;bot.state.serverStateIdx=serverStateIdx;const oldX=player.position.x;const oldY=player.position.y;const oldZ=player.position.z;player.position.x=newX;player.position.y=newY;player.position.z=newZ;if(oldX!==newX||oldY!==newY||oldZ!==newZ)bot.$emit("playerMove",player,{x:oldX,y:oldY,z:oldZ},{x:newX,y:newY,z:newZ})};export default processSyncMePacket;
@@ -1,63 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- import { FramesBetweenSyncs, GameMode, Movement } from "../constants/index.js";
3
- import { ZoneLeaveReason } from "../enums.js";
4
- const processSyncThemPacket = (bot) => {
5
- const id = CommIn.unPackInt8U();
6
- const x = CommIn.unPackFloat();
7
- const y = CommIn.unPackFloat();
8
- const z = CommIn.unPackFloat();
9
- const climbing = CommIn.unPackInt8U();
10
- const player = bot.players[id];
11
- if (!player || player.id === bot.me.id) {
12
- for (let i2 = 0;i2 < FramesBetweenSyncs; i2++) {
13
- CommIn.unPackInt8U();
14
- CommIn.unPackRadU();
15
- CommIn.unPackRad();
16
- CommIn.unPackInt8U();
17
- }
18
- return;
19
- }
20
- for (let i2 = 0;i2 < FramesBetweenSyncs; i2++) {
21
- const controlKeys = CommIn.unPackInt8U();
22
- player.jumping = !!(controlKeys & Movement.Jump);
23
- player.scoping = !!(controlKeys & Movement.Scope);
24
- const oldView = structuredClone(player.view);
25
- player.view.yaw = CommIn.unPackRadU();
26
- player.view.pitch = CommIn.unPackRad();
27
- if (player.view.yaw !== oldView.yaw || player.view.pitch !== oldView.pitch)
28
- bot.$emit("playerRotate", player, oldView, player.view);
29
- player.scale = CommIn.unPackInt8U();
30
- }
31
- const px = player.position;
32
- const posChanged = px.x !== x || px.y !== y || px.z !== z;
33
- const climbingChanged = player.climbing !== climbing;
34
- const didChange = posChanged || climbingChanged;
35
- const oldPosition = didChange ? structuredClone(px) : null;
36
- if (px.x !== x)
37
- px.x = x;
38
- if (px.z !== z)
39
- px.z = z;
40
- if (!player.jumping || Math.abs(px.y - y) > 0.5)
41
- px.y = y;
42
- if (climbingChanged)
43
- player.climbing = climbing;
44
- if (!didChange)
45
- return;
46
- bot.$emit("playerMove", player, oldPosition, px);
47
- if (bot.game.gameModeId !== GameMode.KOTC)
48
- return;
49
- const zone = bot.game.kotc.activeZone;
50
- const wasIn = !!player.inKotcZone;
51
- if (!zone && wasIn) {
52
- player.inKotcZone = false;
53
- bot.$emit("playerLeaveZone", player, ZoneLeaveReason.RoundEnded);
54
- return;
55
- }
56
- player.updateKotcZone(zone);
57
- const nowIn = !!player.inKotcZone;
58
- if (wasIn !== nowIn) {
59
- player.inKotcZone = nowIn;
60
- bot.$emit(nowIn ? "playerEnterZone" : "playerLeaveZone", player, nowIn ? null : ZoneLeaveReason.WalkedOut);
61
- }
62
- };
63
- export default processSyncThemPacket;
1
+ import CommIn from"../comm/CommIn.js";import{FramesBetweenSyncs,GameMode,Movement}from"../constants/index.js";import{ZoneLeaveReason}from"../enums.js";const processSyncThemPacket=(bot)=>{const id=CommIn.unPackInt8U();const x=CommIn.unPackFloat();const y=CommIn.unPackFloat();const z=CommIn.unPackFloat();const climbing=CommIn.unPackInt8U();const player=bot.players[id];if(!player||player.id===bot.me.id){for(let i2=0;i2<FramesBetweenSyncs;i2++){CommIn.unPackInt8U();CommIn.unPackRadU();CommIn.unPackRad();CommIn.unPackInt8U()}return}for(let i2=0;i2<FramesBetweenSyncs;i2++){const controlKeys=CommIn.unPackInt8U();player.jumping=!!(controlKeys&Movement.Jump);player.scoping=!!(controlKeys&Movement.Scope);const oldView=structuredClone(player.view);player.view.yaw=CommIn.unPackRadU();player.view.pitch=CommIn.unPackRad();if(player.view.yaw!==oldView.yaw||player.view.pitch!==oldView.pitch)bot.$emit("playerRotate",player,oldView,player.view);player.scale=CommIn.unPackInt8U()}const px=player.position;const posChanged=px.x!==x||px.y!==y||px.z!==z;const climbingChanged=player.climbing!==climbing;const didChange=posChanged||climbingChanged;const oldPosition=didChange?structuredClone(px):null;if(px.x!==x)px.x=x;if(px.z!==z)px.z=z;if(!player.jumping||Math.abs(px.y-y)>0.5)px.y=y;if(climbingChanged)player.climbing=climbing;if(!didChange)return;bot.$emit("playerMove",player,oldPosition,px);if(bot.game.gameModeId!==GameMode.KOTC)return;const zone=bot.game.kotc.activeZone;const wasIn=!!player.inKotcZone;if(!zone&&wasIn){player.inKotcZone=false;bot.$emit("playerLeaveZone",player,ZoneLeaveReason.RoundEnded);return}player.updateKotcZone(zone);const nowIn=!!player.inKotcZone;if(wasIn!==nowIn){player.inKotcZone=nowIn;bot.$emit(nowIn?"playerEnterZone":"playerLeaveZone",player,nowIn?null:ZoneLeaveReason.WalkedOut)}};export default processSyncThemPacket;
@@ -1,17 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processThrowGrenadePacket = (bot) => {
3
- const id = CommIn.unPackInt8U();
4
- const x = CommIn.unPackFloat();
5
- const y = CommIn.unPackFloat();
6
- const z = CommIn.unPackFloat();
7
- const dx = CommIn.unPackFloat();
8
- const dy = CommIn.unPackFloat();
9
- const dz = CommIn.unPackFloat();
10
- const player = bot.players[id];
11
- if (player) {
12
- if (player.grenades > 0)
13
- player.grenades--;
14
- bot.$emit("playerThrowGrenade", player, { x, y, z }, { x: dx, y: dy, z: dz });
15
- }
16
- };
17
- export default processThrowGrenadePacket;
1
+ import CommIn from"../comm/CommIn.js";const processThrowGrenadePacket=(bot)=>{const id=CommIn.unPackInt8U();const x=CommIn.unPackFloat();const y=CommIn.unPackFloat();const z=CommIn.unPackFloat();const dx=CommIn.unPackFloat();const dy=CommIn.unPackFloat();const dz=CommIn.unPackFloat();const player=bot.players[id];if(player){if(player.grenades>0)player.grenades--;bot.$emit("playerThrowGrenade",player,{x,y,z},{x:dx,y:dy,z:dz})}};export default processThrowGrenadePacket;
@@ -1,8 +1 @@
1
- import CommIn from "../comm/CommIn.js";
2
- const processUpdateBalancePacket = (bot) => {
3
- const newBalance = CommIn.unPackInt32U();
4
- const oldBalance = bot.account.eggBalance;
5
- bot.account.eggBalance = newBalance;
6
- bot.$emit("balanceUpdate", oldBalance, newBalance);
7
- };
8
- export default processUpdateBalancePacket;
1
+ import CommIn from"../comm/CommIn.js";const processUpdateBalancePacket=(bot)=>{const newBalance=CommIn.unPackInt32U();const oldBalance=bot.account.eggBalance;bot.account.eggBalance=newBalance;bot.$emit("balanceUpdate",oldBalance,newBalance)};export default processUpdateBalancePacket;
@@ -1,68 +1 @@
1
- export default class AStar {
2
- constructor(list) {
3
- this.list = list;
4
- }
5
- heuristic(pos1, pos2) {
6
- const dx = Math.abs(pos1.x - pos2.x);
7
- const dy = Math.abs(pos1.y - pos2.y);
8
- const dz = Math.abs(pos1.z - pos2.z);
9
- const dxz = Math.max(dx, dz);
10
- return dy + dxz;
11
- }
12
- reversePath(node) {
13
- const path = [];
14
- while (node.parent) {
15
- path.push(node);
16
- node = node.parent;
17
- }
18
- path.reverse();
19
- return path;
20
- }
21
- path(start, end) {
22
- this.list.clean();
23
- const openSet = [start];
24
- const closedSet = new Set;
25
- start.h = this.heuristic(start, end);
26
- start.g = 0;
27
- start.f = start.h;
28
- start.visited = true;
29
- let current;
30
- while (openSet.length > 0) {
31
- let lowestIdx = 0;
32
- let lowestF = openSet[0].f;
33
- let lowestG = openSet[0].g;
34
- for (let i = 1;i < openSet.length; i++) {
35
- const node = openSet[i];
36
- if (node.f < lowestF || node.f === lowestF && node.g > lowestG) {
37
- lowestF = node.f;
38
- lowestG = node.g;
39
- lowestIdx = i;
40
- }
41
- }
42
- current = openSet[lowestIdx];
43
- if (current === end)
44
- return this.reversePath(current);
45
- openSet[lowestIdx] = openSet[openSet.length - 1];
46
- openSet.pop();
47
- closedSet.add(current);
48
- const neighbors = current.links;
49
- for (let i = 0;i < neighbors.length; i++) {
50
- const neighbor = neighbors[i];
51
- if (closedSet.has(neighbor))
52
- continue;
53
- const tentativeGScore = current.g + 1;
54
- if (!neighbor.visited || tentativeGScore < neighbor.g) {
55
- const isNew = !neighbor.visited;
56
- neighbor.visited = true;
57
- neighbor.parent = current;
58
- neighbor.g = tentativeGScore;
59
- neighbor.h = this.heuristic(neighbor, end);
60
- neighbor.f = neighbor.g + neighbor.h;
61
- if (isNew)
62
- openSet.push(neighbor);
63
- }
64
- }
65
- }
66
- return null;
67
- }
68
- }
1
+ export default class AStar{constructor(list){this.list=list}heuristic(pos1,pos2){const dx=Math.abs(pos1.x-pos2.x);const dy=Math.abs(pos1.y-pos2.y);const dz=Math.abs(pos1.z-pos2.z);const dxz=Math.max(dx,dz);return dy+dxz}reversePath(node){const path=[];while(node.parent){path.push(node);node=node.parent}path.reverse();return path}path(start,end){this.list.clean();const openSet=[start];const closedSet=new Set;start.h=this.heuristic(start,end);start.g=0;start.f=start.h;start.visited=true;let current;while(openSet.length>0){let lowestIdx=0;let lowestF=openSet[0].f;let lowestG=openSet[0].g;for(let i=1;i<openSet.length;i++){const node=openSet[i];if(node.f<lowestF||node.f===lowestF&&node.g>lowestG){lowestF=node.f;lowestG=node.g;lowestIdx=i}}current=openSet[lowestIdx];if(current===end)return this.reversePath(current);openSet[lowestIdx]=openSet[openSet.length-1];openSet.pop();closedSet.add(current);const neighbors=current.links;for(let i=0;i<neighbors.length;i++){const neighbor=neighbors[i];if(closedSet.has(neighbor))continue;const tentativeGScore=current.g+1;if(!neighbor.visited||tentativeGScore<neighbor.g){const isNew=!neighbor.visited;neighbor.visited=true;neighbor.parent=current;neighbor.g=tentativeGScore;neighbor.h=this.heuristic(neighbor,end);neighbor.f=neighbor.g+neighbor.h;if(isNew)openSet.push(neighbor)}}}return null}}
@@ -1,284 +1 @@
1
- const FORWARD_RY_WEDGE_MAPPING = Object.freeze({
2
- 0: { x: 0, z: -1 },
3
- 1: { x: -1, z: 0 },
4
- 2: { x: 0, z: 1 },
5
- 3: { x: 1, z: 0 }
6
- });
7
- const positionKey = (x, y, z) => (x & 255) << 16 | (y & 255) << 8 | z & 255;
8
-
9
- class MapNode {
10
- constructor(meshType, data) {
11
- this.x = data.x;
12
- this.y = data.y;
13
- this.z = data.z;
14
- this.positionKey = positionKey(this.x, this.y, this.z);
15
- this.meshType = meshType.split(".").pop();
16
- this.f = 0;
17
- this.g = 0;
18
- this.h = 0;
19
- this.visited = null;
20
- this.parent = null;
21
- this.closed = null;
22
- this.links = [];
23
- this.flatCenter = {
24
- x: this.x + 0.5,
25
- y: this.y,
26
- z: this.z + 0.5
27
- };
28
- if (this.meshType === "wedge")
29
- this.ry = data.ry ?? 0;
30
- }
31
- isFull() {
32
- return this.meshType === "full";
33
- }
34
- canWalkThrough() {
35
- return this.meshType === "none" || this.meshType === "ladder";
36
- }
37
- canWalkOn() {
38
- return this.meshType === "full";
39
- }
40
- isLadder() {
41
- return this.meshType === "ladder";
42
- }
43
- isStair() {
44
- return this.meshType === "wedge";
45
- }
46
- isAir() {
47
- return this.meshType === "none";
48
- }
49
- isJumpPad() {
50
- return this.meshType === "jump-pad";
51
- }
52
- canLink(node, list) {
53
- const dx0 = this.x - node.x;
54
- const dz0 = this.z - node.z;
55
- const dy0 = this.y - node.y;
56
- const dx = Math.abs(dx0);
57
- const dy = Math.abs(dy0);
58
- const dz = Math.abs(dz0);
59
- if (dx + dy + dz === 0 || dx + dz > 1 && !(dx === 2 && dz === 1 || dx === 1 && dz === 2 || dx === 2 && dz === 2) || this.isFull() || node.isFull())
60
- return false;
61
- const belowMe = list.at(this.x, this.y - 1, this.z);
62
- const belowOther = list.at(node.x, node.y - 1, node.z);
63
- if (!belowMe || !belowOther)
64
- return false;
65
- if (dy === 0 && belowMe.isFull() && belowOther.isFull()) {
66
- if (dx === 2 && dz === 0 || dx === 0 && dz === 2) {
67
- const midX = (this.x + node.x) / 2;
68
- const midZ = (this.z + node.z) / 2;
69
- const midNode = list.at(midX, this.y, midZ);
70
- const midBelow = list.at(midX, this.y - 1, midZ);
71
- const midAbove = list.at(midX, this.y + 1, midZ);
72
- if (midBelow && midBelow.isAir()) {
73
- if (midNode && midNode.isAir() && midAbove && midAbove.isAir()) {
74
- const startHead = list.at(this.x, this.y + 1, this.z);
75
- const endHead = list.at(node.x, node.y + 1, node.z);
76
- if (startHead && startHead.isAir() && endHead && endHead.isAir()) {
77
- return true;
78
- }
79
- }
80
- }
81
- } else if (dx === 2 && dz === 1 || dx === 1 && dz === 2) {
82
- const xDir = dx0 > 0 ? -1 : 1;
83
- const zDir = dz0 > 0 ? -1 : 1;
84
- const checks = dx === 2 ? [
85
- [this.x + xDir, this.y, this.z],
86
- [this.x + xDir, this.y, this.z + zDir]
87
- ] : [
88
- [this.x, this.y, this.z + zDir],
89
- [this.x + xDir, this.y, this.z + zDir]
90
- ];
91
- let allClear = true;
92
- for (const [x, y, z] of checks) {
93
- const block = list.at(x, y, z);
94
- const blockBelow = list.at(x, y - 1, z);
95
- const blockAbove = list.at(x, y + 1, z);
96
- if (!block || !block.isAir() || !blockBelow || !blockBelow.isAir() || !blockAbove || !blockAbove.isAir()) {
97
- allClear = false;
98
- break;
99
- }
100
- }
101
- if (allClear) {
102
- const startHead = list.at(this.x, this.y + 1, this.z);
103
- const endHead = list.at(node.x, node.y + 1, node.z);
104
- if (startHead && startHead.isAir() && endHead && endHead.isAir())
105
- return true;
106
- }
107
- } else if (dx === 2 && dz === 2) {
108
- const xDir = dx0 > 0 ? -1 : 1;
109
- const zDir = dz0 > 0 ? -1 : 1;
110
- const checks = [
111
- [this.x + xDir, this.y, this.z + zDir],
112
- [this.x + 2 * xDir, this.y, this.z + zDir],
113
- [this.x + 2 * xDir, this.y, this.z + 2 * zDir]
114
- ];
115
- let allClear = true;
116
- for (const [x, y, z] of checks) {
117
- const block = list.at(x, y, z);
118
- const blockBelow = list.at(x, y - 1, z);
119
- const blockAbove = list.at(x, y + 1, z);
120
- if (!block || !block.isAir() || !blockBelow || !blockBelow.isAir() || !blockAbove || !blockAbove.isAir()) {
121
- allClear = false;
122
- break;
123
- }
124
- }
125
- if (allClear) {
126
- const startHead = list.at(this.x, this.y + 1, this.z);
127
- const endHead = list.at(node.x, node.y + 1, node.z);
128
- if (startHead && startHead.isAir() && endHead && endHead.isAir())
129
- return true;
130
- }
131
- }
132
- }
133
- const meSupported = belowMe.isFull() || this.isStair();
134
- const otherSupported = belowOther.isFull() || belowOther.isStair() || node.isStair();
135
- if (dy <= 2 && meSupported && otherSupported) {
136
- if (this.meshType === "none") {
137
- if (dy0 === 1 && node.canWalkThrough())
138
- return true;
139
- if (belowMe.canWalkOn() || belowMe.isLadder() || belowMe.isStair()) {
140
- if (node.meshType === "none" || node.meshType === "ladder" && dy === 0 || node.meshType === "wedge" && dy0 === 0 && dx0 === -FORWARD_RY_WEDGE_MAPPING[node.ry].x && dz0 === -FORWARD_RY_WEDGE_MAPPING[node.ry].z)
141
- return true;
142
- }
143
- return false;
144
- } else if (this.meshType === "ladder") {
145
- if (dy === 1 && node.canWalkThrough())
146
- return true;
147
- if (dy === 0 && belowMe.canWalkOn())
148
- return true;
149
- return node.meshType === "ladder" && (dy === 1 || belowMe.canWalkOn() && belowOther.canWalkOn());
150
- } else if (this.meshType === "wedge") {
151
- const forward = FORWARD_RY_WEDGE_MAPPING[this.ry];
152
- const backward = { x: -forward.x, z: -forward.z };
153
- if (this.x + forward.x === node.x && this.z + forward.z === node.z) {
154
- if (this.y + 1 === node.y && node.canWalkThrough())
155
- return true;
156
- if (this.y === node.y && node.meshType === "wedge")
157
- return true;
158
- if (this.y + 1 === node.y && node.meshType === "wedge")
159
- return true;
160
- }
161
- if (this.x + backward.x === node.x && this.z + backward.z === node.z) {
162
- if ((this.y === node.y || this.y - 1 === node.y) && node.canWalkThrough())
163
- return true;
164
- if (this.y - 1 === node.y && (node.meshType === "wedge" || node.meshType === "none" && belowOther.isFull()))
165
- return true;
166
- }
167
- if (node.canWalkThrough() && (belowOther.isFull() || belowOther.isStair()))
168
- return true;
169
- if (node.isStair())
170
- return true;
171
- return false;
172
- }
173
- }
174
- return false;
175
- }
176
- flatRadialDistance(position) {
177
- return Math.hypot(this.flatCenter.x - position.x, this.flatCenter.z - position.z);
178
- }
179
- }
180
- const NEIGHBOR_OFFSETS = [
181
- [1, 0, 0],
182
- [-1, 0, 0],
183
- [0, 1, 0],
184
- [0, -1, 0],
185
- [0, 0, 1],
186
- [0, 0, -1],
187
- [1, 0, 1],
188
- [1, 0, -1],
189
- [-1, 0, 1],
190
- [-1, 0, -1],
191
- [1, 1, 0],
192
- [-1, 1, 0],
193
- [0, 1, 1],
194
- [0, 1, -1],
195
- [1, -1, 0],
196
- [-1, -1, 0],
197
- [0, -1, 1],
198
- [0, -1, -1],
199
- [2, 0, 0],
200
- [-2, 0, 0],
201
- [0, 0, 2],
202
- [0, 0, -2],
203
- [2, 0, 1],
204
- [2, 0, -1],
205
- [-2, 0, 1],
206
- [-2, 0, -1],
207
- [1, 0, 2],
208
- [1, 0, -2],
209
- [-1, 0, 2],
210
- [-1, 0, -2],
211
- [2, 0, 2],
212
- [2, 0, -2],
213
- [-2, 0, 2],
214
- [-2, 0, -2]
215
- ];
216
-
217
- class NodeList {
218
- list = [];
219
- nodeMap = null;
220
- constructor(raw) {
221
- const addedPositions = new Set;
222
- for (const meshName of Object.keys(raw.data)) {
223
- for (const nodeData of raw.data[meshName]) {
224
- addedPositions.add(positionKey(nodeData.x, nodeData.y, nodeData.z));
225
- this.list.push(new MapNode(meshName, nodeData));
226
- }
227
- }
228
- for (let x = 0;x < raw.width; x++)
229
- for (let y = 0;y < raw.height; y++)
230
- for (let z = 0;z < raw.depth; z++)
231
- if (!addedPositions.has(positionKey(x, y, z)))
232
- this.list.push(new MapNode("SPECIAL.air.none", { x, y, z }));
233
- this.nodeMap = new Map;
234
- for (const node of this.list)
235
- this.nodeMap.set(node.positionKey, node);
236
- for (const node of this.list) {
237
- for (const [dx, dy, dz] of NEIGHBOR_OFFSETS) {
238
- const neighborKey = positionKey(node.x + dx, node.y + dy, node.z + dz);
239
- const neighborNode = this.nodeMap.get(neighborKey);
240
- if (neighborNode && node.canLink(neighborNode, this))
241
- node.links.push(neighborNode);
242
- }
243
- }
244
- }
245
- at(x, y, z) {
246
- return this.nodeMap?.get(positionKey(x, y, z));
247
- }
248
- atObject({ x, y, z }) {
249
- return this.nodeMap?.get(positionKey(Math.floor(x), Math.floor(y), Math.floor(z)));
250
- }
251
- clean() {
252
- for (const node of this.list) {
253
- node.f = 0;
254
- node.g = 0;
255
- node.h = 0;
256
- node.visited = null;
257
- node.parent = null;
258
- node.closed = null;
259
- }
260
- }
261
- hasLineOfSight(bot, target) {
262
- const dx = target.x - bot.x;
263
- const dy = target.y - bot.y;
264
- const dz = target.z - bot.z;
265
- const steps = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
266
- const xStep = dx / steps;
267
- const yStep = dy / steps;
268
- const zStep = dz / steps;
269
- let x = bot.x;
270
- let y = bot.y;
271
- let z = bot.z;
272
- for (let i = 0;i <= steps; i++) {
273
- const node = this.at(Math.round(x), Math.round(y), Math.round(z));
274
- if (node?.isFull())
275
- return false;
276
- x += xStep;
277
- y += yStep;
278
- z += zStep;
279
- }
280
- return true;
281
- }
282
- }
283
- export default MapNode;
284
- export { MapNode, NodeList };
1
+ const FORWARD_RY_WEDGE_MAPPING=Object.freeze({0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}});const positionKey=(x,y,z)=>(x&255)<<16|(y&255)<<8|z&255;class MapNode{constructor(meshType,data){this.x=data.x;this.y=data.y;this.z=data.z;this.positionKey=positionKey(this.x,this.y,this.z);this.meshType=meshType.split(".").pop();this.f=0;this.g=0;this.h=0;this.visited=null;this.parent=null;this.closed=null;this.links=[];this.flatCenter={x:this.x+0.5,y:this.y,z:this.z+0.5};if(this.meshType==="wedge")this.ry=data.ry??0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}isJumpPad(){return this.meshType==="jump-pad"}canLink(node,list){const dx0=this.x-node.x;const dz0=this.z-node.z;const dy0=this.y-node.y;const dx=Math.abs(dx0);const dy=Math.abs(dy0);const dz=Math.abs(dz0);if(dx+dy+dz===0||dx+dz>1&&!(dx===2&&dz===1||dx===1&&dz===2||dx===2&&dz===2)||this.isFull()||node.isFull())return false;const belowMe=list.at(this.x,this.y-1,this.z);const belowOther=list.at(node.x,node.y-1,node.z);if(!belowMe||!belowOther)return false;if(dy===0&&belowMe.isFull()&&belowOther.isFull()){if(dx===2&&dz===0||dx===0&&dz===2){const midX=(this.x+node.x)/2;const midZ=(this.z+node.z)/2;const midNode=list.at(midX,this.y,midZ);const midBelow=list.at(midX,this.y-1,midZ);const midAbove=list.at(midX,this.y+1,midZ);if(midBelow&&midBelow.isAir()){if(midNode&&midNode.isAir()&&midAbove&&midAbove.isAir()){const startHead=list.at(this.x,this.y+1,this.z);const endHead=list.at(node.x,node.y+1,node.z);if(startHead&&startHead.isAir()&&endHead&&endHead.isAir()){return true}}}}else if(dx===2&&dz===1||dx===1&&dz===2){const xDir=dx0>0?-1:1;const zDir=dz0>0?-1:1;const checks=dx===2?[[this.x+xDir,this.y,this.z],[this.x+xDir,this.y,this.z+zDir]]:[[this.x,this.y,this.z+zDir],[this.x+xDir,this.y,this.z+zDir]];let allClear=true;for(const[x,y,z]of checks){const block=list.at(x,y,z);const blockBelow=list.at(x,y-1,z);const blockAbove=list.at(x,y+1,z);if(!block||!block.isAir()||!blockBelow||!blockBelow.isAir()||!blockAbove||!blockAbove.isAir()){allClear=false;break}}if(allClear){const startHead=list.at(this.x,this.y+1,this.z);const endHead=list.at(node.x,node.y+1,node.z);if(startHead&&startHead.isAir()&&endHead&&endHead.isAir())return true}}else if(dx===2&&dz===2){const xDir=dx0>0?-1:1;const zDir=dz0>0?-1:1;const checks=[[this.x+xDir,this.y,this.z+zDir],[this.x+2*xDir,this.y,this.z+zDir],[this.x+2*xDir,this.y,this.z+2*zDir]];let allClear=true;for(const[x,y,z]of checks){const block=list.at(x,y,z);const blockBelow=list.at(x,y-1,z);const blockAbove=list.at(x,y+1,z);if(!block||!block.isAir()||!blockBelow||!blockBelow.isAir()||!blockAbove||!blockAbove.isAir()){allClear=false;break}}if(allClear){const startHead=list.at(this.x,this.y+1,this.z);const endHead=list.at(node.x,node.y+1,node.z);if(startHead&&startHead.isAir()&&endHead&&endHead.isAir())return true}}}const meSupported=belowMe.isFull()||this.isStair();const otherSupported=belowOther.isFull()||belowOther.isStair()||node.isStair();if(dy<=2&&meSupported&&otherSupported){if(this.meshType==="none"){if(dy0===1&&node.canWalkThrough())return true;if(belowMe.canWalkOn()||belowMe.isLadder()||belowMe.isStair()){if(node.meshType==="none"||node.meshType==="ladder"&&dy===0||node.meshType==="wedge"&&dy0===0&&dx0===-FORWARD_RY_WEDGE_MAPPING[node.ry].x&&dz0===-FORWARD_RY_WEDGE_MAPPING[node.ry].z)return true}return false}else if(this.meshType==="ladder"){if(dy===1&&node.canWalkThrough())return true;if(dy===0&&belowMe.canWalkOn())return true;return node.meshType==="ladder"&&(dy===1||belowMe.canWalkOn()&&belowOther.canWalkOn())}else if(this.meshType==="wedge"){const forward=FORWARD_RY_WEDGE_MAPPING[this.ry];const backward={x:-forward.x,z:-forward.z};if(this.x+forward.x===node.x&&this.z+forward.z===node.z){if(this.y+1===node.y&&node.canWalkThrough())return true;if(this.y===node.y&&node.meshType==="wedge")return true;if(this.y+1===node.y&&node.meshType==="wedge")return true}if(this.x+backward.x===node.x&&this.z+backward.z===node.z){if((this.y===node.y||this.y-1===node.y)&&node.canWalkThrough())return true;if(this.y-1===node.y&&(node.meshType==="wedge"||node.meshType==="none"&&belowOther.isFull()))return true}if(node.canWalkThrough()&&(belowOther.isFull()||belowOther.isStair()))return true;if(node.isStair())return true;return false}}return false}flatRadialDistance(position){return Math.hypot(this.flatCenter.x-position.x,this.flatCenter.z-position.z)}}const NEIGHBOR_OFFSETS=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1],[1,0,1],[1,0,-1],[-1,0,1],[-1,0,-1],[1,1,0],[-1,1,0],[0,1,1],[0,1,-1],[1,-1,0],[-1,-1,0],[0,-1,1],[0,-1,-1],[2,0,0],[-2,0,0],[0,0,2],[0,0,-2],[2,0,1],[2,0,-1],[-2,0,1],[-2,0,-1],[1,0,2],[1,0,-2],[-1,0,2],[-1,0,-2],[2,0,2],[2,0,-2],[-2,0,2],[-2,0,-2]];class NodeList{list=[];nodeMap=null;constructor(raw){const addedPositions=new Set;for(const meshName of Object.keys(raw.data)){for(const nodeData of raw.data[meshName]){addedPositions.add(positionKey(nodeData.x,nodeData.y,nodeData.z));this.list.push(new MapNode(meshName,nodeData))}}for(let x=0;x<raw.width;x++)for(let y=0;y<raw.height;y++)for(let z=0;z<raw.depth;z++)if(!addedPositions.has(positionKey(x,y,z)))this.list.push(new MapNode("SPECIAL.air.none",{x,y,z}));this.nodeMap=new Map;for(const node of this.list)this.nodeMap.set(node.positionKey,node);for(const node of this.list){for(const[dx,dy,dz]of NEIGHBOR_OFFSETS){const neighborKey=positionKey(node.x+dx,node.y+dy,node.z+dz);const neighborNode=this.nodeMap.get(neighborKey);if(neighborNode&&node.canLink(neighborNode,this))node.links.push(neighborNode)}}}at(x,y,z){return this.nodeMap?.get(positionKey(x,y,z))}atObject({x,y,z}){return this.nodeMap?.get(positionKey(Math.floor(x),Math.floor(y),Math.floor(z)))}clean(){for(const node of this.list){node.f=0;node.g=0;node.h=0;node.visited=null;node.parent=null;node.closed=null}}hasLineOfSight(bot,target){const dx=target.x-bot.x;const dy=target.y-bot.y;const dz=target.z-bot.z;const steps=Math.max(Math.abs(dx),Math.abs(dy),Math.abs(dz));const xStep=dx/steps;const yStep=dy/steps;const zStep=dz/steps;let x=bot.x;let y=bot.y;let z=bot.z;for(let i=0;i<=steps;i++){const node=this.at(Math.round(x),Math.round(y),Math.round(z));if(node?.isFull())return false;x+=xStep;y+=yStep;z+=zStep}return true}}export default MapNode;export{MapNode,NodeList};